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

Inconsistent base_url behavior with module client and OpenAIClient #1373

Open
1 task done
dramdass opened this issue Apr 26, 2024 · 2 comments
Open
1 task done

Inconsistent base_url behavior with module client and OpenAIClient #1373

dramdass opened this issue Apr 26, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@dramdass
Copy link

dramdass commented Apr 26, 2024

Confirm this is an issue with the Python library and not an underlying OpenAI API

  • This is an issue with the Python library

Describe the bug

The issue is that the base_url in the OpenAI client enforces a trailing slash whereas setting the module openai.base_url does not enforce.

This is 100% reproducible and while it can be worked around, the inconsistency in clients causes issues in scripts that use both clients.

To Reproduce

  1. Create a module client and use a base_url without a trailing slash. See error with URL for completions
  2. Create an OpenAIClient and use a base_url without a trailing slash. See no erros.

Code snippets

This works

    client = openai.OpenAI(
        api_key=my_key,
        base_url="https://myllmserver.com/api/v1"
    )
    print(client.completions.create(
       model="mistralai/Mistral-7B-Instruct-v0.2",
       prompt="test" 
    ))

This does not:

    openai.base_url="https://myllmserver.com/api/v1"
    openai.api_key=my_key
    print(openai.completions.create(
       model="mistralai/Mistral-7B-Instruct-v0.2",
       prompt="test"
    ))

Error:

https://myllmserver.com/api/v1completions "HTTP/1.1 404 Not Found"

OS

macOS

Python version

Python v3.12

Library version

openai v1.23.6

@dramdass dramdass added the bug Something isn't working label Apr 26, 2024
@rattrayalex
Copy link
Collaborator

Thanks for reporting, @dramdass. I'm not sure we'd prioritize a fix here, but we'd likely accept a contribution that updates the module client to match the non-module client.

@dramdass
Copy link
Author

The right fix seems to be in src/__init__.py but the comment says # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.. I could't find a relevant place in the schema here https://github.com/openai/openai-openapi/tree/master to generate it. Can I add the fix manually into src/__init__.py?

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