Skip to content

Commit 392677a

Browse files
committed
rename and clean gemini example notebook
1 parent 3384b2d commit 392677a

File tree

1 file changed

+32
-37
lines changed

1 file changed

+32
-37
lines changed

examples/gemini_examples/gemini_example_sync.ipynb renamed to examples/gemini_examples/gemini_example.ipynb

Lines changed: 32 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -19,28 +19,23 @@
1919
"source": [
2020
"import google.generativeai as genai\n",
2121
"import agentops\n",
22-
"from agentops.llms.providers.gemini import GeminiProvider"
22+
"from dotenv import load_dotenv\n",
23+
"import os"
2324
]
2425
},
2526
{
2627
"cell_type": "code",
27-
"execution_count": null,
28+
"execution_count": 2,
2829
"id": "a94545c9",
2930
"metadata": {},
3031
"outputs": [],
3132
"source": [
32-
"# Configure the Gemini API\n",
33-
"import os\n",
33+
"load_dotenv()\n",
3434
"\n",
35-
"# Replace with your API key\n",
36-
"# You can get one at: https://ai.google.dev/tutorials/setup\n",
37-
"GEMINI_API_KEY = \"YOUR_API_KEY_HERE\" # Replace with your API key\n",
38-
"genai.configure(api_key=GEMINI_API_KEY)\n",
35+
"GEMINI_API_KEY = os.getenv(\"GEMINI_API_KEY\") or \"your gemini api key\"\n",
36+
"AGENTOPS_API_KEY = os.getenv(\"AGENTOPS_API_KEY\") or \"your agentops api key\"\n",
3937
"\n",
40-
"# Note: In production, use environment variables:\n",
41-
"# import os\n",
42-
"# GEMINI_API_KEY = os.getenv(\"GEMINI_API_KEY\")\n",
43-
"# genai.configure(api_key=GEMINI_API_KEY)"
38+
"genai.configure(api_key=GEMINI_API_KEY)"
4439
]
4540
},
4641
{
@@ -51,12 +46,8 @@
5146
"outputs": [],
5247
"source": [
5348
"# Initialize AgentOps and Gemini model\n",
54-
"ao_client = agentops.init()\n",
55-
"model = genai.GenerativeModel(\"gemini-1.5-flash\")\n",
56-
"\n",
57-
"# Initialize and override Gemini provider\n",
58-
"provider = GeminiProvider(model)\n",
59-
"provider.override()"
49+
"agentops.init()\n",
50+
"model = genai.GenerativeModel(\"gemini-1.5-flash\")"
6051
]
6152
},
6253
{
@@ -70,7 +61,7 @@
7061
"print(\"Testing synchronous generation:\")\n",
7162
"response = model.generate_content(\n",
7263
" \"What are the three laws of robotics?\",\n",
73-
" session=ao_client\n",
64+
" # session=ao_client\n",
7465
")\n",
7566
"print(response.text)"
7667
]
@@ -87,7 +78,7 @@
8778
"response = model.generate_content(\n",
8879
" \"Explain the concept of machine learning in simple terms.\",\n",
8980
" stream=True,\n",
90-
" session=ao_client\n",
81+
" # session=ao_client\n",
9182
")\n",
9283
"\n",
9384
"for chunk in response:\n",
@@ -98,7 +89,7 @@
9889
"print(\"\\nTesting another synchronous generation:\")\n",
9990
"response = model.generate_content(\n",
10091
" \"What is the difference between supervised and unsupervised learning?\",\n",
101-
" session=ao_client\n",
92+
" # session=ao_client\n",
10293
")\n",
10394
"print(response.text)"
10495
]
@@ -111,25 +102,29 @@
111102
"outputs": [],
112103
"source": [
113104
"# End session and check stats\n",
114-
"agentops.end_session(\n",
115-
" end_state=\"Success\",\n",
116-
" end_state_reason=\"Gemini integration example completed successfully\"\n",
117-
")"
118-
]
119-
},
120-
{
121-
"cell_type": "code",
122-
"execution_count": null,
123-
"id": "b6d35f28",
124-
"metadata": {},
125-
"outputs": [],
126-
"source": [
127-
"# Clean up\n",
128-
"provider.undo_override()"
105+
"agentops.end_session(end_state=\"Success\")"
129106
]
130107
}
131108
],
132-
"metadata": {},
109+
"metadata": {
110+
"kernelspec": {
111+
"display_name": "ops",
112+
"language": "python",
113+
"name": "python3"
114+
},
115+
"language_info": {
116+
"codemirror_mode": {
117+
"name": "ipython",
118+
"version": 3
119+
},
120+
"file_extension": ".py",
121+
"mimetype": "text/x-python",
122+
"name": "python",
123+
"nbconvert_exporter": "python",
124+
"pygments_lexer": "ipython3",
125+
"version": "3.10.16"
126+
}
127+
},
133128
"nbformat": 4,
134129
"nbformat_minor": 5
135130
}

0 commit comments

Comments
 (0)