Copilot helps users answer questions and assignments through different tools. So far, copilot supports two agents types: Langchain Agent
and OpenAI Assistant Agent
.
- Make sure docker is installed
- Get the
etendo/etendo_copilot_core
image from dockerhub:docker pull etendo/etendo_copilot_core:develop
- Once image is downloaded:
- Set your local configuration copying
.env.sample
into.env
and set the right values - Run a container as:
docker run -it --env-file .env -p <host_machine_port>:<inside_docker_port> -v $(pwd)/:/app/ etendo/etendo_copilot_core:develop
- Make a request sample:
curl -i -X POST -H "Content-Type: application/json" -d '{"question": "What is etendo?"}' http://localhost:<host_machine_port>/question
- Set your local configuration copying
This is done automatically from CI for develop and experimental branches.
docker build -t etendo/chatbot_etendo .
docker push etendo/chatbot_etendo
kubectl port-forward -n chat-etendo svc/das 8092:8092
kubectl port-forward -n chat-etendo svc/etendo-retrieval 8085:8080
As tool for managing multiple Python versions you can use pyenv. pyenv
does not manage package dependencies, so for this purpose you can use Poetry. It will create an isolated virtual environment for the etendo-copilot-core
project.
- Install
pyenv
: https://github.com/pyenv/pyenv#installation - Install
Poetry
:curl -sSL https://install.python-poetry.org | python3 -
- Create
etendo-copilot-core
venv using poetry (recommended approach):
pyenv install 3.10
pyenv local 3.10
poetry env use 3.10
poetry install
Alternative, you can use Docker.
If you are getting this issue from poetry install
: Unable to find installation candidates for torch (2.0.1+cpu)
.
Workaround:
poetry shell
pip install torch==2.0.1
deactivate
Verify installation:
poetry run python
>>> import torch
>>> torch.__version__
'2.0.1'
- For prod dependency run:
poetry add <dep_name>
- For dev dependency run:
poetry add <dep_name> --group dev
- To export dependencies to
requirements.txt
run:pip freeze > requirements.txt
orpoetry export -without-hashes -f requirements.txt > requirements.txt
but removing the python versions range.
-
Locally outside docker:
- Copy
.env.sample
into.env
and set the right values poetry run python run.py
- Copy
-
Using docker, make sure
.env
is created and all the variables are set, only then rundocker run --env-file .env -p 5001:5001 etendo/chatbot_etendo
. You can set the port that you want, just be sure to set the same port in the image from.env
if not, the api will never be reached. -
The
AGENT_TYPE
environment variable should be used to set the agent type. There are two available agent:langchain
andopenai-assistant
. By default copilot will be executed forlangchain
. -
Mount code as volume:
docker run --env-file .env -p 5001:5001 -v $(pwd)/copilot:/app/copilot etendo/chatbot_etendo
.
poetry run pytest tests
You can get the open api (swagger) documentation from http://localhost:<port>/docs
or http://localhost:<port>/redoc
- Install pre-commit from HERE
- Setup pre-commit
pre-commit install & pre-commit autoupdate
- If you want to run for all the files:
pre-commit run --all-files
Any developer can define his own tools and attach them into copilot agent. So as to do this the third party tools MUST be added into the tools
package.
1- Create a new python module inside tools
package: hello_world.py
2- Extend the ToolWrapper class from copilot.core.tool_wrapper and set your own tool implementation. Boilerplate sample:
from copilot.core.tool_wrapper import ToolWrapper
class MyTool(ToolWrapper):
name = 'my_tool_name'
description = 'My tool description'
def __call__(self, *args, **kwargs):
# Implement your tool's logic HERE
3- Enable the new tool from tools_config.json
under third_party_tools
:
{
"native_tools": {
...
},
"third_party_tools": {
"MyTool": true
}
}
4- Restart the copilot container loading the project root folder through a volume: docker run --env-file .env -p 5001:5001 -v $(pwd):/app etendo/chatbot_etendo
1- Create a tools
directory and inside it create a __init__.py
file.
2- Create a new python module inside tools
package: hello_world.py
3- Extend the ToolWrapper class from copilot.core.tool_wrapper and set your own tool implementation. Boilerplate sample:
from copilot.core.tool_wrapper import ToolWrapper
class MyTool(ToolWrapper):
name = 'my_tool_name'
description = 'My tool description'
def __call__(self, *args, **kwargs):
# Implement your tool's logic HERE
4- Expose the new tool class name from __init__.py
from .hello_world import MyTool
5- Enable the new tool from tools_config.json
under third_party_tools
:
{
"native_tools": {
...
},
"third_party_tools": {
"MyTool": true
}
}
6- Restart the copilot container loading the project root folder through a volume: docker run --env-file .env -p 5001:5001 -v $(pwd)/tools:/app/tools -v $(pwd)/tools_config.json:/app/tools_config.json etendo/chatbot_etendo
Formats:
pandas
=> Installing latest versionpandas==1.3.3
=> Installing a specific versionpandas>=1.0.3
=> Greater than or equal to a certain versionpandas<=1.2.4
=> Less than or equal to a certain versionpandas>1.0.0
=> Greater than a certain versionpandas<2.0.0
=> Less than a certain versionpandas>=1.0.0,<=2.0.0
=> Using version rangespandas~=1.0.0
=> Tilde operator (~) for installing compatible versionspandas^1.0.0
=> Caret operator (^) for installing compatible versions