Fix function call notebook to make sure title is displayed. (#2403)

* Fix function call notebook to make sure title is displayed.

* Fix formatting

* formatting
This commit is contained in:
Eric Zhu 2024-04-17 07:02:10 -07:00 committed by GitHub
parent c4e570393d
commit 3c266c5c01
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 42 additions and 46 deletions

View File

@ -1,20 +1,5 @@
{
"cells": [
{
"attachments": {},
"cell_type": "markdown",
"id": "ae1f50ec",
"metadata": {
"editable": true,
"slideshow": {
"slide_type": ""
},
"tags": []
},
"source": [
"<a href=\"https://colab.research.google.com/github/microsoft/autogen/blob/main/notebook/agentchat_function_call_currency_calculator.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
]
},
{
"attachments": {},
"cell_type": "markdown",
@ -32,11 +17,18 @@
"The default way of creating code in Autogen is its built-in code extractor. Although it allows for creating and executing simple scripts fast, that way of creating code is not suitable for developing advanced software applications, according to my experiences. The process of developing an application is mostly the process of introducing changes into existing files rather than creating new files with code. And in my experience, the code extractor is bad at introducing changes as the model often gets lost and can damage existing files.\n",
"\n",
"Properly created functions that can modify code provide us with the ability to have more control over code changes and result in better quality. Additionally, as the scope of possible operations is predefined inside the tools, we can safely use Autogen without Docker, avoiding all the complications related to it.\n",
"## Requirements\n",
"\n",
"```bash\n",
"pip install pyautogen\n",
"```"
"## Requirements"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "c528cd6d",
"metadata": {},
"outputs": [],
"source": [
"! pip install pyautogen"
]
},
{
@ -51,9 +43,7 @@
"tags": []
},
"source": [
"## Set your API Endpoint\n",
"\n",
"The [`config_list_from_json`](https://microsoft.github.io/autogen/docs/reference/oai/openai_utils#config_list_from_json) function loads a list of configurations from an environment variable or a json file."
"## Set your API Endpoint"
]
},
{
@ -73,7 +63,7 @@
"\n",
"import autogen\n",
"\n",
"config_list = [{\"model\": \"gpt-4-turbo-preview\", \"api_key\": os.getenv(\"OPENAI_API_KEY\")}, ...]"
"config_list = [{\"model\": \"gpt-4-turbo-preview\", \"api_key\": os.getenv(\"OPENAI_API_KEY\")}]"
]
},
{
@ -224,7 +214,7 @@
"id": "370a9f8d-d5ce-4127-8646-cf0e4effd9f5",
"metadata": {},
"source": [
"```\n",
"```python\n",
"# backend_dir/main.py\n",
"\n",
"from fastapi import FastAPI\n",
@ -247,9 +237,11 @@
"metadata": {},
"source": [
"Install needed libraries. We can run our API using:\n",
"```\n",
"\n",
"```bash\n",
"uvicorn main:app --reload\n",
"```\n",
"\n",
"Send a request to 'localhost:8000/cdr_daily_spread' to check if it works.\n",
"\n",
"## Edit code using agents\n",
@ -292,7 +284,7 @@
]
},
{
"name": "stdin",
"name": "stdout",
"output_type": "stream",
"text": [
"Provide feedback to chat_manager. Press enter to skip and use auto-reply, or type 'exit' to end the conversation: \n"
@ -331,7 +323,7 @@
]
},
{
"name": "stdin",
"name": "stdout",
"output_type": "stream",
"text": [
"Provide feedback to chat_manager. Press enter to skip and use auto-reply, or type 'exit' to end the conversation: \n"
@ -364,7 +356,7 @@
]
},
{
"name": "stdin",
"name": "stdout",
"output_type": "stream",
"text": [
"Provide feedback to chat_manager. Press enter to skip and use auto-reply, or type 'exit' to end the conversation: Let's move spread calculation logic to separate file. Create spread_calculation function with ticker argument in it. in our endpoint, we need to compare daily spread for CD Project Red and 11bits Studio - return difference between them. Start with providing plan of changes. Don't do any changes yet.\n"
@ -395,7 +387,7 @@
]
},
{
"name": "stdin",
"name": "stdout",
"output_type": "stream",
"text": [
"Provide feedback to chat_manager. Press enter to skip and use auto-reply, or type 'exit' to end the conversation: go with the plan\n"
@ -425,7 +417,7 @@
]
},
{
"name": "stdin",
"name": "stdout",
"output_type": "stream",
"text": [
"Provide feedback to chat_manager. Press enter to skip and use auto-reply, or type 'exit' to end the conversation: \n"
@ -467,7 +459,7 @@
]
},
{
"name": "stdin",
"name": "stdout",
"output_type": "stream",
"text": [
"Provide feedback to chat_manager. Press enter to skip and use auto-reply, or type 'exit' to end the conversation: Do not change whole the file. concentrate on the concrete lines.\n"
@ -506,7 +498,7 @@
]
},
{
"name": "stdin",
"name": "stdout",
"output_type": "stream",
"text": [
"Provide feedback to chat_manager. Press enter to skip and use auto-reply, or type 'exit' to end the conversation: \n"
@ -548,7 +540,7 @@
]
},
{
"name": "stdin",
"name": "stdout",
"output_type": "stream",
"text": [
"Provide feedback to chat_manager. Press enter to skip and use auto-reply, or type 'exit' to end the conversation: Check out file first to get actual lines position. Also, change endpoint name.\n"
@ -584,7 +576,7 @@
]
},
{
"name": "stdin",
"name": "stdout",
"output_type": "stream",
"text": [
"Provide feedback to chat_manager. Press enter to skip and use auto-reply, or type 'exit' to end the conversation: \n"
@ -626,7 +618,7 @@
]
},
{
"name": "stdin",
"name": "stdout",
"output_type": "stream",
"text": [
"Provide feedback to chat_manager. Press enter to skip and use auto-reply, or type 'exit' to end the conversation: \n"
@ -659,7 +651,7 @@
]
},
{
"name": "stdin",
"name": "stdout",
"output_type": "stream",
"text": [
"Provide feedback to chat_manager. Press enter to skip and use auto-reply, or type 'exit' to end the conversation: Good. But add in return some addition description to be understandable which stock change is bigger. Remember to check out main.py first to actualize your knowledge.\n"
@ -688,7 +680,7 @@
]
},
{
"name": "stdin",
"name": "stdout",
"output_type": "stream",
"text": [
"Provide feedback to chat_manager. Press enter to skip and use auto-reply, or type 'exit' to end the conversation: \n"
@ -730,7 +722,7 @@
]
},
{
"name": "stdin",
"name": "stdout",
"output_type": "stream",
"text": [
"Provide feedback to chat_manager. Press enter to skip and use auto-reply, or type 'exit' to end the conversation: \n"
@ -763,7 +755,7 @@
]
},
{
"name": "stdin",
"name": "stdout",
"output_type": "stream",
"text": [
"Provide feedback to chat_manager. Press enter to skip and use auto-reply, or type 'exit' to end the conversation: ValueError: The truth value of a Series is ambiguous.\n"
@ -795,7 +787,7 @@
]
},
{
"name": "stdin",
"name": "stdout",
"output_type": "stream",
"text": [
"Provide feedback to chat_manager. Press enter to skip and use auto-reply, or type 'exit' to end the conversation: Cool. Remember to check out file before introducing modifications.\n"
@ -824,7 +816,7 @@
]
},
{
"name": "stdin",
"name": "stdout",
"output_type": "stream",
"text": [
"Provide feedback to chat_manager. Press enter to skip and use auto-reply, or type 'exit' to end the conversation: \n"
@ -866,7 +858,7 @@
]
},
{
"name": "stdin",
"name": "stdout",
"output_type": "stream",
"text": [
"Provide feedback to chat_manager. Press enter to skip and use auto-reply, or type 'exit' to end the conversation: \n"
@ -899,7 +891,7 @@
]
},
{
"name": "stdin",
"name": "stdout",
"output_type": "stream",
"text": [
"Provide feedback to chat_manager. Press enter to skip and use auto-reply, or type 'exit' to end the conversation: exit\n"
@ -930,7 +922,7 @@
"id": "0dec75d5-035d-4cd6-956e-cafb37f304e7",
"metadata": {},
"source": [
"```\n",
"```python\n",
"# backend_dir/main.py\n",
"\n",
"from fastapi import FastAPI\n",
@ -977,10 +969,12 @@
"id": "3d52418e-9a67-4ea2-984e-5a14bdd78255",
"metadata": {},
"source": [
"```json\n",
"{\n",
" \"message\": \"11bits Studio has a larger daily spread\",\n",
" \"difference\": 1.7968083865943187\n",
"}"
"}\n",
"```"
]
}
],
@ -989,7 +983,9 @@
"description": "Equip your agent with functions that can efficiently implement features into your software application.",
"tags": [
"function call",
"code generation"
"code generation",
"tool use",
"software engineering"
]
},
"kernelspec": {