Chainlit / cookbook

Chainlit's cookbook repo
https://github.com/Chainlit/chainlit
726 stars 270 forks source link

Update Anthropic Client #15

Closed krrishdholakia closed 1 year ago

krrishdholakia commented 1 year ago

Anthropic changed their python sdk - making this code line outdated.

https://github.com/Chainlit/cookbook/blob/b6aa4aadec67173805101502685b5b9dc0fe243b/anthropic-chat/app.py#L8

Would love to know if this might help - https://github.com/BerriAI/litellm

~100 lines of code, that standardizes all the llm api calls to the OpenAI call

from litellm import completion

## set ENV variables
# ENV variables can be set in .env file, too. Example in .env.example
os.environ["OPENAI_API_KEY"] = "openai key"
os.environ["ANTHROPIC_API_KEY"] = "anthropic key"

messages = [{ "content": "Hello, how are you?","role": "user"}]

# openai call
response = completion(model="gpt-3.5-turbo", messages=messages)

# anthropic call
response = completion("claude-v-2", messages)
krrishdholakia commented 1 year ago

cc: @willydouhard

willydouhard commented 1 year ago

Thank you for creating this issue! Just updated the anthropic-chat example. Will take a look at LiteLLM 👀