Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default python interpreter doesn't work #97

Closed
acanis opened this issue May 3, 2024 · 3 comments
Closed

Default python interpreter doesn't work #97

acanis opened this issue May 3, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@acanis
Copy link
Contributor

acanis commented May 3, 2024

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 acanis added the bug Something isn't working label May 3, 2024
@tianjing-li
Copy link
Collaborator

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

@acanis
Copy link
Contributor Author

acanis commented May 6, 2024

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 added a commit to acanis/cohere-toolkit that referenced this issue May 6, 2024
…rarium:8080

The previous default http://localhost:8080 didn't work with docker
compose on Mac
@tianjing-li
Copy link
Collaborator

Thank you, let's go with that

lakshyaag pushed a commit to lakshyaag/cohere-toolkit that referenced this issue May 8, 2024
…http://terrarium:8080 (cohere-ai#103)

Fix cohere-ai#97: Change default python interpreter URL to http://terrarium:8080

The previous default http://localhost:8080 didn't work with docker
compose on Mac

Co-authored-by: Tianjing Li <tianjinglimail@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants