cohere-toolkit icon indicating copy to clipboard operation
cohere-toolkit copied to clipboard

Default python interpreter doesn't work

Open acanis opened this issue 9 months ago • 1 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: image

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 avatar May 03 '24 22:05 acanis

@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?

tianjing-li avatar May 04 '24 03:05 tianjing-li

Yes I confirmed that setting the URL to:

PYTHON_INTERPRETER_URL='http://terrarium:8080'

Works fine. I will create a PR changing the default.

acanis avatar May 06 '24 02:05 acanis

Thank you, let's go with that

tianjing-li avatar May 06 '24 14:05 tianjing-li