Comet Opik - Protokollierung + Evals
Opik ist eine Open-Source End-to-End LLM-Evaluierungsplattform, die Entwicklern hilft, ihre LLM-Prompts und Antworten während der Entwicklung und Produktion zu verfolgen. Benutzer können Auswertungen definieren und ausführen, um ihre LLM-Apps vor der Bereitstellung zu testen und nach Halluzinationen, Genauigkeit, Kontextabruf und mehr zu suchen!
Voraussetzungen
Mehr über die Einrichtung von Opik erfahren Sie im Opik-Schnellstartleitfaden. Mehr über das Self-Hosting von Opik erfahren Sie auch in unserem Self-Hosting-Leitfaden.
Schnellstart
Verwenden Sie nur 4 Codezeilen, um Ihre Antworten über alle Anbieter hinweg sofort mit Opik zu protokollieren.
Holen Sie sich Ihren Opik API-Schlüssel, indem Sie sich hier anmelden!
import litellm
litellm.callbacks = ["opik"]
Vollständige Beispiele
- SDK
- Proxy
import litellm
import os
# Configure the Opik API key or call opik.configure()
os.environ["OPIK_API_KEY"] = ""
os.environ["OPIK_WORKSPACE"] = ""
# LLM provider API Keys:
os.environ["OPENAI_API_KEY"] = ""
# set "opik" as a callback, litellm will send the data to an Opik server (such as comet.com)
litellm.callbacks = ["opik"]
# openai call
response = litellm.completion(
model="gpt-3.5-turbo",
messages=[
{"role": "user", "content": "Why is tracking and evaluation of LLMs important?"}
]
)
Wenn Sie liteLLM innerhalb einer Funktion verwenden, die mit dem @track-Decorator von Opik verfolgt wird, müssen Sie das Feld current_span_data im Metadatenattribut angeben, damit der LLM-Aufruf der richtigen Spur zugeordnet wird.
from opik import track
from opik.opik_context import get_current_span_data
import litellm
litellm.callbacks = ["opik"]
@track()
def streaming_function(input):
messages = [{"role": "user", "content": input}]
response = litellm.completion(
model="gpt-3.5-turbo",
messages=messages,
metadata = {
"opik": {
"current_span_data": get_current_span_data(),
"tags": ["streaming-test"],
},
}
)
return response
response = streaming_function("Why is tracking and evaluation of LLMs important?")
chunks = list(response)
- Konfigurieren Sie config.yaml
model_list:
- model_name: gpt-3.5-turbo-testing
litellm_params:
model: gpt-3.5-turbo
api_key: os.environ/OPENAI_API_KEY
litellm_settings:
callbacks: ["opik"]
environment_variables:
OPIK_API_KEY: ""
OPIK_WORKSPACE: ""
- Proxy ausführen
litellm --config config.yaml
- Testen Sie es!
curl -L -X POST 'http://0.0.0.0:4000/v1/chat/completions' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer sk-1234' \
-d '{
"model": "gpt-3.5-turbo-testing",
"messages": [
{
"role": "user",
"content": "What's the weather like in Boston today?"
}
]
}'
Opik-spezifische Parameter
Diese können innerhalb von Metadaten mit dem Schlüssel opik übergeben werden.
Felder
project_name- Name des Opik-Projekts, an das Daten gesendet werden sollen.current_span_data- Die aktuellen Span-Daten, die für das Tracing verwendet werden.tags- Tags, die für das Tracing verwendet werden sollen.
Verwendung
- SDK
- Proxy
from opik import track
from opik.opik_context import get_current_span_data
import litellm
litellm.callbacks = ["opik"]
messages = [{"role": "user", "content": input}]
response = litellm.completion(
model="gpt-3.5-turbo",
messages=messages,
metadata = {
"opik": {
"current_span_data": get_current_span_data(),
"tags": ["streaming-test"],
},
}
)
return response
curl -L -X POST 'http://0.0.0.0:4000/v1/chat/completions' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer sk-1234' \
-d '{
"model": "gpt-3.5-turbo-testing",
"messages": [
{
"role": "user",
"content": "What's the weather like in Boston today?"
}
],
"metadata": {
"opik": {
"current_span_data": "...",
"tags": ["streaming-test"],
},
}
}'
Support & Sprechen Sie mit den Gründern
- Demo buchen 👋
- Community Discord 💭
- Unsere Nummern 📞 +1 (770) 8783-106 / +1 (412) 618-6238
- Unsere E-Mails ✉️ ishaan@berri.ai / krrish@berri.ai