Skip to content

Commit

Permalink
clean
Browse files Browse the repository at this point in the history
  • Loading branch information
hozen-groq committed Sep 7, 2024
1 parent 7caf0fa commit 8792319
Showing 1 changed file with 11 additions and 112 deletions.
123 changes: 11 additions & 112 deletions tutorials/parallel-tool-use/parallel-tool-use.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -59,44 +59,10 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": null,
"id": "962ae5e2",
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"23.03s - pydevd: Sending message related to process being replaced timed-out after 5 seconds\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Requirement already satisfied: groq in /opt/homebrew/lib/python3.10/site-packages (from -r requirements.txt (line 1)) (0.9.0)\n",
"Collecting python-dotenv (from -r requirements.txt (line 2))\n",
" Using cached python_dotenv-1.0.1-py3-none-any.whl.metadata (23 kB)\n",
"Requirement already satisfied: anyio<5,>=3.5.0 in /opt/homebrew/lib/python3.10/site-packages (from groq->-r requirements.txt (line 1)) (4.4.0)\n",
"Requirement already satisfied: distro<2,>=1.7.0 in /opt/homebrew/lib/python3.10/site-packages (from groq->-r requirements.txt (line 1)) (1.9.0)\n",
"Requirement already satisfied: httpx<1,>=0.23.0 in /opt/homebrew/lib/python3.10/site-packages (from groq->-r requirements.txt (line 1)) (0.27.0)\n",
"Requirement already satisfied: pydantic<3,>=1.9.0 in /opt/homebrew/lib/python3.10/site-packages (from groq->-r requirements.txt (line 1)) (2.8.2)\n",
"Requirement already satisfied: sniffio in /opt/homebrew/lib/python3.10/site-packages (from groq->-r requirements.txt (line 1)) (1.3.1)\n",
"Requirement already satisfied: typing-extensions<5,>=4.7 in /Users/hozen/Library/Python/3.10/lib/python/site-packages (from groq->-r requirements.txt (line 1)) (4.12.2)\n",
"Requirement already satisfied: idna>=2.8 in /opt/homebrew/lib/python3.10/site-packages (from anyio<5,>=3.5.0->groq->-r requirements.txt (line 1)) (3.7)\n",
"Requirement already satisfied: exceptiongroup>=1.0.2 in /Users/hozen/Library/Python/3.10/lib/python/site-packages (from anyio<5,>=3.5.0->groq->-r requirements.txt (line 1)) (1.2.2)\n",
"Requirement already satisfied: certifi in /opt/homebrew/lib/python3.10/site-packages (from httpx<1,>=0.23.0->groq->-r requirements.txt (line 1)) (2024.7.4)\n",
"Requirement already satisfied: httpcore==1.* in /opt/homebrew/lib/python3.10/site-packages (from httpx<1,>=0.23.0->groq->-r requirements.txt (line 1)) (1.0.5)\n",
"Requirement already satisfied: h11<0.15,>=0.13 in /opt/homebrew/lib/python3.10/site-packages (from httpcore==1.*->httpx<1,>=0.23.0->groq->-r requirements.txt (line 1)) (0.14.0)\n",
"Requirement already satisfied: annotated-types>=0.4.0 in /opt/homebrew/lib/python3.10/site-packages (from pydantic<3,>=1.9.0->groq->-r requirements.txt (line 1)) (0.7.0)\n",
"Requirement already satisfied: pydantic-core==2.20.1 in /opt/homebrew/lib/python3.10/site-packages (from pydantic<3,>=1.9.0->groq->-r requirements.txt (line 1)) (2.20.1)\n",
"Using cached python_dotenv-1.0.1-py3-none-any.whl (19 kB)\n",
"Installing collected packages: python-dotenv\n",
"Successfully installed python-dotenv-1.0.1\n",
"Note: you may need to restart the kernel to use updated packages.\n"
]
}
],
"outputs": [],
"source": [
"%pip install -r requirements.txt"
]
Expand All @@ -119,21 +85,10 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": null,
"id": "e21816b3",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'Groq API key configured: gsk_EVTAuh...'"
]
},
"execution_count": 1,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"import os\n",
"import json\n",
Expand All @@ -155,7 +110,7 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": null,
"id": "0cca781b-1950-4167-b36a-c1099d6b3b00",
"metadata": {},
"outputs": [],
Expand All @@ -174,7 +129,7 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": null,
"id": "f2ce18dc",
"metadata": {},
"outputs": [],
Expand All @@ -200,7 +155,7 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": null,
"id": "6b454910-4352-40cc-b9b2-cc79edabd7c1",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -262,58 +217,10 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": null,
"id": "fe623ab9",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[\n",
" {\n",
" \"role\": \"system\",\n",
" \"content\": \"You are a helpful assistant.\"\n",
" },\n",
" {\n",
" \"role\": \"user\",\n",
" \"content\": \"What is the price for a cappuccino and croissant?\"\n",
" },\n",
" {\n",
" \"role\": \"assistant\",\n",
" \"tool_calls\": [\n",
" {\n",
" \"id\": \"call_07bz\",\n",
" \"function\": {\n",
" \"name\": \"get_bakery_prices\",\n",
" \"arguments\": \"{\\\"bakery_item\\\": \\\"cappuccino\\\"}\"\n",
" },\n",
" \"type\": \"function\"\n",
" },\n",
" {\n",
" \"id\": \"call_h9pz\",\n",
" \"function\": {\n",
" \"name\": \"get_bakery_prices\",\n",
" \"arguments\": \"{\\\"bakery_item\\\": \\\"croissant\\\"}\"\n",
" },\n",
" \"type\": \"function\"\n",
" }\n",
" ]\n",
" },\n",
" {\n",
" \"role\": \"tool\",\n",
" \"content\": \"4.75\",\n",
" \"tool_call_id\": \"call_07bz\"\n",
" },\n",
" {\n",
" \"role\": \"tool\",\n",
" \"content\": \"4.25\",\n",
" \"tool_call_id\": \"call_h9pz\"\n",
" }\n",
"]\n"
]
}
],
"outputs": [],
"source": [
"tool_calls = response_message.tool_calls\n",
"\n",
Expand Down Expand Up @@ -368,18 +275,10 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": null,
"id": "5f077df3",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"The price for a cappuccino is $4.75 and for a croissant, it is $4.25.\n"
]
}
],
"outputs": [],
"source": [
"response = client.chat.completions.create(\n",
" model=model, messages=messages, tools=tools, tool_choice=\"auto\", max_tokens=4096\n",
Expand Down

0 comments on commit 8792319

Please sign in to comment.