Polyhistor is a AI bot that can answer questions from documents.
We use Poetry to manage dependencies.
poetry shell
poetry install
Create testdata
directory in the root directory and add files.
Now we only support
.md
,.txt
,.docx
,
You can also import documents from github repositories.
Use pre-commit.
pre-commit install
Create a .env
file in the root directory and add the following environment variables:
MODE="dev"
LANGCHAIN_TRACING_V2=true
LANGCHAIN_API_KEY=<LANGCHAIN_API_KEY>
MODEL_API=<the model api from Mattermost>
ACCESS_TOKEN=<Github access token>
MATTERMOST_TOKEN=<Mattermost token>
Note:
- You can get the
LANGCHAIN_API_KEY
from LangSmith.- Get the
MODEL_API
from Mattermost.- (Optional) How to get Github access token: Github Docs
- (Optional) How to get Mattermost token: Mattermost Docs
Default port:6333
If you want to change the port, please modify the
docker-compose.yml
andconfig.yaml
.
cd vectorDB
docker-compose up -d
python vectorDB/create_collection.py
python vectorDB/read_docs.py --source <source_type>
<source_type>
:local
orgithub
If you choose
github
, you need to addACCESS_TOKEN
in.env
python vectorDB/read_mattermost.py
You need to add
MATTERMOST_TOKEN
in.env
It will import the messages from specific users.
poetry run uvicorn index:app --reload --host 0.0.0.0 --port 8080
Now you can access the API at http://localhost:8080/api/v1/ask
.
Open a new terminal and run the following command:
cd src
python main.py
Then you can ask questions to the model.
If you want to exit, type bye
.
.env 中的 MODE 設定成 "official"
docker-compose up -d --build