-
-
Save jcheng5/28a84f3fde930778e09509ad0437030f to your computer and use it in GitHub Desktop.
LiteLLM otel
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| OTEL_SERVICE_NAME=litellm-test | |
| OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4318/v1/traces | |
| OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from dotenv import load_dotenv | |
| import litellm | |
| def main(): | |
| # Load environment variables from .env file | |
| load_dotenv() | |
| # Enable OpenTelemetry integration | |
| litellm.callbacks = ["otel"] | |
| # Set up the request to ollama | |
| messages = [ | |
| {"role": "user", "content": "What is the capital of France?"} | |
| ] | |
| # Make the chat completion request | |
| response = litellm.completion( | |
| model="ollama/llama3.1:8b", | |
| messages=messages | |
| ) | |
| # Print the response | |
| print("Response from model:") | |
| print(response.choices[0].message.content) | |
| if __name__ == "__main__": | |
| main() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| backoff | |
| litellm[proxy] | |
| opentelemetry-api | |
| opentelemetry-exporter-otlp | |
| opentelemetry-sdk | |
| python-dotenv |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment