|
42 | 42 | "outputs": [], |
43 | 43 | "source": [ |
44 | 44 | "\"\"\"\n", |
45 | | - "The following sample demonstrates how to create an Azure AI agent that answers\n", |
46 | | - "questions about a sample menu using a Semantic Kernel Plugin.\n", |
| 45 | + "The following sample demonstrates how to create an Azure AI agent that answers \n", |
| 46 | + "questions about conversational data using a Semantic Kernel plugin.\n", |
47 | 47 | "\"\"\"\n", |
48 | 48 | "\n", |
49 | 49 | "async def get_db_connection():\n", |
|
96 | 96 | " cursor.close()\n", |
97 | 97 | " conn.close()\n", |
98 | 98 | "\n", |
99 | | - "# Define a sample plugin for the sample\n", |
100 | | - "class MenuPlugin:\n", |
| 99 | + "# Define a chat with data plugin for the conversational data\n", |
| 100 | + "class ChatWithDataPlugin:\n", |
101 | 101 | " def __init__(self):\n", |
102 | 102 | " self.azure_openai_deployment_model = os.getenv(\"AZURE_OPEN_AI_DEPLOYMENT_MODEL\")\n", |
103 | 103 | " self.azure_openai_endpoint = os.getenv(\"AZURE_OPEN_AI_ENDPOINT\")\n", |
|
109 | 109 | " self.use_ai_project_client = os.getenv(\"USE_AI_PROJECT_CLIENT\", \"False\").lower() == \"true\"\n", |
110 | 110 | " self.azure_ai_project_conn_string = os.getenv(\"AZURE_AI_PROJECT_CONN_STRING\")\n", |
111 | 111 | " \n", |
112 | | - " \"\"\"A sample Menu Plugin used for the concept sample.\"\"\"\n", |
113 | | - "\n", |
114 | 112 | " \n", |
115 | 113 | " @kernel_function(name=\"Greeting\",\n", |
116 | 114 | " description=\"Respond to any greeting or general questions\")\n", |
|
207 | 205 | " )\n", |
208 | 206 | " sql_query = completion.choices[0].message.content\n", |
209 | 207 | " sql_query = sql_query.replace(\"```sql\", '').replace(\"```\", '')\n", |
210 | | - " print(\"SQL Query: \", sql_query, flush=True)\n", |
| 208 | + " # print(\"SQL Query: \", sql_query, flush=True)\n", |
211 | 209 | "\n", |
212 | 210 | " answer = await execute_sql_query(sql_query)\n", |
213 | 211 | " answer = answer[:20000] if len(answer) > 20000 else answer\n", |
|
342 | 340 | " agent = AzureAIAgent(\n", |
343 | 341 | " client=client,\n", |
344 | 342 | " definition=agent_definition,\n", |
345 | | - " plugins=[MenuPlugin()], # Add the plugin to the agent\n", |
| 343 | + " plugins=[ChatWithDataPlugin()], # Add the plugin to the agent\n", |
346 | 344 | " )\n", |
347 | 345 | "\n", |
348 | 346 | " # 3. Create a thread for the agent\n", |
|
370 | 368 | " await thread.delete() if thread else None\n", |
371 | 369 | " await client.agents.delete_agent(agent.id)\n", |
372 | 370 | "\n", |
373 | | - " \"\"\"\n", |
374 | | - " Sample Output:\n", |
375 | | - " # User: Hello\n", |
376 | | - " # Agent: Hello! How can I assist you today?\n", |
377 | | - " # User: What is the special soup?\n", |
378 | | - " # ...\n", |
379 | | - " \"\"\"\n", |
380 | | - "\n", |
381 | | - "\n", |
382 | 371 | "if __name__ == \"__main__\":\n", |
383 | 372 | " await main()" |
384 | 373 | ] |
|
0 commit comments