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

Add support for litellm and dozens of other providers #33

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ First things first! You can install the SDK with pip as follows:
pip install observers
```

Or if you want to use AISuite, you can install the SDK with pip as follows:
Or if you want to use other LLM providers through AISuite or Litellm, you can install the SDK with pip as follows:

```bash
pip install observers[aisuite]
pip install observers[aisuite] # or observers[litellm]
```

## Usage
Expand Down
17 changes: 17 additions & 0 deletions examples/observers/litellm_example.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import os

from litellm import completion
from observers.observers import wrap_litellm

# ensure you have both `ANTHROPIC_API_KEY` and `OPENAI_API_KEY` environment variables set
os.environ["OPENAI_API_KEY"] = "your-api-key"
os.environ["ANTHROPIC_API_KEY"] = "your-api-key"

completion = wrap_litellm(completion)

models = ["gpt-3.5-turbo", "claude-3-5-sonnet-20240620"]
messages = [{"content": "Hello, how are you?", "role": "user"}]

for model in models:
response = completion(model=model, messages=messages, temperature=0.75)
print(response.choices[0].message.content)
Loading