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

Handle multiple providers/llms #45

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Conversation

mbertrand
Copy link
Member

@mbertrand mbertrand commented Jan 31, 2025

What are the relevant tickets?

Closes https://github.com/mitodl/hq/issues/6622

Description (What does it do?)

  • Adds the langchain-community library and uses the ChatLiteLLM class for all LLM models.
  • Updates the LiteLLMProxy default kwargs to work with this class.
  • Adds support for one bedrock anthropic model in the LiteLLM proxy server configuration.
  • Sets different configurable default models for each bot.

How can this be tested?

  • You'll need this env value set (same as heroku mit-learn RC) in backend.local.env : OPENAI_API_KEY
  • Start the containers and go to http://ai.open.odl.local:8003. Ask some questions, it should work. Look at the logs, you should find this:
    web-1         | LiteLLM completion() model= gpt-4o; provider = openai
  • Add AI_DEFAULT_RECOMMENDATION_MODEL=openai/o3-mini to your backend.local.env file and restart containers.
  • Try the chat UI again. It should still work and you should see this in the logs:
    web-1         | LiteLLM completion() model= o3-mini; provider = openai
  • Add the following env settings to backend.local.env:
    AI_PROXY_URL=http://litellm:4000
    AI_PROXY_AUTH_TOKEN=sk-secret
    LITELLM_MASTER_KEY=sk-secret
    LITELLM_PROXY_API_KEY
    AI_PROXY_CLASS=LiteLLMProxy
    
  • Restart containers and interact with the chatbot again. It should still work and logs should indicate that the requests are going to the LiteLLM proxy service:
      litellm-1     | LiteLLM completion() model= o3-mini; provider = openai
    

@@ -43,3 +43,6 @@ KEYCLOAK_CLIENT_ID=apisix
KEYCLOAK_CLIENT_SECRET=HckCZXToXfaetbBx0Fo3xbjnC468oMi4 # pragma: allowlist-secret
KEYCLOAK_DISCOVERY_URL=http://${KEYCLOAK_SVC_HOSTNAME}:${KEYCLOAK_PORT}/realms/ol-local/.well-known/openid-configuration
KEYCLOAK_SCOPES="openid profile ol-profile"

#AWS settings
AWS_DEFAULT_REGION=us-east-1
Copy link
Member Author

Choose a reason for hiding this comment

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

Will be required for AWS Bedrock models

Comment on lines +50 to +51
# AWS_ACCESS_KEY_ID=
# AWS_SECRET_ACCESS_KEY=
Copy link
Member Author

Choose a reason for hiding this comment

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

Required for AWS Bedrock models

"ignore",
module=".*(pydantic).*",
category=UserWarning,
)
Copy link
Member Author

Choose a reason for hiding this comment

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

Pydantic warnings coming from ChatLiteLLM class

**(self.proxy.get_api_kwargs() if self.proxy else {}),
**(self.proxy.get_additional_kwargs(self) if self.proxy else {}),
**kwargs,
)
if self.temperature:
if self.temperature and self.model not in settings.AI_UNSUPPORTED_TEMP_MODELS:
Copy link
Member Author

Choose a reason for hiding this comment

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

The new o3-mini model does not support the temperature parameter and will raise an exception if it is passed along

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant