Default python interpreter doesn't work
acanis opened this issue · 3 comments
What is the issue?
When I setup the toolkit locally on Mac the python interpreter tool does not work.
Using make attach
and the python debugger I see:
-> res = requests.post(self.interpreter_url, json={"code": code})
(Pdb) p self.interpreter_url
'http://localhost:8080/'
(Pdb) n
2024-05-03 22:22:45,509 - urllib3.connectionpool - DEBUG - Starting new HTTP connection (1): localhost:8080
requests.exceptions.ConnectionError: HTTPConnectionPool(host='localhost', port=8080): Max retries exceeded with url: / (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0xffff4a881390>: Failed to establish a new connection: [Errno 111] Connection refused'))
> /workspace/src/backend/tools/function_tools/python_interpreter.py(48)call()
SOLUTION: Update PYTHON_INTERPRETER_URL
in the .env
file to specify the docker container name cohere-toolkit-terrarium-1
instead of localhost
then this works:
PYTHON_INTERPRETER_URL='http://cohere-toolkit-terrarium-1:8080'
I found this name from Docker desktop, the python tool is running on port 8080:
This must be a Docker network permission issue. Outside the docker in a shell, curl works:
curl --location 'http://localhost:8080/' \
--header 'User-Id: me' \
--header 'Content-Type: application/json' \
--data '{
"code": "1+3"
}'
{"success":true,"output_files":[],"final_expression":4,"std_out":"","std_err":"","code_runtime":26}
Additional information
No response
@acanis possible from the Docker services we need to point to the service name, do you mind retesting with http://terrarium:8080 as the url?
Yes I confirmed that setting the URL to:
PYTHON_INTERPRETER_URL='http://terrarium:8080'
Works fine. I will create a PR changing the default.
Thank you, let's go with that