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

community: Remove all other keys in ChatLiteLLM and add api_key #28097

Merged
merged 4 commits into from
Dec 16, 2024

Conversation

chenzimin
Copy link
Contributor

@chenzimin chenzimin commented Nov 13, 2024

Thank you for contributing to LangChain!

  • PR title: "community: Remove all other keys in ChatLiteLLM and add api_key"

  • PR message: Currently, no api_key are passed to LiteLLM, and LiteLLM only takes on api_key parameter. Therefore I removed all current *_api_key attributes (They are not used), and added api_key that is passed to ChatLiteLLM.

Copy link

vercel bot commented Nov 13, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
langchain ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 16, 2024 5:54pm

@dosubot dosubot bot added size:XS This PR changes 0-9 lines, ignoring generated files. community Related to langchain-community size:M This PR changes 30-99 lines, ignoring generated files. and removed size:XS This PR changes 0-9 lines, ignoring generated files. labels Nov 13, 2024
Copy link
Member

@efriis efriis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hey there! is this a recent change in litellm that merits this change / is it possible this will break something for current users of this + an old version of lite llm?

@efriis efriis self-assigned this Dec 9, 2024
@chenzimin
Copy link
Contributor Author

I am not sure, in the current litellm documentation it states that you can provide different provider keys by (https://docs.litellm.ai/docs/set_keys#litellm-variables):

litellm.openai_key = "sk-OpenAIKey"
response = litellm.completion(messages=messages, model="gpt-3.5-turbo")

# anthropic call
litellm.anthropic_key = "sk-AnthropicKey"
response = litellm.completion(messages=messages, model="claude-2")

Even from the initial version of litellm (back in Nov 2023), they are called openai_key, not openai_api_key, https://github.com/BerriAI/litellm/blob/1b4aadbb253043378fd58205dc66f4fcc9339976/litellm/__init__.py#L8

But api_key is checked for all providers.

Plus I have not found where openai_api_key, openai_api_key ... are used in the current ChatliteLLM.

@dosubot dosubot bot added size:S This PR changes 10-29 lines, ignoring generated files. and removed size:M This PR changes 30-99 lines, ignoring generated files. labels Dec 16, 2024
Copy link
Collaborator

@ccurme ccurme left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@chenzimin from what I can tell, you're correct that the named API keys are not used and it is defensible to delete them.

I think it's preferable to just fix them in this case instead of deleting the fields, in case users are setting them somewhere.

I've updated the PR to support the api_key field in addition to the named keys. Let me know if you see any issues with this.

Thanks!

@dosubot dosubot bot added the lgtm PR looks good. Use to confirm that a PR is ready for merging. label Dec 16, 2024
@ccurme ccurme enabled auto-merge (squash) December 16, 2024 17:47
@ccurme ccurme merged commit 169d419 into langchain-ai:master Dec 16, 2024
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community Related to langchain-community lgtm PR looks good. Use to confirm that a PR is ready for merging. size:S This PR changes 10-29 lines, ignoring generated files.
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants