GAIR-NLP / factool

FacTool: Factuality Detection in Generative AI
https://ethanc111.github.io/factool_website/
Apache License 2.0
804 stars 62 forks source link

Add support for Azure, OpenAI, Palm, Anthropic, Cohere, Replicate Models - using litellm #20

Open ishaan-jaff opened 1 year ago

ishaan-jaff commented 1 year ago

This PR adds support for models from all the above mentioned providers using https://github.com/BerriAI/litellm

Here's a sample of how it's used:

from litellm import completion, acompletion

## 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["COHERE_API_KEY"] = "cohere key"

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

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

# async openai
response = acompletion(model="gpt-3.5-turbo", messages=messages)

# cohere call
response = completion("command-nightly", messages)

# anthropic call
response = completion(model="claude-instant-1", messages=messages)
ishaan-jaff commented 1 year ago

@pfliu-nlp @EthanC111 can you take a look at this when you get a chance? If this initial commit looks good - happy to update readme and add tests😊

pfliu-nlp commented 1 year ago

hi @ishaan-jaff Thanks a lot for your attention on this project and nice PR, which looks good to me overall. I left one comment. I think we can merge this PR once: