Skip to content

Commit f070dd1

Browse files
Merge branch 'main' into feat/portkey-tracing-integration
2 parents 3c66d8b + 90b940c commit f070dd1

File tree

13 files changed

+2603
-143
lines changed

13 files changed

+2603
-143
lines changed

.release-please-manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
".": "0.4.0"
2+
".": "0.9.0"
33
}

CHANGELOG.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,60 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
66
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
77

8+
## 0.9.0 (2025-11-24)
9+
10+
Full Changelog: [v0.8.1...v0.9.0](https://github.com/openlayer-ai/openlayer-python/compare/v0.8.1...v0.9.0)
11+
12+
### Features
13+
14+
* enhance LangFlow integration with improved context detection ([5c1d3a5](https://github.com/openlayer-ai/openlayer-python/commit/5c1d3a559f5a3380d804ead9bbef4bb9b0ebc30c))
15+
* improve async trace handling in AsyncOpenlayerHandler ([01fa425](https://github.com/openlayer-ai/openlayer-python/commit/01fa42594c98507e718c065fdcec732c3a9c8181))
16+
17+
## 0.8.1 (2025-11-13)
18+
19+
Full Changelog: [v0.8.0...v0.8.1](https://github.com/openlayer-ai/openlayer-python/compare/v0.8.0...v0.8.1)
20+
21+
### Bug Fixes
22+
23+
* **closes OPEN-8001:** handle ValueError in _current_step.reset to manage context variable mismatches ([5649f17](https://github.com/openlayer-ai/openlayer-python/commit/5649f172dd4892a92bea5bc5220b79511f13afd4))
24+
25+
## 0.8.0 (2025-11-11)
26+
27+
Full Changelog: [v0.7.0...v0.8.0](https://github.com/openlayer-ai/openlayer-python/compare/v0.7.0...v0.8.0)
28+
29+
### Features
30+
31+
* **closes OPEN-7550:** add tracing for openai chat completions parse method ([47c4487](https://github.com/openlayer-ai/openlayer-python/commit/47c44873375faf333191e92751ba22eda7b7cd6f))
32+
33+
## 0.7.0 (2025-11-11)
34+
35+
Full Changelog: [v0.6.0...v0.7.0](https://github.com/openlayer-ai/openlayer-python/compare/v0.6.0...v0.7.0)
36+
37+
### Features
38+
39+
* **closes OPEN-7119:** add Google ADK tracing integration with Openlayer ([b7a0706](https://github.com/openlayer-ai/openlayer-python/commit/b7a0706979fde2bf1226b122bcab889e08c7b127))
40+
41+
42+
### Documentation
43+
44+
* add Colab badge to Google ADK tracing notebook for easier access ([89916a8](https://github.com/openlayer-ai/openlayer-python/commit/89916a8db2f2525f1941664cb5480a0e41a82f90))
45+
46+
## 0.6.0 (2025-11-11)
47+
48+
Full Changelog: [v0.5.0...v0.6.0](https://github.com/openlayer-ai/openlayer-python/compare/v0.5.0...v0.6.0)
49+
50+
### Features
51+
52+
* **closes OPEN-7543:** update trace openai to support responses api ([4969d03](https://github.com/openlayer-ai/openlayer-python/commit/4969d034bbb5484dbac94f160a1fb95cc6c8fc39))
53+
54+
## 0.5.0 (2025-11-07)
55+
56+
Full Changelog: [v0.4.0...v0.5.0](https://github.com/openlayer-ai/openlayer-python/compare/v0.4.0...v0.5.0)
57+
58+
### Features
59+
60+
* add examples for creating and managing LLM projects and tests ([#543](https://github.com/openlayer-ai/openlayer-python/issues/543)) ([86b9e2d](https://github.com/openlayer-ai/openlayer-python/commit/86b9e2d566e0d4e72de14ed43369ebcc6a089d27))
61+
862
## 0.4.0 (2025-10-22)
963

1064
Full Changelog: [v0.3.1...v0.4.0](https://github.com/openlayer-ai/openlayer-python/compare/v0.3.1...v0.4.0)
Lines changed: 293 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,293 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"metadata": {},
6+
"source": [
7+
"[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/openlayer-ai/openlayer-python/blob/main/examples/tracing/google-adk/google_adk_tracing.ipynb)\n",
8+
"\n",
9+
"# Google ADK Tracing with Openlayer\n",
10+
"\n",
11+
"This notebook demonstrates how to trace Google Agent Development Kit (ADK) agents with Openlayer.\n",
12+
"\n",
13+
"## Prerequisites\n",
14+
"\n",
15+
"Install the required packages:\n",
16+
"```bash\n",
17+
"pip install openlayer google-adk wrapt\n",
18+
"```\n"
19+
]
20+
},
21+
{
22+
"cell_type": "markdown",
23+
"metadata": {},
24+
"source": [
25+
"## Setup\n",
26+
"\n",
27+
"First, configure your Openlayer credentials and Google Cloud credentials:\n"
28+
]
29+
},
30+
{
31+
"cell_type": "code",
32+
"execution_count": null,
33+
"metadata": {},
34+
"outputs": [],
35+
"source": [
36+
"import os\n",
37+
"\n",
38+
"# Openlayer configuration\n",
39+
"os.environ[\"OPENLAYER_API_KEY\"] = \"your-api-key-here\"\n",
40+
"os.environ[\"OPENLAYER_INFERENCE_PIPELINE_ID\"] = \"your-pipeline-id-here\"\n",
41+
"\n",
42+
"# Google AI API configuration (Option 1: Using Google AI Studio)\n",
43+
"# Get your API key from: https://aistudio.google.com/apikey\n",
44+
"os.environ[\"GOOGLE_API_KEY\"] = \"your-google-ai-api-key-here\"\n",
45+
"\n",
46+
"# Google Cloud Vertex AI configuration (Option 2: Using Google Cloud)\n",
47+
"# Uncomment these if you're using Vertex AI instead of Google AI\n",
48+
"# os.environ[\"GOOGLE_APPLICATION_CREDENTIALS\"] = \"path/to/your/service-account-key.json\"\n",
49+
"# os.environ[\"GOOGLE_CLOUD_PROJECT\"] = \"your-project-id\"\n",
50+
"# os.environ[\"GOOGLE_CLOUD_LOCATION\"] = \"us-central1\"\n"
51+
]
52+
},
53+
{
54+
"cell_type": "markdown",
55+
"metadata": {},
56+
"source": [
57+
"## Enable Google ADK Tracing\n",
58+
"\n",
59+
"Enable tracing before creating any agents. This patches Google ADK globally to send traces to Openlayer:\n"
60+
]
61+
},
62+
{
63+
"cell_type": "code",
64+
"execution_count": null,
65+
"metadata": {},
66+
"outputs": [],
67+
"source": [
68+
"from openlayer.lib.integrations import trace_google_adk\n",
69+
"\n",
70+
"# Enable tracing (must be called before creating agents)\n",
71+
"trace_google_adk()"
72+
]
73+
},
74+
{
75+
"cell_type": "markdown",
76+
"metadata": {},
77+
"source": [
78+
"## Example 1: Basic Agent with LLM Calls\n",
79+
"\n",
80+
"Create a simple agent that responds to user queries:\n"
81+
]
82+
},
83+
{
84+
"cell_type": "code",
85+
"execution_count": null,
86+
"metadata": {},
87+
"outputs": [],
88+
"source": [
89+
"\n",
90+
"from google.genai import types\n",
91+
"from google.adk.agents import LlmAgent\n",
92+
"from google.adk.runners import Runner\n",
93+
"from google.adk.sessions import InMemorySessionService\n",
94+
"\n",
95+
"# Setup constants\n",
96+
"APP_NAME = \"openlayer_demo\"\n",
97+
"USER_ID = \"user_123\"\n",
98+
"SESSION_ID = \"session_123\"\n",
99+
"\n",
100+
"# Create session service (shared across examples)\n",
101+
"session_service = InMemorySessionService()\n",
102+
"\n",
103+
"# Create a basic agent\n",
104+
"agent = LlmAgent(\n",
105+
" model=\"gemini-2.0-flash-exp\",\n",
106+
" name=\"Assistant\",\n",
107+
" instruction=\"You are a helpful assistant. Provide concise and accurate responses.\"\n",
108+
")\n",
109+
"\n",
110+
"# Create runner\n",
111+
"runner = Runner(\n",
112+
" agent=agent,\n",
113+
" app_name=APP_NAME,\n",
114+
" session_service=session_service\n",
115+
")\n",
116+
"\n",
117+
"# Define async function to run the agent\n",
118+
"async def run_basic_agent():\n",
119+
" # Create session\n",
120+
" await session_service.create_session(\n",
121+
" app_name=APP_NAME,\n",
122+
" user_id=USER_ID,\n",
123+
" session_id=SESSION_ID\n",
124+
" )\n",
125+
" \n",
126+
" # Run the agent\n",
127+
" query = \"What is the capital of France?\"\n",
128+
" content = types.Content(role='user', parts=[types.Part(text=query)])\n",
129+
" \n",
130+
" # Process events and get response\n",
131+
" async for event in runner.run_async(user_id=USER_ID, session_id=SESSION_ID, new_message=content):\n",
132+
" if event.is_final_response() and event.content:\n",
133+
" final_answer = event.content.parts[0].text.strip()\n",
134+
"\n",
135+
"# Run the async function\n",
136+
"await run_basic_agent()"
137+
]
138+
},
139+
{
140+
"cell_type": "markdown",
141+
"metadata": {},
142+
"source": [
143+
"## Example 2: Agent with Tools/Functions\n",
144+
"\n",
145+
"Create an agent with custom tools that can be called during execution:\n"
146+
]
147+
},
148+
{
149+
"cell_type": "code",
150+
"execution_count": null,
151+
"metadata": {},
152+
"outputs": [],
153+
"source": [
154+
"import os\n",
155+
"\n",
156+
"\n",
157+
"# Define custom tools as regular Python functions\n",
158+
"def get_weather(city: str) -> str:\n",
159+
" \"\"\"Retrieves the current weather report for a specified city.\n",
160+
" \n",
161+
" Args:\n",
162+
" city: The name of the city for which to retrieve the weather report.\n",
163+
" \n",
164+
" Returns:\n",
165+
" str: Weather report or error message.\n",
166+
" \"\"\"\n",
167+
" if city.lower() == \"san francisco\":\n",
168+
" return \"The weather in San Francisco is sunny with a temperature of 72°F (22°C).\"\n",
169+
" else:\n",
170+
" return f\"Sorry, weather information for '{city}' is not available.\"\n",
171+
"\n",
172+
"def calculate(expression: str) -> str:\n",
173+
" \"\"\"Evaluates a mathematical expression.\n",
174+
" \n",
175+
" Args:\n",
176+
" expression: A mathematical expression to evaluate.\n",
177+
" \n",
178+
" Returns:\n",
179+
" str: Calculation result or error message.\n",
180+
" \"\"\"\n",
181+
" try:\n",
182+
" result = eval(expression)\n",
183+
" return f\"The result is {result}\"\n",
184+
" except Exception as e:\n",
185+
" return f\"Error: {str(e)}\"\n",
186+
"\n",
187+
"# Use different session IDs for tool agent\n",
188+
"TOOL_USER_ID = \"user_456\"\n",
189+
"TOOL_SESSION_ID = \"session_456\"\n",
190+
"\n",
191+
"# Create agent with tools (pass functions directly)\n",
192+
"tool_agent = LlmAgent(\n",
193+
" model=\"gemini-2.0-flash-exp\",\n",
194+
" name=\"ToolAgent\",\n",
195+
" instruction=\"You are a helpful assistant with access to weather and calculation tools. Use them when appropriate.\",\n",
196+
" tools=[get_weather, calculate]\n",
197+
")\n",
198+
"\n",
199+
"# Create runner for tool agent (reuse the session_service)\n",
200+
"tool_runner = Runner(\n",
201+
" agent=tool_agent,\n",
202+
" app_name=APP_NAME,\n",
203+
" session_service=session_service\n",
204+
")\n",
205+
"\n",
206+
"# Define async function to run the tool agent\n",
207+
"async def run_tool_agent():\n",
208+
" # Create session\n",
209+
" await session_service.create_session(\n",
210+
" app_name=APP_NAME,\n",
211+
" user_id=TOOL_USER_ID,\n",
212+
" session_id=TOOL_SESSION_ID\n",
213+
" )\n",
214+
" \n",
215+
" # Run the agent with a query that requires tool use\n",
216+
" query = \"What's the weather in San Francisco? Also, what is 15 * 24?\"\n",
217+
" content = types.Content(role='user', parts=[types.Part(text=query)])\n",
218+
" \n",
219+
" # Process events and get response\n",
220+
" async for event in tool_runner.run_async(\n",
221+
" user_id=TOOL_USER_ID,\n",
222+
" session_id=TOOL_SESSION_ID,\n",
223+
" new_message=content\n",
224+
" ):\n",
225+
" if event.is_final_response() and event.content:\n",
226+
" final_answer = event.content.parts[0].text.strip()\n",
227+
"\n",
228+
"# Run the async function\n",
229+
"await run_tool_agent()\n"
230+
]
231+
},
232+
{
233+
"cell_type": "markdown",
234+
"metadata": {},
235+
"source": [
236+
"## View Traces in Openlayer\n",
237+
"\n",
238+
"After running these examples, you can view the traces in your Openlayer dashboard:\n",
239+
"\n",
240+
"1. Go to https://app.openlayer.com\n",
241+
"2. Navigate to your inference pipeline\n",
242+
"3. View the traces tab to see:\n",
243+
" - Agent execution steps\n",
244+
" - LLM calls with token counts\n",
245+
" - Tool executions with inputs and outputs\n",
246+
" - Latency for each operation\n",
247+
" - Complete execution hierarchy\n"
248+
]
249+
},
250+
{
251+
"cell_type": "markdown",
252+
"metadata": {},
253+
"source": [
254+
"## Disable Tracing\n",
255+
"\n",
256+
"When you're done, you can disable tracing to restore ADK's default behavior:\n"
257+
]
258+
},
259+
{
260+
"cell_type": "code",
261+
"execution_count": null,
262+
"metadata": {},
263+
"outputs": [],
264+
"source": [
265+
"from openlayer.lib.integrations import unpatch_google_adk\n",
266+
"\n",
267+
"# Disable tracing\n",
268+
"unpatch_google_adk()"
269+
]
270+
}
271+
],
272+
"metadata": {
273+
"kernelspec": {
274+
"display_name": ".venv",
275+
"language": "python",
276+
"name": "python3"
277+
},
278+
"language_info": {
279+
"codemirror_mode": {
280+
"name": "ipython",
281+
"version": 3
282+
},
283+
"file_extension": ".py",
284+
"mimetype": "text/x-python",
285+
"name": "python",
286+
"nbconvert_exporter": "python",
287+
"pygments_lexer": "ipython3",
288+
"version": "3.9.18"
289+
}
290+
},
291+
"nbformat": 4,
292+
"nbformat_minor": 2
293+
}

0 commit comments

Comments
 (0)