Project Icon

knowledge

多平台内容聚合与知识图谱导航工具

Knowledge是一个Web应用,自动从GitHub、HackerNews、Zotero和Twitter等平台提取用户互动内容。它集成了搜索引擎和知识图谱功能,便于浏览文档和自动提取的标签。应用通过Fly.io托管,支持每日内容更新和ChatGPT搜索结果重排。此工具提供个性化知识管理和探索功能,具有低成本和易部署的特点。

Knowledge

Personal bookmarks


Knowledge is a web application that automatically extract content you interact with from various social media platforms, including GitHub, HackerNews, Zotero, and Twitter. It creates a search engine, coupled with a knowledge graph that enables to navigate through documents and automatically extracted tags.

A live version of my personal knowledge graph is available online.

The web app is hosted with Fly.io, and its GitHub action workflow calls APIs from Twitter, GitHub, HackerNews, and Zotero on a daily basis to extract content from the user's starred repositories, upvoted posts, uploaded documents, and liked tweets. The extracted content is tagged to enhance the search experience, and the updated version of the web app is pushed automatically.

How it works

Twice a day, a dedicated github workflow extracts:

  • GitHub stars

  • Twitter likes

  • HackerNews upvotes

  • Zotero records

The data generated by the workflow of this tool is stored in various files located in the database directory. Specifically, the records are exported to the file database/database.json, while the knowledge graph of topics is saved in the file database/triples.json. Additionally, the workflow generates a search engine and saves it as database/retriever.pkl. Finally, the updated state of the application is pushed to the cloud provider Fly.io and the dedicated GitHub page is updated accordingly. The cost of hosting the application is under 8$ per month. It may increase if a large number of users query your bookmarks 24/7. Costs can be bounded via Fly.io and OpenAI dashboards.

Alt text


Secrets

To deploy this tool, the first step is to fork the repository and clone it locally. The next step involves defining secrets in the repository configurations (fork) for the different APIs that the system requests. The application requires several secrets to access the different APIs. While it is possible to skip some of the secrets, it is necessary to set FLY_API_TOKEN and OPENAI_API_KEY. If you do not plan to use ChatGPT, you can leave OPENAI_API_KEY empty. It is important to set secrets as repository secrets and not as environment secrets.

Alt text

Twitter

To extract likes, we will need a Twitter API TOKEN, available on the Developer Portal after having creater an account.

TWITTER_TOKEN
Zotero

We will need a "group library" to index content from Zotero. The ZOTERO_API_KEY is available at https://www.zotero.org/settings/keys.

ZOTERO_API_KEY

The ZOTERO_LIBRARY_ID can be found by opening the group's page https://www.zotero.org/groups/groupname, and hovering over the group settings link. The ID is the integer after /groups/.

ZOTERO_LIBRARY_ID
Hackernews

We will need to create secrets for both Hackernews username and password.

HACKERNEWS_USERNAME
HACKERNEWS_PASSWORD
OpenAI

OpenAI API is used to call ChatGPT when pressing the button "ask" to re-rank documents based on our query. If we do not plan to use ChatGPT, we will need to set the secret OPENAI_API_KEY with an empty value. We can get our OpenAI key here.

OPENAI_API_KEY

The prompt to ChatGPT is stored in the api/api.py file.

Fly.io

We will need to install the flyctl client available here to set the FLY_API_TOKEN. The fly.io api token enables the github action to automatically push the updated state of the api. We can get the token using the command line:

flyctl auth signup
fly auth login
flyctl auth token
FLY_API_TOKEN

Sources

After finalizing the secrets, we can specify the Github and Twitter users whose liked content we wish to extract. To achieve this, we'll need to modify the sources.yml file located at the root of the repository. We'll be able to handpick the Github stars we want to index and set the Twitter ID and handle of the users whose content we want to include. To obtain the Twitter ID, we can use a tool like tweeterid.com."

github:
  - "raphaelsty"
  - "gbolmier"
  - "MaxHalford"
  - "AdilZouitine"

twitter:
  - [1262679654239961088, "raphaelsrty"]

Deployment

Fly.io

Once secrets and sources are set. We will deploy the API following the Fly.io documentation. You won't need any database. fly client should generate a fly.toml file that looks like the toml file below where app_name is the name of our api.

app = "app_name"
kill_signal = "SIGINT"
kill_timeout = 5
processes = []

[env]

[experimental]
  auto_rollback = true

