This guide will walk you through the process of debugging the dockerized Toolkit API using VSCode or PyCharm. Debugging allows you to inspect the code, set breakpoints, and step through the code execution to identify and fix issues.
To debug the dockerized Toolkit API using VSCode, follow these steps:
.vscode/launch.json
file if exists or create a new one.configurations
array in the launch.json
file:
{
"configurations": [
{
"name": "Python Debugger: Remote Attach to Toolkit",
"type": "debugpy",
"request": "attach",
"connect": {
"host": "localhost",
"port": 5678
},
"pathMappings": [
{
"localRoot": "${workspaceFolder}/src/backend",
"remoteRoot": "/workspace/src/backend/"
}
]
},
................ your other configurations here(if not exists just remove the comma)..........
]
}
make vscode-debug
Python Debugger: Remote Attach to Toolkit
configuration in the debug panel and clicking the play button.
To debug the dockerized Toolkit API using PyCharm, follow these steps:
PyCharm > Settings > Project: <project_name> > Python Interpreter
(Click ⌘Сmd,
on Mac).Add interpreter
and select On Docker Compose
.
docker-compose.pycharm.debug.yml
file and select the service name backend
.
Next
to apply the changes.Next
after setup will be completed, click Create
to create the new interpreter.Apply
and OK
to save the changes.make pycharm-debug
Run > Edit Configurations
from the menu.
+
button and select Python
Toolkit Docker Debug
src/backend/pycharm_debug_main.py
/path/to/cohere-toolkit
)Apply
and OK
to save the configuration.
Toolkit Docker Debug
configuration in the debug panel and clicking the bug button.