stanford-futuredata / FrugalGPT

FrugalGPT: better quality and lower cost for LLM applications
Apache License 2.0
185 stars 21 forks source link

Update Anthropic Client #2

Open krrishdholakia opened 1 year ago

krrishdholakia commented 1 year ago

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

https://github.com/stanford-futuredata/FrugalGPT/blob/a46f0a6ec1cf286ffd962dce99c6bf47659e5764/src/service/modelservice.py#L470


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

~Simple I/O library, 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: @lchen001

lchen001 commented 1 year ago

Thank you for pointing this out! I have tentatively fixed this by forcing anthropic version to be 0.2.10. In the future, the package will be fully upgraded to be compatible with the new version.