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

fix: api_url concat #27

Merged
merged 1 commit into from
May 15, 2023
Merged

Conversation

nero19960329
Copy link
Contributor

close #26

@mikelambert
Copy link
Collaborator

Thanks for the quick fix! I kinda hate raw string concat for this kind of thing, what do you think of a different solution:
You pass up "http://localhost/anthropic/" instead of "http://localhost/anthropic".
And then change this PR from "/v1/complete" to be "v1/complete"

I believe this should work?

>>> from urllib.parse import urljoin
>>> urljoin("http://localhost/anthropic/", "/v1/complete")
'http://localhost/v1/complete'
>>> urljoin("http://localhost/anthropic/", "v1/complete")
'http://localhost/anthropic/v1/complete'
>>> urljoin("http://localhost/anthropic", "v1/complete")
'http://localhost/v1/complete'

@nero19960329
Copy link
Contributor Author

Thanks for the quick fix! I kinda hate raw string concat for this kind of thing, what do you think of a different solution: You pass up "http://localhost/anthropic/" instead of "http://localhost/anthropic". And then change this PR from "/v1/complete" to be "v1/complete"

I believe this should work?

>>> from urllib.parse import urljoin
>>> urljoin("http://localhost/anthropic/", "/v1/complete")
'http://localhost/v1/complete'
>>> urljoin("http://localhost/anthropic/", "v1/complete")
'http://localhost/anthropic/v1/complete'
>>> urljoin("http://localhost/anthropic", "v1/complete")
'http://localhost/v1/complete'

It works! Now I've changed my fixing plan.

@ravintpillai
Copy link

ravintpillai commented May 14, 2023

any idea when this will get merged? Proposed fix looks sensible to me and would actually help us as well! :D

@mikelambert mikelambert merged commit 342da8c into anthropics:main May 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fix URL concatenation in anthropic/api.py
3 participants