Skip to content

added imports to run Agent-SDK with Gemini API #12

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
156 changes: 79 additions & 77 deletions 00_openai_agents/01_hello_agent/hello_agent.ipynb
Original file line number Diff line number Diff line change
@@ -1,72 +1,65 @@
{
"nbformat": 4,
"nbformat_minor": 0,
"metadata": {
"colab": {
"provenance": []
},
"kernelspec": {
"name": "python3",
"display_name": "Python 3"
},
"language_info": {
"name": "python"
}
},
"cells": [
{
"cell_type": "markdown",
"source": [
"# Install openai-agents SDK"
],
"metadata": {
"id": "PdKwzEluDBN7"
}
},
"source": [
"# Install openai-agents SDK"
]
},
{
"cell_type": "code",
"source": [
"!pip install -Uq openai-agents"
],
"execution_count": 4,
"metadata": {
"id": "3QdkOviEB2ay"
},
"execution_count": 4,
"outputs": []
"outputs": [],
"source": [
"!pip install -Uq openai-agents"
]
},
{
"cell_type": "markdown",
"source": [
"# Make your Jupyter Notebook capable of running asynchronous functions."
],
"metadata": {
"id": "7yD91lz4DIAx"
}
},
"source": [
"# Make your Jupyter Notebook capable of running asynchronous functions."
]
},
{
"cell_type": "code",
"source": [
"import nest_asyncio\n",
"nest_asyncio.apply()"
],
"execution_count": 6,
"metadata": {
"id": "7A5YLi3HCfBV"
},
"execution_count": 6,
"outputs": []
"outputs": [],
"source": [
"import nest_asyncio\n",
"nest_asyncio.apply()"
]
},
{
"cell_type": "markdown",
"source": [
"# Run Google Gemini with OPENAI-Agent SDK"
],
"metadata": {
"id": "K3VTUWDaGFcV"
}
},
"source": [
"# Run Google Gemini with OPENAI-Agent SDK"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "QSIWS6RvC-a4"
},
"outputs": [],
"source": [
"from google.colab import userdata \n",
"from agents import AsyncOpenAI, OpenAIChatCompletionsModel, RunConfig # imports from agents-sdk required to run below code \n",
"gemini_api_key = userdata.get(\"GEMINI_API_KEY\")\n",
"\n",
"\n",
Expand All @@ -90,23 +83,18 @@
" model_provider=external_client,\n",
" tracing_disabled=True\n",
")"
],
"metadata": {
"id": "QSIWS6RvC-a4"
},
"execution_count": null,
"outputs": []
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "eTyY2o8yHqZ_"
},
"source": [
"# Hello world code | method one\n",
"\n",
"\n"
],
"metadata": {
"id": "eTyY2o8yHqZ_"
}
]
},
{
"cell_type": "code",
Expand All @@ -120,8 +108,8 @@
},
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
"CALLING AGENT\n",
Expand Down Expand Up @@ -152,15 +140,35 @@
},
{
"cell_type": "markdown",
"source": [
"# Hello world code | method two\n"
],
"metadata": {
"id": "p_x578x2JC0c"
}
},
"source": [
"# Hello world code | method two\n"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "xdkrSYWrH4CE",
"outputId": "e2a2f181-6a2a-4410-882d-cd0bd0cb4584"
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Function calls self,\n",
"Repeating until it stops,\n",
"Base case breaks the loop.\n",
"\n"
]
}
],
"source": [
"import asyncio\n",
"\n",
Expand All @@ -182,36 +190,30 @@
"\n",
"if __name__ == \"__main__\":\n",
" asyncio.run(main())"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "xdkrSYWrH4CE",
"outputId": "e2a2f181-6a2a-4410-882d-cd0bd0cb4584"
},
"execution_count": 10,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"Function calls self,\n",
"Repeating until it stops,\n",
"Base case breaks the loop.\n",
"\n"
]
}
]
},
{
"cell_type": "code",
"source": [],
"execution_count": null,
"metadata": {
"id": "pTNf1noxCRi-"
},
"execution_count": null,
"outputs": []
"outputs": [],
"source": []
}
],
"metadata": {
"colab": {
"provenance": []
},
"kernelspec": {
"display_name": "Python 3",
"name": "python3"
},
"language_info": {
"name": "python"
}
]
}
},
"nbformat": 4,
"nbformat_minor": 0
}