chore: import upstream snapshot with attribution
TypeScript SDK Compatibility V1.x E2E Tests / Select Node version matrix (push) Has been cancelled
TypeScript SDK Compatibility V1.x E2E Tests / TypeScript SDK Compatibility V1.x E2E Tests Node ${{matrix.node_version}} (push) Has been cancelled
TypeScript SDK E2E Tests / TypeScript SDK E2E Tests Node ${{matrix.node_version}} (push) Has been cancelled
Opik Optimizer - E2E Tests / build-opik (push) Has been cancelled
TypeScript SDK Compatibility V1.x E2E Tests / build-opik (push) Has been cancelled
Python SDK E2E Tests / Select Python version matrix (push) Has been cancelled
Python SDK E2E Tests / Python SDK E2E Tests ${{matrix.python_version}} (push) Has been cancelled
Python SDK E2E Tests / build-opik (push) Has been cancelled
Python SDK Compatibility V1.x E2E Tests / Select Python version matrix (push) Has been cancelled
Python SDK Compatibility V1.x E2E Tests / Python SDK Compatibility V1.x E2E Tests ${{matrix.python_version}} (push) Has been cancelled
Python SDK Compatibility V1.x E2E Tests / build-opik (push) Has been cancelled
TypeScript SDK E2E Tests / Select Node version matrix (push) Has been cancelled
TypeScript SDK E2E Tests / build-opik (push) Has been cancelled
Opik Optimizer - E2E Tests / Opik Optimizer E2E Tests Python ${{matrix.python_version}} (push) Has been cancelled
Opik Optimizer - E2E Tests / Opik Optimizer Integration Smoke Tests (push) Has been cancelled
🐙 Code Quality / detect (push) Has been cancelled
🐙 Code Quality / lint (${{ matrix.leg.name }}) (push) Has been cancelled
🐙 Code Quality / summary (push) Has been cancelled
TypeScript SDK Library Integration Tests / Check Secrets (push) Has been cancelled
TypeScript SDK Library Integration Tests / opik-vercel (Vercel AI SDK / eve) (push) Has been cancelled
SDK Library Integration Tests Runner / Check Secrets (push) Has been cancelled
SDK Library Integration Tests Runner / Missed OpenAI API Key Warning (push) Has been cancelled
SDK Library Integration Tests Runner / Build (push) Has been cancelled
SDK Library Integration Tests Runner / openai_tests (push) Has been cancelled
SDK Library Integration Tests Runner / langchain_tests (push) Has been cancelled
SDK Library Integration Tests Runner / langchain_legacy_tests (push) Has been cancelled
SDK Library Integration Tests Runner / llama_index_tests (push) Has been cancelled
SDK Library Integration Tests Runner / anthropic_tests (push) Has been cancelled
SDK Library Integration Tests Runner / mistral_tests (push) Has been cancelled
SDK Library Integration Tests Runner / groq_tests (push) Has been cancelled
SDK Library Integration Tests Runner / aisuite_tests (push) Has been cancelled
SDK Library Integration Tests Runner / haystack_tests (push) Has been cancelled
SDK Library Integration Tests Runner / dspy_tests (push) Has been cancelled
SDK Library Integration Tests Runner / crewai_v0_tests (push) Has been cancelled
SDK Library Integration Tests Runner / crewai_v1_tests (push) Has been cancelled
SDK Library Integration Tests Runner / genai_tests (push) Has been cancelled
SDK Library Integration Tests Runner / adk_tests (push) Has been cancelled
SDK Library Integration Tests Runner / adk_legacy_1_3_0_tests (push) Has been cancelled
SDK Library Integration Tests Runner / evaluation_metrics_tests (push) Has been cancelled
SDK Library Integration Tests Runner / bedrock_tests (push) Has been cancelled
SDK Library Integration Tests Runner / litellm_tests (push) Has been cancelled
SDK Library Integration Tests Runner / harbor_tests (push) Has been cancelled
SDK Library Integration Tests Runner / Slack Notification (push) Has been cancelled
Lint Opik Helm Chart / render-equality (push) Has been cancelled
Opik Optimizer - Unit Tests / Opik Optimizer Unit Tests Python ${{matrix.python_version}} (push) Has been cancelled
Python BE E2E Tests / Python BE E2E (push) Has been cancelled
Python Backend Tests / run-python-backend-tests (push) Has been cancelled
Python SDK Unit Tests / Python SDK Unit Tests ${{matrix.python_version}} (push) Has been cancelled
Release Drafter / update_release_draft (push) Has been cancelled
SDK E2E Libraries Integration Tests / Check Secrets (push) Has been cancelled
SDK E2E Libraries Integration Tests / Missed OpenAI API Key Warning (push) Has been cancelled
SDK E2E Libraries Integration Tests / build-opik (push) Has been cancelled
SDK E2E Libraries Integration Tests / E2E Lib Integration Python ${{matrix.python_version}} (push) Has been cancelled
TypeScript SDK Integration Build & Publish / build-and-publish (opik-gemini) (push) Has been cancelled
TypeScript SDK Integration Build & Publish / build-and-publish (opik-langchain) (push) Has been cancelled
TypeScript SDK Integration Build & Publish / build-and-publish (opik-openai) (push) Has been cancelled
TypeScript SDK Integration Build & Publish / build-and-publish (opik-otel) (push) Has been cancelled
TypeScript SDK Integration Build & Publish / build-and-publish (opik-vercel) (push) Has been cancelled
TypeScript SDK Build & Publish / build-and-publish (push) Has been cancelled
TypeScript SDK Unit Tests / Test on Node ${{ matrix.node-version }} (push) Has been cancelled
Backend Tests / discover-tests (push) Has been cancelled
Backend Tests / ${{ matrix.name }} (push) Has been cancelled
Build and Publish SDK / build-and-publish (push) Has been cancelled
Build Opik Docker Images / set-version (push) Has been cancelled
Build Opik Docker Images / build-backend (push) Has been cancelled
Build Opik Docker Images / build-sandbox-executor-python (push) Has been cancelled
Build Opik Docker Images / build-python-backend (push) Has been cancelled
Build Opik Docker Images / build-frontend (push) Has been cancelled
Build Opik Docker Images / create-git-tag (push) Has been cancelled
ClickHouse Migration Cluster Check / validate-clickhouse-migrations (push) Has been cancelled
Docs - Publish / run (push) Has been cancelled
E2E Tests - Post Merge (v2) / 🧪 E2E v2 Tests (${{ github.event.inputs.tier || 't1' }}) (push) Has been cancelled
E2E Tests - Post Merge (v2) / 📢 Slack Notification (push) Has been cancelled
Frontend Unit Tests / Test on Node 20 (push) Has been cancelled
Guardrails E2E Tests / Select Python version matrix (push) Has been cancelled
Guardrails E2E Tests / Guardrails E2E Tests ${{matrix.python_version}} (push) Has been cancelled
Guardrails E2E Tests / 📢 Slack Notification (push) Has been cancelled
Guardrails Backend Unit Tests / Guardrails Backend Unit Tests (push) Has been cancelled
Guardrails Backend Unit Tests / 📢 Slack Notification (push) Has been cancelled
Lint Opik Helm Chart / lint-helm-chart (Helm v3.21.0) (push) Has been cancelled
Lint Opik Helm Chart / lint-helm-chart (Helm v4.2.0) (push) Has been cancelled
Lint Opik Helm Chart / unittest-helm-chart (push) Has been cancelled
TypeScript SDK Compatibility V1.x E2E Tests / Select Node version matrix (push) Has been cancelled
TypeScript SDK Compatibility V1.x E2E Tests / TypeScript SDK Compatibility V1.x E2E Tests Node ${{matrix.node_version}} (push) Has been cancelled
TypeScript SDK E2E Tests / TypeScript SDK E2E Tests Node ${{matrix.node_version}} (push) Has been cancelled
Opik Optimizer - E2E Tests / build-opik (push) Has been cancelled
TypeScript SDK Compatibility V1.x E2E Tests / build-opik (push) Has been cancelled
Python SDK E2E Tests / Select Python version matrix (push) Has been cancelled
Python SDK E2E Tests / Python SDK E2E Tests ${{matrix.python_version}} (push) Has been cancelled
Python SDK E2E Tests / build-opik (push) Has been cancelled
Python SDK Compatibility V1.x E2E Tests / Select Python version matrix (push) Has been cancelled
Python SDK Compatibility V1.x E2E Tests / Python SDK Compatibility V1.x E2E Tests ${{matrix.python_version}} (push) Has been cancelled
Python SDK Compatibility V1.x E2E Tests / build-opik (push) Has been cancelled
TypeScript SDK E2E Tests / Select Node version matrix (push) Has been cancelled
TypeScript SDK E2E Tests / build-opik (push) Has been cancelled
Opik Optimizer - E2E Tests / Opik Optimizer E2E Tests Python ${{matrix.python_version}} (push) Has been cancelled
Opik Optimizer - E2E Tests / Opik Optimizer Integration Smoke Tests (push) Has been cancelled
🐙 Code Quality / detect (push) Has been cancelled
🐙 Code Quality / lint (${{ matrix.leg.name }}) (push) Has been cancelled
🐙 Code Quality / summary (push) Has been cancelled
TypeScript SDK Library Integration Tests / Check Secrets (push) Has been cancelled
TypeScript SDK Library Integration Tests / opik-vercel (Vercel AI SDK / eve) (push) Has been cancelled
SDK Library Integration Tests Runner / Check Secrets (push) Has been cancelled
SDK Library Integration Tests Runner / Missed OpenAI API Key Warning (push) Has been cancelled
SDK Library Integration Tests Runner / Build (push) Has been cancelled
SDK Library Integration Tests Runner / openai_tests (push) Has been cancelled
SDK Library Integration Tests Runner / langchain_tests (push) Has been cancelled
SDK Library Integration Tests Runner / langchain_legacy_tests (push) Has been cancelled
SDK Library Integration Tests Runner / llama_index_tests (push) Has been cancelled
SDK Library Integration Tests Runner / anthropic_tests (push) Has been cancelled
SDK Library Integration Tests Runner / mistral_tests (push) Has been cancelled
SDK Library Integration Tests Runner / groq_tests (push) Has been cancelled
SDK Library Integration Tests Runner / aisuite_tests (push) Has been cancelled
SDK Library Integration Tests Runner / haystack_tests (push) Has been cancelled
SDK Library Integration Tests Runner / dspy_tests (push) Has been cancelled
SDK Library Integration Tests Runner / crewai_v0_tests (push) Has been cancelled
SDK Library Integration Tests Runner / crewai_v1_tests (push) Has been cancelled
SDK Library Integration Tests Runner / genai_tests (push) Has been cancelled
SDK Library Integration Tests Runner / adk_tests (push) Has been cancelled
SDK Library Integration Tests Runner / adk_legacy_1_3_0_tests (push) Has been cancelled
SDK Library Integration Tests Runner / evaluation_metrics_tests (push) Has been cancelled
SDK Library Integration Tests Runner / bedrock_tests (push) Has been cancelled
SDK Library Integration Tests Runner / litellm_tests (push) Has been cancelled
SDK Library Integration Tests Runner / harbor_tests (push) Has been cancelled
SDK Library Integration Tests Runner / Slack Notification (push) Has been cancelled
Lint Opik Helm Chart / render-equality (push) Has been cancelled
Opik Optimizer - Unit Tests / Opik Optimizer Unit Tests Python ${{matrix.python_version}} (push) Has been cancelled
Python BE E2E Tests / Python BE E2E (push) Has been cancelled
Python Backend Tests / run-python-backend-tests (push) Has been cancelled
Python SDK Unit Tests / Python SDK Unit Tests ${{matrix.python_version}} (push) Has been cancelled
Release Drafter / update_release_draft (push) Has been cancelled
SDK E2E Libraries Integration Tests / Check Secrets (push) Has been cancelled
SDK E2E Libraries Integration Tests / Missed OpenAI API Key Warning (push) Has been cancelled
SDK E2E Libraries Integration Tests / build-opik (push) Has been cancelled
SDK E2E Libraries Integration Tests / E2E Lib Integration Python ${{matrix.python_version}} (push) Has been cancelled
TypeScript SDK Integration Build & Publish / build-and-publish (opik-gemini) (push) Has been cancelled
TypeScript SDK Integration Build & Publish / build-and-publish (opik-langchain) (push) Has been cancelled
TypeScript SDK Integration Build & Publish / build-and-publish (opik-openai) (push) Has been cancelled
TypeScript SDK Integration Build & Publish / build-and-publish (opik-otel) (push) Has been cancelled
TypeScript SDK Integration Build & Publish / build-and-publish (opik-vercel) (push) Has been cancelled
TypeScript SDK Build & Publish / build-and-publish (push) Has been cancelled
TypeScript SDK Unit Tests / Test on Node ${{ matrix.node-version }} (push) Has been cancelled
Backend Tests / discover-tests (push) Has been cancelled
Backend Tests / ${{ matrix.name }} (push) Has been cancelled
Build and Publish SDK / build-and-publish (push) Has been cancelled
Build Opik Docker Images / set-version (push) Has been cancelled
Build Opik Docker Images / build-backend (push) Has been cancelled
Build Opik Docker Images / build-sandbox-executor-python (push) Has been cancelled
Build Opik Docker Images / build-python-backend (push) Has been cancelled
Build Opik Docker Images / build-frontend (push) Has been cancelled
Build Opik Docker Images / create-git-tag (push) Has been cancelled
ClickHouse Migration Cluster Check / validate-clickhouse-migrations (push) Has been cancelled
Docs - Publish / run (push) Has been cancelled
E2E Tests - Post Merge (v2) / 🧪 E2E v2 Tests (${{ github.event.inputs.tier || 't1' }}) (push) Has been cancelled
E2E Tests - Post Merge (v2) / 📢 Slack Notification (push) Has been cancelled
Frontend Unit Tests / Test on Node 20 (push) Has been cancelled
Guardrails E2E Tests / Select Python version matrix (push) Has been cancelled
Guardrails E2E Tests / Guardrails E2E Tests ${{matrix.python_version}} (push) Has been cancelled
Guardrails E2E Tests / 📢 Slack Notification (push) Has been cancelled
Guardrails Backend Unit Tests / Guardrails Backend Unit Tests (push) Has been cancelled
Guardrails Backend Unit Tests / 📢 Slack Notification (push) Has been cancelled
Lint Opik Helm Chart / lint-helm-chart (Helm v3.21.0) (push) Has been cancelled
Lint Opik Helm Chart / lint-helm-chart (Helm v4.2.0) (push) Has been cancelled
Lint Opik Helm Chart / unittest-helm-chart (push) Has been cancelled
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
OpikTracer
|
||||
==========
|
||||
|
||||
.. autoclass:: opik.integrations.adk.OpikTracer
|
||||
:members:
|
||||
@@ -0,0 +1,33 @@
|
||||
ADK
|
||||
===
|
||||
|
||||
Opik integrates with Adk to allow you to log your ADK agent run to the Opik platform, use the `OpikTracer` callback to start logging::
|
||||
|
||||
from google.adk.agents import Agent
|
||||
from opik.integrations.adk import OpikTracer
|
||||
|
||||
|
||||
opik_tracer = OpikTracer()
|
||||
|
||||
root_agent = Agent(
|
||||
name="weather_time_agent",
|
||||
model="gemini-2.0-flash-exp",
|
||||
description=DESCRIPTION,
|
||||
instruction=INSTRUCTION,
|
||||
tools=[...],
|
||||
before_agent_callback=opik_tracer.before_agent_callback,
|
||||
after_agent_callback=opik_tracer.after_agent_callback,
|
||||
before_model_callback=opik_tracer.before_model_callback,
|
||||
after_model_callback=opik_tracer.after_model_callback,
|
||||
before_tool_callback=opik_tracer.before_tool_callback,
|
||||
after_tool_callback=opik_tracer.after_tool_callback,
|
||||
)
|
||||
|
||||
You can learn more about the `OpikTracer` object in the following section:
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 4
|
||||
:titlesonly:
|
||||
|
||||
OpikTracer
|
||||
track_adk_agent_recursive
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
track_adk_agent_recursive
|
||||
=========================
|
||||
|
||||
.. autofunction:: opik.integrations.adk.track_adk_agent_recursive
|
||||
@@ -0,0 +1,26 @@
|
||||
Anthropic
|
||||
=========
|
||||
|
||||
Opik integrates with Anthropic to allow you to log your Anthropic calls to the Opik platform, simply wrap the Anthropic client with `track_anthropic` to start logging::
|
||||
|
||||
from opik.integrations.anthropic import track_anthropic
|
||||
from anthropic import Anthropic
|
||||
|
||||
anthropic_client = Anthropic()
|
||||
openai_client = track_openai(openai_client)
|
||||
|
||||
response = anthropic_client.messages.create(
|
||||
model="claude-3-5-sonnet-20241022",
|
||||
max_tokens=1024,
|
||||
messages=[
|
||||
{"role": "user", "content": PROMPT}
|
||||
]
|
||||
)
|
||||
|
||||
You can learn more about the `track_anthropic` decorator in the following section:
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 4
|
||||
:titlesonly:
|
||||
|
||||
track_anthropic
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
track_anthropic
|
||||
===============
|
||||
|
||||
.. autofunction:: opik.integrations.anthropic.track_anthropic
|
||||
@@ -0,0 +1,26 @@
|
||||
Bedrock
|
||||
=======
|
||||
|
||||
Opik integrates with Bedrock to allow you to log your Bedrock calls to the Opik platform, simply wrap the Bedrock client with `track_bedrock` to start logging::
|
||||
|
||||
from opik.integrations.bedrock import track_bedrock
|
||||
import boto3
|
||||
|
||||
bedrock = boto3.client(
|
||||
service_name="bedrock-runtime",
|
||||
region_name=REGION,
|
||||
)
|
||||
bedrock_client = track_bedrock(bedrock, project_name="bedrock-integration-demo")
|
||||
|
||||
response = bedrock_client.converse(
|
||||
modelId=MODEL_ID,
|
||||
messages=[{"role": "user", "content": [{"text": "Hello World!"}]}],
|
||||
)
|
||||
|
||||
You can learn more about the `track_bedrock` decorator in the following section:
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 4
|
||||
:titlesonly:
|
||||
|
||||
track_bedrock
|
||||
@@ -0,0 +1,4 @@
|
||||
track_bedrock
|
||||
=============
|
||||
|
||||
.. autofunction:: opik.integrations.bedrock.track_bedrock
|
||||
@@ -0,0 +1,65 @@
|
||||
CrewAI
|
||||
=======
|
||||
|
||||
Opik integrates with CrewAI to allow you to log your CrewAI activities and LLM calls to the Opik platform, simply invoke `track_crewai` to start logging::
|
||||
|
||||
from opik.integrations.crewai import track_crewai
|
||||
from crewai import Agent, Crew, Task, Process
|
||||
|
||||
|
||||
class YourCrewName:
|
||||
def agent_one(self) -> Agent:
|
||||
return Agent(
|
||||
role="Data Analyst",
|
||||
goal="Analyze data trends in the market",
|
||||
backstory="An experienced data analyst with a background in economics",
|
||||
verbose=True,
|
||||
)
|
||||
|
||||
def agent_two(self) -> Agent:
|
||||
return Agent(
|
||||
role="Market Researcher",
|
||||
goal="Gather information on market dynamics",
|
||||
backstory="A diligent researcher with a keen eye for detail",
|
||||
verbose=True
|
||||
)
|
||||
|
||||
def task_one(self) -> Task:
|
||||
return Task(
|
||||
name="Collect Data Task",
|
||||
description="Collect recent market data and identify trends.",
|
||||
expected_output="A report summarizing key trends in the market.",
|
||||
agent=self.agent_one()
|
||||
)
|
||||
|
||||
def task_two(self) -> Task:
|
||||
return Task(
|
||||
name="Market Research Task",
|
||||
description="Research factors affecting market dynamics.",
|
||||
expected_output="An analysis of factors influencing the market.",
|
||||
agent=self.agent_two()
|
||||
)
|
||||
|
||||
def crew(self) -> Crew:
|
||||
return Crew(
|
||||
agents=[self.agent_one(), self.agent_two()],
|
||||
tasks=[self.task_one(), self.task_two()],
|
||||
process=Process.sequential,
|
||||
verbose=True
|
||||
)
|
||||
|
||||
track_crewai(project_name="crewai-integration-demo")
|
||||
|
||||
my_crew = YourCrewName().crew()
|
||||
result = my_crew.kickoff()
|
||||
|
||||
print(result)
|
||||
|
||||
|
||||
You can learn more about the `track_crewai` decorator in the following section:
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 4
|
||||
:titlesonly:
|
||||
|
||||
track_crewai
|
||||
@@ -0,0 +1,4 @@
|
||||
track_crewai
|
||||
=============
|
||||
|
||||
.. autofunction:: opik.integrations.crewai.track_crewai
|
||||
@@ -0,0 +1,5 @@
|
||||
OpikCallback
|
||||
============
|
||||
|
||||
.. autoclass:: opik.integrations.dspy.OpikCallback
|
||||
:members:
|
||||
@@ -0,0 +1,32 @@
|
||||
DSPy
|
||||
====
|
||||
|
||||
Opik integrates with DSPy to allow you to log your DSPy runs to the Opik platform::
|
||||
|
||||
import dspy
|
||||
from opik.integrations.dspy.callback import OpikCallback
|
||||
|
||||
project_name = "DSPY"
|
||||
|
||||
lm = dspy.LM(
|
||||
model="openai/gpt-4o-mini",
|
||||
)
|
||||
dspy.configure(lm=lm)
|
||||
|
||||
|
||||
opik_callback = OpikCallback(project_name=project_name, log_graph=True)
|
||||
dspy.settings.configure(
|
||||
callbacks=[opik_callback],
|
||||
)
|
||||
|
||||
cot = dspy.ChainOfThought("question -> answer")
|
||||
cot(question="What is the meaning of life?")
|
||||
|
||||
|
||||
You can learn more about the `OpikCallback` in the following section:
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 4
|
||||
:titlesonly:
|
||||
|
||||
OpikCallback
|
||||
@@ -0,0 +1,44 @@
|
||||
Guardrails AI
|
||||
=============
|
||||
|
||||
Opik integrates with Guardrails AI to allow you to log your activities to the Opik platform, simply invoke `track_guardrails` to start logging.
|
||||
|
||||
|
||||
First, install the politeness check from the guardrails hub:
|
||||
|
||||
``guardrails hub install hub://guardrails/politeness_check``
|
||||
|
||||
|
||||
Then you can run the example:
|
||||
::
|
||||
|
||||
from guardrails import Guard, OnFailAction
|
||||
from guardrails.hub import PolitenessCheck
|
||||
|
||||
import opik
|
||||
from opik.integrations.guardrails import track_guardrails
|
||||
|
||||
politeness_check = PolitenessCheck(
|
||||
llm_callable="gpt-3.5-turbo", on_fail=OnFailAction.NOOP
|
||||
)
|
||||
|
||||
guard: Guard = Guard()
|
||||
if hasattr(guard, "use_many"):
|
||||
guard = guard.use_many(politeness_check)
|
||||
else:
|
||||
guard = guard.use(politeness_check)
|
||||
guard = track_guardrails(guard, project_name="guardrails-integration-example")
|
||||
|
||||
result = guard.validate(
|
||||
"Would you be so kind to pass me a cup of tea?",
|
||||
)
|
||||
|
||||
Every guardrails check will be logged as a separate trace. Opik will capture inputs, outputs, and provide the trace with a tag "fail" or "pass" for easier management.
|
||||
|
||||
You can learn more about the `track_guardrails` decorator in the following section:
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 4
|
||||
:titlesonly:
|
||||
|
||||
track_guardrails
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
track_guardrails
|
||||
================
|
||||
|
||||
.. autofunction:: opik.integrations.guardrails.track_guardrails
|
||||
@@ -0,0 +1,5 @@
|
||||
OpikConnector
|
||||
=============
|
||||
|
||||
.. autoclass:: opik.integrations.haystack.OpikConnector
|
||||
:members:
|
||||
@@ -0,0 +1,53 @@
|
||||
Haystack
|
||||
========
|
||||
|
||||
Opik integrates with Haystack to allow you to log your Haystack pipeline runs to the Opik platform, simply wrap the Haystack pipeline with `OpikConnector` to start logging::
|
||||
|
||||
import os
|
||||
|
||||
os.environ["HAYSTACK_CONTENT_TRACING_ENABLED"] = "true"
|
||||
|
||||
from haystack import Pipeline
|
||||
from haystack.components.builders import ChatPromptBuilder
|
||||
from haystack.components.generators.chat import OpenAIChatGenerator
|
||||
from haystack.dataclasses import ChatMessage
|
||||
|
||||
from opik.integrations.haystack import OpikConnector
|
||||
|
||||
|
||||
pipe = Pipeline()
|
||||
|
||||
# Add the OpikConnector component to the pipeline
|
||||
pipe.add_component(
|
||||
"tracer", OpikConnector("Chat example")
|
||||
)
|
||||
|
||||
# Continue building the pipeline
|
||||
pipe.add_component("prompt_builder", ChatPromptBuilder())
|
||||
pipe.add_component("llm", OpenAIChatGenerator(model="gpt-3.5-turbo"))
|
||||
|
||||
pipe.connect("prompt_builder.prompt", "llm.messages")
|
||||
|
||||
messages = [
|
||||
ChatMessage.from_system(
|
||||
"Always respond in German even if some input data is in other languages."
|
||||
),
|
||||
ChatMessage.from_user("Tell me about {{location}}"),
|
||||
]
|
||||
|
||||
response = pipe.run(
|
||||
data={
|
||||
"prompt_builder": {
|
||||
"template_variables": {"location": "Berlin"},
|
||||
"template": messages,
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
You can learn more about the `OpikConnector` in the following section:
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 4
|
||||
:titlesonly:
|
||||
|
||||
OpikConnector
|
||||
@@ -0,0 +1,5 @@
|
||||
OpikTracer
|
||||
==========
|
||||
|
||||
.. autoclass:: opik.integrations.langchain.OpikTracer
|
||||
:members:
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
extract_current_langgraph_span_data
|
||||
===================================
|
||||
|
||||
.. autofunction:: opik.integrations.langchain.extract_current_langgraph_span_data
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
langchain
|
||||
=========
|
||||
|
||||
Opik integrates with Langchain to allow you to log your Langchain calls to the Opik platform, simply wrap the Langchain client with `OpikTracer` to start logging::
|
||||
|
||||
from langchain.chains import LLMChain
|
||||
from langchain_openai import OpenAI
|
||||
from langchain.prompts import PromptTemplate
|
||||
from opik.integrations.langchain import OpikTracer
|
||||
|
||||
# Initialize the tracer
|
||||
opik_tracer = OpikTracer()
|
||||
|
||||
# Create the LLM Chain using LangChain
|
||||
llm = OpenAI(temperature=0)
|
||||
|
||||
prompt_template = PromptTemplate(
|
||||
input_variables=["input"],
|
||||
template="Translate the following text to French: {input}"
|
||||
)
|
||||
|
||||
llm_chain = LLMChain(llm=llm, prompt=prompt_template)
|
||||
|
||||
# Generate the translations
|
||||
translation = llm_chain.run("Hello, how are you?", callbacks=[opik_tracer])
|
||||
print(translation)
|
||||
|
||||
You can learn more about the LangChain integration functions in the following sections:
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 4
|
||||
:titlesonly:
|
||||
|
||||
OpikTracer
|
||||
track_langgraph
|
||||
extract_current_langgraph_span_data
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
track_langgraph
|
||||
===============
|
||||
|
||||
.. autofunction:: opik.integrations.langchain.track_langgraph
|
||||
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
LlamaIndexCallbackHandler
|
||||
=========================
|
||||
|
||||
.. autofunction:: opik.integrations.llama_index.LlamaIndexCallbackHandler
|
||||
@@ -0,0 +1,19 @@
|
||||
llama_index
|
||||
===========
|
||||
|
||||
Opik integrates with LlamaIndex to allow you to log your LlamaIndex calls to the Opik platform. To enable the logging to Opik, simply set::
|
||||
|
||||
from llama_index.core import Settings
|
||||
from llama_index.core.callbacks import CallbackManager
|
||||
from opik.integrations.llama_index import LlamaIndexCallbackHandler
|
||||
|
||||
opik_callback_handler = LlamaIndexCallbackHandler()
|
||||
Settings.callback_manager = CallbackManager([opik_callback_handler])
|
||||
|
||||
You can learn more about the `LlamaIndexCallbackHandler` callback in the following section:
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 4
|
||||
:titlesonly:
|
||||
|
||||
LlamaIndexCallbackHandler
|
||||
@@ -0,0 +1,22 @@
|
||||
openai
|
||||
=======
|
||||
|
||||
Opik integrates with OpenAI to allow you to log your OpenAI calls to the Opik platform, simply wrap the OpenAI client with `track_openai` to start logging::
|
||||
|
||||
from opik.integrations.openai import track_openai
|
||||
from openai import OpenAI
|
||||
|
||||
openai_client = OpenAI()
|
||||
openai_client = track_openai(openai_client)
|
||||
|
||||
response = openai_client.Completion.create(
|
||||
prompt="Hello, world!",
|
||||
)
|
||||
|
||||
You can learn more about the `track_openai` decorator in the following section:
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 4
|
||||
:titlesonly:
|
||||
|
||||
track_openai
|
||||
@@ -0,0 +1,4 @@
|
||||
track_openai
|
||||
============
|
||||
|
||||
.. autofunction:: opik.integrations.openai.track_openai
|
||||
Reference in New Issue
Block a user