Skip to content

Commit

Permalink
clear outputs
Browse files Browse the repository at this point in the history
  • Loading branch information
siyangqiu committed Aug 13, 2024
1 parent 758df79 commit 4202f25
Showing 1 changed file with 17 additions and 134 deletions.
151 changes: 17 additions & 134 deletions examples/openai-gpt.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -21,54 +21,10 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": null,
"id": "88c8f60d",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Requirement already satisfied: openai in /home/siyangqiu/DevDrive/pythonsdk/env/lib/python3.12/site-packages (1.40.6)\n",
"Requirement already satisfied: anyio<5,>=3.5.0 in /home/siyangqiu/DevDrive/pythonsdk/env/lib/python3.12/site-packages (from openai) (4.4.0)\n",
"Requirement already satisfied: distro<2,>=1.7.0 in /home/siyangqiu/DevDrive/pythonsdk/env/lib/python3.12/site-packages (from openai) (1.9.0)\n",
"Requirement already satisfied: httpx<1,>=0.23.0 in /home/siyangqiu/DevDrive/pythonsdk/env/lib/python3.12/site-packages (from openai) (0.27.0)\n",
"Requirement already satisfied: jiter<1,>=0.4.0 in /home/siyangqiu/DevDrive/pythonsdk/env/lib/python3.12/site-packages (from openai) (0.4.2)\n",
"Requirement already satisfied: pydantic<3,>=1.9.0 in /home/siyangqiu/DevDrive/pythonsdk/env/lib/python3.12/site-packages (from openai) (2.8.2)\n",
"Requirement already satisfied: sniffio in /home/siyangqiu/DevDrive/pythonsdk/env/lib/python3.12/site-packages (from openai) (1.3.1)\n",
"Requirement already satisfied: tqdm>4 in /home/siyangqiu/DevDrive/pythonsdk/env/lib/python3.12/site-packages (from openai) (4.66.5)\n",
"Requirement already satisfied: typing-extensions<5,>=4.11 in /home/siyangqiu/DevDrive/pythonsdk/env/lib/python3.12/site-packages (from openai) (4.12.2)\n",
"Requirement already satisfied: idna>=2.8 in /home/siyangqiu/DevDrive/pythonsdk/env/lib/python3.12/site-packages (from anyio<5,>=3.5.0->openai) (3.7)\n",
"Requirement already satisfied: certifi in /home/siyangqiu/DevDrive/pythonsdk/env/lib/python3.12/site-packages (from httpx<1,>=0.23.0->openai) (2024.7.4)\n",
"Requirement already satisfied: httpcore==1.* in /home/siyangqiu/DevDrive/pythonsdk/env/lib/python3.12/site-packages (from httpx<1,>=0.23.0->openai) (1.0.5)\n",
"Requirement already satisfied: h11<0.15,>=0.13 in /home/siyangqiu/DevDrive/pythonsdk/env/lib/python3.12/site-packages (from httpcore==1.*->httpx<1,>=0.23.0->openai) (0.14.0)\n",
"Requirement already satisfied: annotated-types>=0.4.0 in /home/siyangqiu/DevDrive/pythonsdk/env/lib/python3.12/site-packages (from pydantic<3,>=1.9.0->openai) (0.7.0)\n",
"Requirement already satisfied: pydantic-core==2.20.1 in /home/siyangqiu/DevDrive/pythonsdk/env/lib/python3.12/site-packages (from pydantic<3,>=1.9.0->openai) (2.20.1)\n",
"\n",
"\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m A new release of pip is available: \u001b[0m\u001b[31;49m24.0\u001b[0m\u001b[39;49m -> \u001b[0m\u001b[32;49m24.2\u001b[0m\n",
"\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m To update, run: \u001b[0m\u001b[32;49mpip install --upgrade pip\u001b[0m\n",
"Note: you may need to restart the kernel to use updated packages.\n",
"Requirement already satisfied: agentops in /home/siyangqiu/DevDrive/pythonsdk/env/lib/python3.12/site-packages (0.3.7)\n",
"Requirement already satisfied: requests==2.31.0 in /home/siyangqiu/DevDrive/pythonsdk/env/lib/python3.12/site-packages (from agentops) (2.31.0)\n",
"Requirement already satisfied: psutil==5.9.8 in /home/siyangqiu/DevDrive/pythonsdk/env/lib/python3.12/site-packages (from agentops) (5.9.8)\n",
"Requirement already satisfied: packaging==23.2 in /home/siyangqiu/DevDrive/pythonsdk/env/lib/python3.12/site-packages (from agentops) (23.2)\n",
"Requirement already satisfied: termcolor==2.4.0 in /home/siyangqiu/DevDrive/pythonsdk/env/lib/python3.12/site-packages (from agentops) (2.4.0)\n",
"Requirement already satisfied: charset-normalizer<4,>=2 in /home/siyangqiu/DevDrive/pythonsdk/env/lib/python3.12/site-packages (from requests==2.31.0->agentops) (3.3.2)\n",
"Requirement already satisfied: idna<4,>=2.5 in /home/siyangqiu/DevDrive/pythonsdk/env/lib/python3.12/site-packages (from requests==2.31.0->agentops) (3.7)\n",
"Requirement already satisfied: urllib3<3,>=1.21.1 in /home/siyangqiu/DevDrive/pythonsdk/env/lib/python3.12/site-packages (from requests==2.31.0->agentops) (2.2.2)\n",
"Requirement already satisfied: certifi>=2017.4.17 in /home/siyangqiu/DevDrive/pythonsdk/env/lib/python3.12/site-packages (from requests==2.31.0->agentops) (2024.7.4)\n",
"\n",
"\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m A new release of pip is available: \u001b[0m\u001b[31;49m24.0\u001b[0m\u001b[39;49m -> \u001b[0m\u001b[32;49m24.2\u001b[0m\n",
"\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m To update, run: \u001b[0m\u001b[32;49mpip install --upgrade pip\u001b[0m\n",
"Note: you may need to restart the kernel to use updated packages.\n",
"Requirement already satisfied: python-dotenv in /home/siyangqiu/DevDrive/pythonsdk/env/lib/python3.12/site-packages (1.0.1)\n",
"\n",
"\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m A new release of pip is available: \u001b[0m\u001b[31;49m24.0\u001b[0m\u001b[39;49m -> \u001b[0m\u001b[32;49m24.2\u001b[0m\n",
"\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m To update, run: \u001b[0m\u001b[32;49mpip install --upgrade pip\u001b[0m\n",
"Note: you may need to restart the kernel to use updated packages.\n"
]
}
],
"outputs": [],
"source": [
"%pip install -U openai\n",
"%pip install -U agentops\n",
Expand All @@ -85,7 +41,7 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": null,
"id": "c51dcbda80eb8c53",
"metadata": {
"collapsed": false
Expand All @@ -110,7 +66,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": null,
"id": "cbc5d13679e269dc",
"metadata": {
"collapsed": false
Expand All @@ -134,30 +90,12 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": null,
"id": "5d424a02e30ce7f4",
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"🖇 AgentOps: \u001b[34m\u001b[34mSession Replay: https://app.agentops.ai/drilldown?session_id=037c5380-e7f2-4ab7-b85b-54b714416fc8\u001b[0m\u001b[0m\n"
]
},
{
"data": {
"text/plain": [
"<agentops.session.Session at 0x7f341784db20>"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"openai = OpenAI(api_key=OPENAI_API_KEY)\n",
"agentops.init(AGENTOPS_API_KEY, default_tags=[\"openai-gpt-notebook\"])"
Expand Down Expand Up @@ -185,20 +123,12 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": null,
"id": "2704d6d625efa77f",
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"ChatCompletion(id='chatcmpl-9vfc9uAbQf2b4gkBLF8r2S1hemHff', choices=[Choice(finish_reason='stop', index=0, logprobs=None, message=ChatCompletionMessage(content='Silent shadows move, unseen, on covert missions of intrigue and espionage.', refusal=None, role='assistant', function_call=None, tool_calls=None))], created=1723531689, model='gpt-3.5-turbo-0125', object='chat.completion', service_tier=None, system_fingerprint=None, usage=CompletionUsage(completion_tokens=15, prompt_tokens=17, total_tokens=32))\n"
]
}
],
"outputs": [],
"source": [
"message = [{\"role\": \"user\", \"content\": \"Write a 12 word poem about secret agents.\"}]\n",
"res = openai.chat.completions.create(\n",
Expand All @@ -219,21 +149,12 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": null,
"id": "537abd77cd0e0d25",
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"🖇 AgentOps: This run's cost $0.000031\n",
"🖇 AgentOps: \u001b[34m\u001b[34mSession Replay: https://app.agentops.ai/drilldown?session_id=037c5380-e7f2-4ab7-b85b-54b714416fc8\u001b[0m\u001b[0m\n"
]
}
],
"outputs": [],
"source": [
"agentops.end_session(\"Success\")"
]
Expand Down Expand Up @@ -262,30 +183,12 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": null,
"id": "544c8f1bdb8c6e4b",
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"🖇 AgentOps: \u001b[34m\u001b[34mSession Replay: https://app.agentops.ai/drilldown?session_id=ed47e38d-39c7-498e-bccf-e4b5280c983d\u001b[0m\u001b[0m\n"
]
},
{
"data": {
"text/plain": [
"<agentops.session.Session at 0x7f3417633fe0>"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"# Create new session\n",
"agentops.start_session(tags=[\"openai-gpt-notebook-events\"])"
Expand All @@ -301,23 +204,12 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": null,
"id": "b45754a57148eed1",
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"6"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"from agentops import record_action\n",
"\n",
Expand All @@ -340,7 +232,7 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": null,
"id": "2ac84c35",
"metadata": {},
"outputs": [],
Expand All @@ -364,21 +256,12 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": null,
"id": "4ca2b49fc06adddb",
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"🖇 AgentOps: This run's cost $0.000017\n",
"🖇 AgentOps: \u001b[34m\u001b[34mSession Replay: https://app.agentops.ai/drilldown?session_id=ed47e38d-39c7-498e-bccf-e4b5280c983d\u001b[0m\u001b[0m\n"
]
}
],
"outputs": [],
"source": [
"agentops.end_session(\"Success\")"
]
Expand Down

0 comments on commit 4202f25

Please sign in to comment.