{"id":13492208,"url":"https://github.com/daveshap/KB_microservice","last_synced_at":"2025-03-28T09:34:00.046Z","repository":{"id":217431394,"uuid":"653646436","full_name":"daveshap/KB_microservice","owner":"daveshap","description":"KB (knowledge base) microservice powered by GPT4. For chatbots, cognitive architectures, and autonomous agents","archived":true,"fork":false,"pushed_at":"2023-06-16T13:35:05.000Z","size":16,"stargazers_count":76,"open_issues_count":1,"forks_count":33,"subscribers_count":8,"default_branch":"main","last_synced_at":"2024-10-31T06:34:48.384Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/daveshap.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-06-14T13:00:06.000Z","updated_at":"2024-10-18T18:13:24.000Z","dependencies_parsed_at":null,"dependency_job_id":"1d878376-9d66-413f-99a7-cc2b62d10068","html_url":"https://github.com/daveshap/KB_microservice","commit_stats":null,"previous_names":["daveshap/kb_microservice"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daveshap%2FKB_microservice","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daveshap%2FKB_microservice/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daveshap%2FKB_microservice/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daveshap%2FKB_microservice/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/daveshap","download_url":"https://codeload.github.com/daveshap/KB_microservice/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246004265,"owners_count":20708172,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-31T19:01:04.025Z","updated_at":"2025-03-28T09:34:00.041Z","avatar_url":"https://github.com/daveshap.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"# KB Microservice\n\nThe KB Microservice is a Python-based application that provides a simple and efficient way to manage a knowledge base\n(KB) of articles. It allows users to create, search, and update KB articles through a RESTful API. The service uses\nOpenAI's GPT model to process and generate the content of the articles.\n\n\n| Endpoint | Method | Description | Parameters | Example Request |\n| --- | --- | --- | --- | --- |\n| `/create` | POST | Creates a new KB article | `input`: The text for the new KB article | `{ \"input\": \"This is the text for the new KB article.\" }` |\n| `/search` | POST | Searches for KB articles | `query`: The search query | `{ \"query\": \"search query\" }` |\n| `/update` | POST | Updates an existing KB article | `title`: The title of the KB article to update\u003cbr\u003e`input`: The new text for the KB article | `{ \"title\": \"Article 1\", \"input\": \"This is the updated text for the KB article.\" }` |\n\n## Setup\n\n1. Create `key_openai.txt` and place your API key within.\n2. Create `kb/` directory for your KB articles.\n3. Install all requirements in `requirements.txt`.\n\n## Usage\n\n1. Run `kb_microservice.py` - this is a Flask app that runs on 999 by default.\n2. Test it using `test_kb_service.py` to create, search, and update KB articles.\n\n# How It Works\n\nThe KB Microservice uses Flask, a lightweight web framework for Python, to expose endpoints for creating, searching, and\nupdating KB articles. The service uses YAML files to store the articles, and a directory text file to keep track of all\nthe articles in the knowledge base.\n\nThe service uses OpenAI's GPT model to process user inputs and generate the content of the articles. The GPT model\nis a powerful language model that can generate human-like text based on the input it receives.\n\n## Creating KB Articles\n\nTo create a KB article, a POST request is made to the `/create` endpoint with a JSON payload containing the text for the\narticle. The service then uses the GPT model to process the text and generate a JSON object containing the title,\ndescription, keywords, and body of the article. The article is then saved as a YAML file in the knowledge base\ndirectory.\n\n## Searching KB Articles\n\nTo search for KB articles, a POST request is made to the `/search` endpoint with a JSON payload containing the search\nquery. The service first updates the directory of articles, then uses the GPT model to process the query and return a\nlist of relevant article filenames. The service then opens each file, converts the YAML content to JSON, and returns the\nlist of articles as a JSON response.\n\n## Updating KB Articles\n\nTo update a KB article, a POST request is made to the `/update` endpoint with a JSON payload containing the title of the\narticle to update and the new text for the article. The service first opens the existing article, then uses the GPT\nmodel to process the new text and generate an updated JSON object for the article. The updated article is then saved\nback to the knowledge base directory.\n\n# Future Work\n\n1. Daily Journal (episodic memory)\n   - Prioritize based on relevance, or temporal proximity\n2. Tasks (like internal Jira or Trello)\n   - Prioritize based on ROI or heuristic imperatives (e.g. which tasks will reduce suffering the most, increase prosperity the most, and increase understanding the most)\n3. Dossiers (basically KB article on users)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdaveshap%2FKB_microservice","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdaveshap%2FKB_microservice","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdaveshap%2FKB_microservice/lists"}