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

Changing AsyncOpenAI( base_url=' ' ) #15

Open
Sparkxxx opened this issue Nov 26, 2024 · 0 comments
Open

Changing AsyncOpenAI( base_url=' ' ) #15

Sparkxxx opened this issue Nov 26, 2024 · 0 comments

Comments

@Sparkxxx
Copy link

Hello,

I've found your project looking for a translator and discovered W&B which is an awsome project and this sent me into the lerning rabbit hole. Now I'm hooked and want to dig deeper and learn more python and weave using your complete project.

I am trying to use gpt_translate with LiteLLM on my Ubuntu VM with venv.
I've put LiteLLM through a proxy so that I don't get TLS errors and defined correct dns.

I can't get the AsyncOpenAI client to connect to my endpoint.
Curl works without any errors and I can tcpdump see the transactions on the LiteLLM interface.
Initialized wandb as docker container and logged in with the cli, all good, I can see the gpt_translate project in the UI.

What I've tried so far:

Defining environment variables:

    export OPENAI_API_KEY=sk-1234
    export OPENAI_BASE_URL=https://litellm.mydomain.lan/v1

Made changes in /src/utils.py:

try:
    openai_client = AsyncOpenAI(
        base_url='https://litellm.mydomain.lan/v1',
        api_key='sk-1234'
    )
    print(openai_client.base_url)
    print(openai_client.api_key)
except Exception:
    logging.warning("Failed to initialize OpenAI client. Using a dummy client.")
    openai_client = None

After each modification of the code I ran pip install . again in the project's folder, changes are reflected in the output.

Successfully built gpt_translate
Installing collected packages: gpt_translate
  Attempting uninstall: gpt_translate
    Found existing installation: gpt_translate 4.0.0
    Uninstalling gpt_translate-4.0.0:
      Successfully uninstalled gpt_translate-4.0.0
Successfully installed gpt_translate-4.0.0

Running gpt_translate with default example + debug flag:

(venv) sparkx@dockers:~/gpt_translate$ gpt_translate.file --input_file README.md --out_file README_es_.md --language es --config_folder ./configs --debug

[2024-11-26 09:27:23 - httpx:82 - DEBUG] load_ssl_context verify=True cert=None trust_env=True http2=False
[2024-11-26 09:27:23 - httpx:148 - DEBUG] load_verify_locations cafile='/home/sparkx/gpt_translate/venv/lib/python3.10/site-packages/certifi/cacert.pem'
https://litellm.mydomain.lan/v1/
sk-1234

^CTraceback (most recent call last):
  File "/home/sparkx/gpt_translate/venv/bin/gpt_translate.file", line 8, in <module>
    sys.exit(translate_file())
  File "/home/sparkx/gpt_translate/venv/lib/python3.10/site-packages/gpt_translate/cli.py", line 39, in translate_file
    setup_logging(
  File "/home/sparkx/gpt_translate/venv/lib/python3.10/site-packages/gpt_translate/cli.py", line 21, in setup_logging
    weave.init(weave_project)
  File "/home/sparkx/gpt_translate/venv/lib/python3.10/site-packages/weave/trace/api.py", line 55, in init
    return weave_init.init_weave(project_name).client
  File "/home/sparkx/gpt_translate/venv/lib/python3.10/site-packages/weave/trace/weave_init.py", line 128, in init_weave
    remote_server.server_info().min_required_weave_python_version
  File "/home/sparkx/gpt_translate/venv/lib/python3.10/site-packages/tenacity/__init__.py", line 336, in wrapped_f
    return copy(f, *args, **kw)
  File "/home/sparkx/gpt_translate/venv/lib/python3.10/site-packages/tenacity/__init__.py", line 485, in __call__
    self.sleep(do)
  File "/home/sparkx/gpt_translate/venv/lib/python3.10/site-packages/tenacity/nap.py", line 31, in sleep
    time.sleep(seconds)
KeyboardInterrupt

No matter what I do, wait or change I always get the nap.py sleep end line. No requests are made to my endpoint.

Is there anything more you can think of that I might test or do to get the client to connect?

Thank you.

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

No branches or pull requests

1 participant