[[services]]
  http_checks = []
  internal_port = 8080
  processes = ["app"]
  protocol = "tcp"
  script_checks = []
  [services.concurrency]
    hard_limit = 6
    soft_limit = 3
    type = "connections"

  [[services.ports]]
    force_https = true
    handlers = ["http"]
    port = 80

  [[services.ports]]
    handlers = ["tls", "http"]
    port = 443

  [[services.tcp_checks]]
    grace_period = "1s"
    interval = "15s"
    restart_limit = 0
    timeout = "2s"

⚠️ After having created our API, we will need to update the urls called by the web app in the file docs/index.html. There are 3 urls to replace: https://knowledge.fly.dev per https://app_name.fly.dev where app_name is your API name.

Github Page

We will need to set the Github Page from the repository configurations (fork).

Alt text

⚠️ After creating your github page, you will have to modify the origins field of the api/api.py file:

origins = [
    "https://raphaelsty.github.io", # Put your own github page name here.
]

Costs

⚠️ To avoid any financial incident, remember to define a hard_limit and a soft_limit which will bounder the number of instance Fly.io will deploy to answer to peak demands and therefore limit the costs. Those parameters are available in the fly.toml file.

[services.concurrency]
	hard_limit = 6
	soft_limit = 3
	type = "connections"

⚠️ Setting a 2GB memory VM with a single shared cpu on FLy.io will do the job for the app.

Alt text

⚠️ Don't forget to define the limit amount you want to spend on OpenAI platform (10$ here).

Alt text

Development

To run the API locally using Docker, we can export the OPENAI_API_KEY to our environment variables using:

export OPENAI_API_KEY="sk-..."

Then, we can run make launch at the root of the repository.

make launch

We can also deploy the API manually using:

fly deploy \
    --build-secret OPENAI_API_KEY=$OPENAI_API_KEY

Notes

My personal Knowledge Base is inspired and extract resources from the Knowledge Base of François-Paul Servant namely Semanlink.

License

GNU GENERAL PUBLIC LICENSE Knowledge Copyright (C) 2023 Raphaël Sourty

项目侧边栏1项目侧边栏2
推荐项目
Project Cover

豆包MarsCode

豆包 MarsCode 是一款革命性的编程助手,通过AI技术提供代码补全、单测生成、代码解释和智能问答等功能,支持100+编程语言,与主流编辑器无缝集成,显著提升开发效率和代码质量。

Project Cover

AI写歌

Suno AI是一个革命性的AI音乐创作平台,能在短短30秒内帮助用户创作出一首完整的歌曲。无论是寻找创作灵感还是需要快速制作音乐,Suno AI都是音乐爱好者和专业人士的理想选择。

Project Cover

有言AI

有言平台提供一站式AIGC视频创作解决方案,通过智能技术简化视频制作流程。无论是企业宣传还是个人分享,有言都能帮助用户快速、轻松地制作出专业级别的视频内容。

Project Cover

Kimi

Kimi AI助手提供多语言对话支持,能够阅读和理解用户上传的文件内容,解析网页信息,并结合搜索结果为用户提供详尽的答案。无论是日常咨询还是专业问题,Kimi都能以友好、专业的方式提供帮助。

Project Cover

阿里绘蛙

绘蛙是阿里巴巴集团推出的革命性AI电商营销平台。利用尖端人工智能技术,为商家提供一键生成商品图和营销文案的服务,显著提升内容创作效率和营销效果。适用于淘宝、天猫等电商平台,让商品第一时间被种草。

Project Cover

吐司

探索Tensor.Art平台的独特AI模型,免费访问各种图像生成与AI训练工具,从Stable Diffusion等基础模型开始,轻松实现创新图像生成。体验前沿的AI技术,推动个人和企业的创新发展。

Project Cover

SubCat字幕猫

SubCat字幕猫APP是一款创新的视频播放器,它将改变您观看视频的方式!SubCat结合了先进的人工智能技术,为您提供即时视频字幕翻译,无论是本地视频还是网络流媒体,让您轻松享受各种语言的内容。

Project Cover

美间AI

美间AI创意设计平台,利用前沿AI技术,为设计师和营销人员提供一站式设计解决方案。从智能海报到3D效果图,再到文案生成,美间让创意设计更简单、更高效。

Project Cover

AIWritePaper论文写作

AIWritePaper论文写作是一站式AI论文写作辅助工具,简化了选题、文献检索至论文撰写的整个过程。通过简单设定,平台可快速生成高质量论文大纲和全文,配合图表、参考文献等一应俱全,同时提供开题报告和答辩PPT等增值服务,保障数据安全,有效提升写作效率和论文质量。

投诉举报邮箱: service@vectorlightyear.com
@2024 懂AI·鲁ICP备2024100362号-6·鲁公网安备37021002001498号