|
@@ -0,0 +1,579 @@
|
|
|
+{
|
|
|
+ "cells": [
|
|
|
+ {
|
|
|
+ "cell_type": "markdown",
|
|
|
+ "id": "a3ae7ae7",
|
|
|
+ "metadata": {},
|
|
|
+ "source": [
|
|
|
+ "### 练习4. Agent API 服务\n",
|
|
|
+ "\n",
|
|
|
+ "#### 目标\n",
|
|
|
+ "1. 使用FastAPI公开Agent的SSE接口\n",
|
|
|
+ "2. 使用一个简单的客户端模拟用户来调用这个SSE\n",
|
|
|
+ "\n",
|
|
|
+ "#### 要求\n",
|
|
|
+ "1. 练习2中的收集信息的AI 通过 Agno实现,可以和用户进行流式对话\n",
|
|
|
+ "2. 通过FastAPI SSE 协议输出Agent Stream Response\n",
|
|
|
+ " - https://github.com/agno-agi/agent-api \n",
|
|
|
+ "3. 脚本运行在控制台,可以实现打字机效果的信息收集\n",
|
|
|
+ " - AI 的输出应该和deepseek 一样,是打字机效果\n"
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "cell_type": "code",
|
|
|
+ "execution_count": 1,
|
|
|
+ "id": "6df7a17d",
|
|
|
+ "metadata": {},
|
|
|
+ "outputs": [],
|
|
|
+ "source": [
|
|
|
+ "import os\n",
|
|
|
+ "from dotenv import load_dotenv\n",
|
|
|
+ "\n",
|
|
|
+ "load_dotenv()\n",
|
|
|
+ "base_url = os.getenv('BAILIAN_API_BASE_URL')\n",
|
|
|
+ "api_key = os.getenv('BAILIAN_API_KEY')"
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "cell_type": "code",
|
|
|
+ "execution_count": 5,
|
|
|
+ "id": "500dca93",
|
|
|
+ "metadata": {},
|
|
|
+ "outputs": [],
|
|
|
+ "source": [
|
|
|
+ "from agno.agent import Agent\n",
|
|
|
+ "from agno.tools import tool\n",
|
|
|
+ "from agno.memory.v2.db.sqlite import SqliteMemoryDb\n",
|
|
|
+ "from agno.memory.v2.memory import Memory\n",
|
|
|
+ "from agno.storage.sqlite import SqliteStorage\n",
|
|
|
+ "from agno.models.openai.like import OpenAILike\n",
|
|
|
+ "from typing import Optional, Dict, Any\n",
|
|
|
+ "from enum import Enum\n",
|
|
|
+ "import json\n",
|
|
|
+ "\n",
|
|
|
+ "SYSTEM_PROMPT = \"\"\"\n",
|
|
|
+ " 你是一个信息收集助手。你需要依次收集用户的姓名、年龄和感兴趣的行业。\n",
|
|
|
+ " 如果用户输入其他无关内容,请提醒用户需要先完成信息收集。\n",
|
|
|
+ " 开始对话前,请先介绍自己。\n",
|
|
|
+ " \n",
|
|
|
+ " 工具使用规则:\n",
|
|
|
+ " 1. 每当用户提供有效信息时,必须立即使用 add_info 工具保存信息\n",
|
|
|
+ " 2. 使用 get_info 工具检查特定信息是否已收集\n",
|
|
|
+ " 3. 使用 list_info 工具确认所有已收集的信息\n",
|
|
|
+ "\n",
|
|
|
+ " 信息收集策略:\n",
|
|
|
+ " 1. 使用开放式问题引导用户提供更多信息\n",
|
|
|
+ " 2. 对模糊的信息进行澄清和确认\n",
|
|
|
+ " 3. 根据上下文,智能地推断和补充相关信息\n",
|
|
|
+ " 4. 保持对话的自然性和连贯性\n",
|
|
|
+ " 5. 务必保证信息的准确性和完整性\n",
|
|
|
+ " 6. 只有当信息符合需要收集的内容的规则时(例如姓名必须是符合姓名规则的,年龄必须是1~100内的数字等等),才将其记录到已收集信息中\n",
|
|
|
+ " 7. 如果用户输入年龄时给出的是出生年份,请帮用户计算实际年龄(今年是2025年)。\n",
|
|
|
+ " 8. 如果用户输入的年龄没有明确的数字,则此输入无效。\n",
|
|
|
+ "\n",
|
|
|
+ " 对话要求:\n",
|
|
|
+ " 1. 保持友好、专业的语调\n",
|
|
|
+ " 2. 每次回复要简洁明了\n",
|
|
|
+ " 3. 每个信息收集成功后,确认用户输入的内容,格式为:\"好的,已经收集到您的(此处为收集的项目)是:\",并询问下一个问题。\n",
|
|
|
+ " 4. 当用户询问一些其他问题时,请礼貱地告诉用户,你是一个信息收集助手,不回答其它不相关问题。提醒用户还没收集完成。\n",
|
|
|
+ " 5. 所有问题回答并收集完毕后,请务必要总结用户的所有信息,并告知用户\"信息已收集完毕\"。\n",
|
|
|
+ " 6. 如果没有对话历史,请先介绍自己,再进行询问。\n",
|
|
|
+ " 7. 如果用户回答与问题无关,请礼貌且友好地提醒用户需要回答相关问题。\n",
|
|
|
+ " 8. 请不要直接将问题内容直接输出,而是要根据用户的回答进行智能化的处理和回复。\n",
|
|
|
+ "\n",
|
|
|
+ " 注意事项:\n",
|
|
|
+ " 除非用户输入与信息收集无关,否则一定要调用对应的tools再给予回复。\n",
|
|
|
+ " 除非用户输入与信息收集无关,否则一定要调用对应的tools再给予回复。\n",
|
|
|
+ " 除非用户输入与信息收集无关,否则一定要调用对应的tools再给予回复。\n",
|
|
|
+ " 除非用户输入与信息收集无关,否则一定要调用对应的tools再给予回复。\n",
|
|
|
+ " 除非用户输入与信息收集无关,否则一定要调用对应的tools再给予回复。\n",
|
|
|
+ " 除非用户输入与信息收集无关,否则一定要调用对应的tools再给予回复。\n",
|
|
|
+ "\"\"\"\n",
|
|
|
+ "\n",
|
|
|
+ "# 初始化空的session状态\n",
|
|
|
+ "initial_state = {\n",
|
|
|
+ " \"name\": None,\n",
|
|
|
+ " \"age\": None,\n",
|
|
|
+ " \"industry\": None\n",
|
|
|
+ "}\n",
|
|
|
+ "\n",
|
|
|
+ "class DataField(str, Enum):\n",
|
|
|
+ " NAME = \"name\"\n",
|
|
|
+ " AGE = \"age\"\n",
|
|
|
+ " INDUSTRY = \"industry\"\n",
|
|
|
+ "\n",
|
|
|
+ "@tool(name=\"add_info\", description=\"添加或修改用户信息\")\n",
|
|
|
+ "def add_info(agent: Agent, field: DataField, value: str) -> str:\n",
|
|
|
+ " if field == DataField.NAME:\n",
|
|
|
+ " agent.session_state[\"name\"] = value\n",
|
|
|
+ " return json.dumps({\"result\": f\"已收集姓名: {value}\"})\n",
|
|
|
+ " elif field == DataField.AGE:\n",
|
|
|
+ " try:\n",
|
|
|
+ " age = int(value)\n",
|
|
|
+ " agent.session_state[\"age\"] = age\n",
|
|
|
+ " return json.dumps({\"result\": f\"已收集年龄: {age}\"})\n",
|
|
|
+ " except ValueError:\n",
|
|
|
+ " return json.dumps({\"result\": \"年龄输入无效,请输入一个正确的数字。\"})\n",
|
|
|
+ " elif field == DataField.INDUSTRY:\n",
|
|
|
+ " agent.session_state[\"industry\"] = value\n",
|
|
|
+ " return json.dumps({\"result\": f\"已收集感兴趣的行业: {value}\"})\n",
|
|
|
+ "\n",
|
|
|
+ "@tool(name=\"get_info\", description=\"获取用户信息\")\n",
|
|
|
+ "def get_info(agent:Agent, field: DataField) -> str:\n",
|
|
|
+ " info = agent.session_state.get(field)\n",
|
|
|
+ " if info is None:\n",
|
|
|
+ " info = \"未收集\" if field != DataField.AGE else \"未收集\"\n",
|
|
|
+ " return json.dumps({\"result\": str(info)})\n",
|
|
|
+ "\n",
|
|
|
+ "@tool(name=\"list_info\", description=\"列出所有用户信息\")\n",
|
|
|
+ "def list_info(agent:Agent) -> str:\n",
|
|
|
+ " user_info = agent.session_state\n",
|
|
|
+ " info = {\n",
|
|
|
+ " \"姓名\": user_info.get(\"name\") or \"未收集\",\n",
|
|
|
+ " \"年龄\": user_info.get(\"age\") or \"未收集\",\n",
|
|
|
+ " \"感兴趣的行业\": user_info.get(\"industry\") or \"未收集\"\n",
|
|
|
+ " }\n",
|
|
|
+ " return json.dumps({\"result\": info})\n",
|
|
|
+ "\n",
|
|
|
+ "# 配置\n",
|
|
|
+ "user_id = \"test\"\n",
|
|
|
+ "session_id = \"325\"\n",
|
|
|
+ "db_file = \"tmp/agent.db\"\n",
|
|
|
+ "\n",
|
|
|
+ "# 模型配置\n",
|
|
|
+ "model = OpenAILike(\n",
|
|
|
+ " id=\"qwen3-32b\",\n",
|
|
|
+ " api_key=api_key,\n",
|
|
|
+ " base_url=base_url,\n",
|
|
|
+ " request_params={\n",
|
|
|
+ " \"extra_body\": {\"enable_thinking\": False},\n",
|
|
|
+ " # \"response_format\": {\"type\": \"json_object\"}\n",
|
|
|
+ " },\n",
|
|
|
+ ")\n",
|
|
|
+ "\n",
|
|
|
+ "# 初始化内存和存储\n",
|
|
|
+ "memory = Memory(\n",
|
|
|
+ " model=model,\n",
|
|
|
+ " db=SqliteMemoryDb(table_name=\"user_memories\", db_file=db_file),\n",
|
|
|
+ ")\n",
|
|
|
+ "storage = SqliteStorage(table_name=\"agent_sessions\", db_file=db_file)\n",
|
|
|
+ "\n",
|
|
|
+ "# 创建agent实例\n",
|
|
|
+ "agent = Agent(\n",
|
|
|
+ " model=model,\n",
|
|
|
+ " tools=[add_info, get_info, list_info],\n",
|
|
|
+ " instructions=SYSTEM_PROMPT,\n",
|
|
|
+ " add_datetime_to_instructions=True,\n",
|
|
|
+ " show_tool_calls=True,\n",
|
|
|
+ " markdown=True,\n",
|
|
|
+ " memory=memory,\n",
|
|
|
+ " enable_user_memories=True,\n",
|
|
|
+ " storage=storage,\n",
|
|
|
+ " add_history_to_messages=True,\n",
|
|
|
+ " enable_session_summaries=True,\n",
|
|
|
+ " session_state=initial_state,\n",
|
|
|
+ " add_state_in_messages=True,\n",
|
|
|
+ " session_id=session_id,\n",
|
|
|
+ ")"
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "cell_type": "code",
|
|
|
+ "execution_count": 6,
|
|
|
+ "id": "df49f6e6",
|
|
|
+ "metadata": {},
|
|
|
+ "outputs": [
|
|
|
+ {
|
|
|
+ "data": {
|
|
|
+ "application/vnd.jupyter.widget-view+json": {
|
|
|
+ "model_id": "b4fbe5cc4de0453fb01ba38aebd18695",
|
|
|
+ "version_major": 2,
|
|
|
+ "version_minor": 0
|
|
|
+ },
|
|
|
+ "text/plain": [
|
|
|
+ "Output()"
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ "metadata": {},
|
|
|
+ "output_type": "display_data"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "data": {
|
|
|
+ "text/html": [
|
|
|
+ "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #800000; text-decoration-color: #800000; font-weight: bold\">ERROR </span> API status error from OpenAI API: Error code: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">400</span> - <span style=\"font-weight: bold\">{</span><span style=\"color: #008000; text-decoration-color: #008000\">'error'</span>: <span style=\"font-weight: bold\">{</span><span style=\"color: #008000; text-decoration-color: #008000\">'code'</span>: <span style=\"color: #008000; text-decoration-color: #008000\">'invalid_parameter_error'</span>, <span style=\"color: #008000; text-decoration-color: #008000\">'param'</span>:\n",
|
|
|
+ " <span style=\"color: #800080; text-decoration-color: #800080; font-style: italic\">None</span>, <span style=\"color: #008000; text-decoration-color: #008000\">'message'</span>: <span style=\"color: #008000; text-decoration-color: #008000\">\"<400> InternalError.Algo.InvalidParameter: 'messages' must contain the word 'json' in </span> \n",
|
|
|
+ " <span style=\"color: #008000; text-decoration-color: #008000\">some form, to use 'response_format' of type 'json_object'.\"</span>, <span style=\"color: #008000; text-decoration-color: #008000\">'type'</span>: <span style=\"color: #008000; text-decoration-color: #008000\">'invalid_request_error'</span><span style=\"font-weight: bold\">}</span>, <span style=\"color: #008000; text-decoration-color: #008000\">'id'</span>: \n",
|
|
|
+ " <span style=\"color: #008000; text-decoration-color: #008000\">'chatcmpl-1e479ee3-9537-9c96-a975-f7636f971412'</span>, <span style=\"color: #008000; text-decoration-color: #008000\">'request_id'</span>: <span style=\"color: #008000; text-decoration-color: #008000\">'1e479ee3-9537-9c96-a975-f7636f971412'</span><span style=\"font-weight: bold\">}</span> \n",
|
|
|
+ "</pre>\n"
|
|
|
+ ],
|
|
|
+ "text/plain": [
|
|
|
+ "\u001b[1;31mERROR \u001b[0m API status error from OpenAI API: Error code: \u001b[1;36m400\u001b[0m - \u001b[1m{\u001b[0m\u001b[32m'error'\u001b[0m: \u001b[1m{\u001b[0m\u001b[32m'code'\u001b[0m: \u001b[32m'invalid_parameter_error'\u001b[0m, \u001b[32m'param'\u001b[0m:\n",
|
|
|
+ " \u001b[3;35mNone\u001b[0m, \u001b[32m'message'\u001b[0m: \u001b[32m\"\u001b[0m\u001b[32m<\u001b[0m\u001b[32m400\u001b[0m\u001b[32m>\u001b[0m\u001b[32m InternalError.Algo.InvalidParameter: 'messages' must contain the word 'json' in \u001b[0m \n",
|
|
|
+ " \u001b[32msome form, to use 'response_format' of type 'json_object'.\"\u001b[0m, \u001b[32m'type'\u001b[0m: \u001b[32m'invalid_request_error'\u001b[0m\u001b[1m}\u001b[0m, \u001b[32m'id'\u001b[0m: \n",
|
|
|
+ " \u001b[32m'chatcmpl-1e479ee3-9537-9c96-a975-f7636f971412'\u001b[0m, \u001b[32m'request_id'\u001b[0m: \u001b[32m'1e479ee3-9537-9c96-a975-f7636f971412'\u001b[0m\u001b[1m}\u001b[0m \n"
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ "metadata": {},
|
|
|
+ "output_type": "display_data"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "data": {
|
|
|
+ "text/html": [
|
|
|
+ "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #808000; text-decoration-color: #808000\">WARNING </span> Error in memory/summary operation: <span style=\"font-weight: bold\"><</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">400</span><span style=\"font-weight: bold\">></span> InternalError.Algo.InvalidParameter: <span style=\"color: #008000; text-decoration-color: #008000\">'messages'</span> must contain the \n",
|
|
|
+ " word <span style=\"color: #008000; text-decoration-color: #008000\">'json'</span> in some form, to use <span style=\"color: #008000; text-decoration-color: #008000\">'response_format'</span> of type <span style=\"color: #008000; text-decoration-color: #008000\">'json_object'</span>. \n",
|
|
|
+ "</pre>\n"
|
|
|
+ ],
|
|
|
+ "text/plain": [
|
|
|
+ "\u001b[33mWARNING \u001b[0m Error in memory/summary operation: \u001b[1m<\u001b[0m\u001b[1;36m400\u001b[0m\u001b[1m>\u001b[0m InternalError.Algo.InvalidParameter: \u001b[32m'messages'\u001b[0m must contain the \n",
|
|
|
+ " word \u001b[32m'json'\u001b[0m in some form, to use \u001b[32m'response_format'\u001b[0m of type \u001b[32m'json_object'\u001b[0m. \n"
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ "metadata": {},
|
|
|
+ "output_type": "display_data"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "data": {
|
|
|
+ "text/html": [
|
|
|
+ "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"></pre>\n"
|
|
|
+ ],
|
|
|
+ "text/plain": []
|
|
|
+ },
|
|
|
+ "metadata": {},
|
|
|
+ "output_type": "display_data"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "data": {
|
|
|
+ "application/vnd.jupyter.widget-view+json": {
|
|
|
+ "model_id": "2b2c64e6403f4b44bdf9c6e56bc86f85",
|
|
|
+ "version_major": 2,
|
|
|
+ "version_minor": 0
|
|
|
+ },
|
|
|
+ "text/plain": [
|
|
|
+ "Output()"
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ "metadata": {},
|
|
|
+ "output_type": "display_data"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "data": {
|
|
|
+ "text/html": [
|
|
|
+ "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #800000; text-decoration-color: #800000; font-weight: bold\">ERROR </span> API status error from OpenAI API: Error code: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">400</span> - <span style=\"font-weight: bold\">{</span><span style=\"color: #008000; text-decoration-color: #008000\">'error'</span>: <span style=\"font-weight: bold\">{</span><span style=\"color: #008000; text-decoration-color: #008000\">'code'</span>: <span style=\"color: #008000; text-decoration-color: #008000\">'invalid_parameter_error'</span>, <span style=\"color: #008000; text-decoration-color: #008000\">'param'</span>:\n",
|
|
|
+ " <span style=\"color: #800080; text-decoration-color: #800080; font-style: italic\">None</span>, <span style=\"color: #008000; text-decoration-color: #008000\">'message'</span>: <span style=\"color: #008000; text-decoration-color: #008000\">\"<400> InternalError.Algo.InvalidParameter: 'messages' must contain the word 'json' in </span> \n",
|
|
|
+ " <span style=\"color: #008000; text-decoration-color: #008000\">some form, to use 'response_format' of type 'json_object'.\"</span>, <span style=\"color: #008000; text-decoration-color: #008000\">'type'</span>: <span style=\"color: #008000; text-decoration-color: #008000\">'invalid_request_error'</span><span style=\"font-weight: bold\">}</span>, <span style=\"color: #008000; text-decoration-color: #008000\">'id'</span>: \n",
|
|
|
+ " <span style=\"color: #008000; text-decoration-color: #008000\">'chatcmpl-10940767-691f-94db-ae9b-22cecb594092'</span>, <span style=\"color: #008000; text-decoration-color: #008000\">'request_id'</span>: <span style=\"color: #008000; text-decoration-color: #008000\">'10940767-691f-94db-ae9b-22cecb594092'</span><span style=\"font-weight: bold\">}</span> \n",
|
|
|
+ "</pre>\n"
|
|
|
+ ],
|
|
|
+ "text/plain": [
|
|
|
+ "\u001b[1;31mERROR \u001b[0m API status error from OpenAI API: Error code: \u001b[1;36m400\u001b[0m - \u001b[1m{\u001b[0m\u001b[32m'error'\u001b[0m: \u001b[1m{\u001b[0m\u001b[32m'code'\u001b[0m: \u001b[32m'invalid_parameter_error'\u001b[0m, \u001b[32m'param'\u001b[0m:\n",
|
|
|
+ " \u001b[3;35mNone\u001b[0m, \u001b[32m'message'\u001b[0m: \u001b[32m\"\u001b[0m\u001b[32m<\u001b[0m\u001b[32m400\u001b[0m\u001b[32m>\u001b[0m\u001b[32m InternalError.Algo.InvalidParameter: 'messages' must contain the word 'json' in \u001b[0m \n",
|
|
|
+ " \u001b[32msome form, to use 'response_format' of type 'json_object'.\"\u001b[0m, \u001b[32m'type'\u001b[0m: \u001b[32m'invalid_request_error'\u001b[0m\u001b[1m}\u001b[0m, \u001b[32m'id'\u001b[0m: \n",
|
|
|
+ " \u001b[32m'chatcmpl-10940767-691f-94db-ae9b-22cecb594092'\u001b[0m, \u001b[32m'request_id'\u001b[0m: \u001b[32m'10940767-691f-94db-ae9b-22cecb594092'\u001b[0m\u001b[1m}\u001b[0m \n"
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ "metadata": {},
|
|
|
+ "output_type": "display_data"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "data": {
|
|
|
+ "text/html": [
|
|
|
+ "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #808000; text-decoration-color: #808000\">WARNING </span> Error in memory/summary operation: <span style=\"font-weight: bold\"><</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">400</span><span style=\"font-weight: bold\">></span> InternalError.Algo.InvalidParameter: <span style=\"color: #008000; text-decoration-color: #008000\">'messages'</span> must contain the \n",
|
|
|
+ " word <span style=\"color: #008000; text-decoration-color: #008000\">'json'</span> in some form, to use <span style=\"color: #008000; text-decoration-color: #008000\">'response_format'</span> of type <span style=\"color: #008000; text-decoration-color: #008000\">'json_object'</span>. \n",
|
|
|
+ "</pre>\n"
|
|
|
+ ],
|
|
|
+ "text/plain": [
|
|
|
+ "\u001b[33mWARNING \u001b[0m Error in memory/summary operation: \u001b[1m<\u001b[0m\u001b[1;36m400\u001b[0m\u001b[1m>\u001b[0m InternalError.Algo.InvalidParameter: \u001b[32m'messages'\u001b[0m must contain the \n",
|
|
|
+ " word \u001b[32m'json'\u001b[0m in some form, to use \u001b[32m'response_format'\u001b[0m of type \u001b[32m'json_object'\u001b[0m. \n"
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ "metadata": {},
|
|
|
+ "output_type": "display_data"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "data": {
|
|
|
+ "text/html": [
|
|
|
+ "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"></pre>\n"
|
|
|
+ ],
|
|
|
+ "text/plain": []
|
|
|
+ },
|
|
|
+ "metadata": {},
|
|
|
+ "output_type": "display_data"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "data": {
|
|
|
+ "application/vnd.jupyter.widget-view+json": {
|
|
|
+ "model_id": "d2c852ff4dd14ba48ef28fcbb603ac5d",
|
|
|
+ "version_major": 2,
|
|
|
+ "version_minor": 0
|
|
|
+ },
|
|
|
+ "text/plain": [
|
|
|
+ "Output()"
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ "metadata": {},
|
|
|
+ "output_type": "display_data"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "data": {
|
|
|
+ "text/html": [
|
|
|
+ "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #800000; text-decoration-color: #800000; font-weight: bold\">ERROR </span> API status error from OpenAI API: Error code: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">400</span> - <span style=\"font-weight: bold\">{</span><span style=\"color: #008000; text-decoration-color: #008000\">'error'</span>: <span style=\"font-weight: bold\">{</span><span style=\"color: #008000; text-decoration-color: #008000\">'code'</span>: <span style=\"color: #008000; text-decoration-color: #008000\">'invalid_parameter_error'</span>, <span style=\"color: #008000; text-decoration-color: #008000\">'param'</span>:\n",
|
|
|
+ " <span style=\"color: #800080; text-decoration-color: #800080; font-style: italic\">None</span>, <span style=\"color: #008000; text-decoration-color: #008000\">'message'</span>: <span style=\"color: #008000; text-decoration-color: #008000\">\"<400> InternalError.Algo.InvalidParameter: 'messages' must contain the word 'json' in </span> \n",
|
|
|
+ " <span style=\"color: #008000; text-decoration-color: #008000\">some form, to use 'response_format' of type 'json_object'.\"</span>, <span style=\"color: #008000; text-decoration-color: #008000\">'type'</span>: <span style=\"color: #008000; text-decoration-color: #008000\">'invalid_request_error'</span><span style=\"font-weight: bold\">}</span>, <span style=\"color: #008000; text-decoration-color: #008000\">'id'</span>: \n",
|
|
|
+ " <span style=\"color: #008000; text-decoration-color: #008000\">'chatcmpl-64e4ea6b-2d1a-9c6b-8055-31ad9e4f84a7'</span>, <span style=\"color: #008000; text-decoration-color: #008000\">'request_id'</span>: <span style=\"color: #008000; text-decoration-color: #008000\">'64e4ea6b-2d1a-9c6b-8055-31ad9e4f84a7'</span><span style=\"font-weight: bold\">}</span> \n",
|
|
|
+ "</pre>\n"
|
|
|
+ ],
|
|
|
+ "text/plain": [
|
|
|
+ "\u001b[1;31mERROR \u001b[0m API status error from OpenAI API: Error code: \u001b[1;36m400\u001b[0m - \u001b[1m{\u001b[0m\u001b[32m'error'\u001b[0m: \u001b[1m{\u001b[0m\u001b[32m'code'\u001b[0m: \u001b[32m'invalid_parameter_error'\u001b[0m, \u001b[32m'param'\u001b[0m:\n",
|
|
|
+ " \u001b[3;35mNone\u001b[0m, \u001b[32m'message'\u001b[0m: \u001b[32m\"\u001b[0m\u001b[32m<\u001b[0m\u001b[32m400\u001b[0m\u001b[32m>\u001b[0m\u001b[32m InternalError.Algo.InvalidParameter: 'messages' must contain the word 'json' in \u001b[0m \n",
|
|
|
+ " \u001b[32msome form, to use 'response_format' of type 'json_object'.\"\u001b[0m, \u001b[32m'type'\u001b[0m: \u001b[32m'invalid_request_error'\u001b[0m\u001b[1m}\u001b[0m, \u001b[32m'id'\u001b[0m: \n",
|
|
|
+ " \u001b[32m'chatcmpl-64e4ea6b-2d1a-9c6b-8055-31ad9e4f84a7'\u001b[0m, \u001b[32m'request_id'\u001b[0m: \u001b[32m'64e4ea6b-2d1a-9c6b-8055-31ad9e4f84a7'\u001b[0m\u001b[1m}\u001b[0m \n"
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ "metadata": {},
|
|
|
+ "output_type": "display_data"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "data": {
|
|
|
+ "text/html": [
|
|
|
+ "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #808000; text-decoration-color: #808000\">WARNING </span> Error in memory/summary operation: <span style=\"font-weight: bold\"><</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">400</span><span style=\"font-weight: bold\">></span> InternalError.Algo.InvalidParameter: <span style=\"color: #008000; text-decoration-color: #008000\">'messages'</span> must contain the \n",
|
|
|
+ " word <span style=\"color: #008000; text-decoration-color: #008000\">'json'</span> in some form, to use <span style=\"color: #008000; text-decoration-color: #008000\">'response_format'</span> of type <span style=\"color: #008000; text-decoration-color: #008000\">'json_object'</span>. \n",
|
|
|
+ "</pre>\n"
|
|
|
+ ],
|
|
|
+ "text/plain": [
|
|
|
+ "\u001b[33mWARNING \u001b[0m Error in memory/summary operation: \u001b[1m<\u001b[0m\u001b[1;36m400\u001b[0m\u001b[1m>\u001b[0m InternalError.Algo.InvalidParameter: \u001b[32m'messages'\u001b[0m must contain the \n",
|
|
|
+ " word \u001b[32m'json'\u001b[0m in some form, to use \u001b[32m'response_format'\u001b[0m of type \u001b[32m'json_object'\u001b[0m. \n"
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ "metadata": {},
|
|
|
+ "output_type": "display_data"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "data": {
|
|
|
+ "text/html": [
|
|
|
+ "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"></pre>\n"
|
|
|
+ ],
|
|
|
+ "text/plain": []
|
|
|
+ },
|
|
|
+ "metadata": {},
|
|
|
+ "output_type": "display_data"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "data": {
|
|
|
+ "application/vnd.jupyter.widget-view+json": {
|
|
|
+ "model_id": "a02e667920734d48b41c1b8ae2d858df",
|
|
|
+ "version_major": 2,
|
|
|
+ "version_minor": 0
|
|
|
+ },
|
|
|
+ "text/plain": [
|
|
|
+ "Output()"
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ "metadata": {},
|
|
|
+ "output_type": "display_data"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "data": {
|
|
|
+ "text/html": [
|
|
|
+ "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #800000; text-decoration-color: #800000; font-weight: bold\">ERROR </span> API status error from OpenAI API: Error code: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">400</span> - <span style=\"font-weight: bold\">{</span><span style=\"color: #008000; text-decoration-color: #008000\">'error'</span>: <span style=\"font-weight: bold\">{</span><span style=\"color: #008000; text-decoration-color: #008000\">'code'</span>: <span style=\"color: #008000; text-decoration-color: #008000\">'invalid_parameter_error'</span>, <span style=\"color: #008000; text-decoration-color: #008000\">'param'</span>:\n",
|
|
|
+ " <span style=\"color: #800080; text-decoration-color: #800080; font-style: italic\">None</span>, <span style=\"color: #008000; text-decoration-color: #008000\">'message'</span>: <span style=\"color: #008000; text-decoration-color: #008000\">\"<400> InternalError.Algo.InvalidParameter: 'messages' must contain the word 'json' in </span> \n",
|
|
|
+ " <span style=\"color: #008000; text-decoration-color: #008000\">some form, to use 'response_format' of type 'json_object'.\"</span>, <span style=\"color: #008000; text-decoration-color: #008000\">'type'</span>: <span style=\"color: #008000; text-decoration-color: #008000\">'invalid_request_error'</span><span style=\"font-weight: bold\">}</span>, <span style=\"color: #008000; text-decoration-color: #008000\">'id'</span>: \n",
|
|
|
+ " <span style=\"color: #008000; text-decoration-color: #008000\">'chatcmpl-01755646-39d4-92a6-a669-82a9adee8a80'</span>, <span style=\"color: #008000; text-decoration-color: #008000\">'request_id'</span>: <span style=\"color: #008000; text-decoration-color: #008000\">'01755646-39d4-92a6-a669-82a9adee8a80'</span><span style=\"font-weight: bold\">}</span> \n",
|
|
|
+ "</pre>\n"
|
|
|
+ ],
|
|
|
+ "text/plain": [
|
|
|
+ "\u001b[1;31mERROR \u001b[0m API status error from OpenAI API: Error code: \u001b[1;36m400\u001b[0m - \u001b[1m{\u001b[0m\u001b[32m'error'\u001b[0m: \u001b[1m{\u001b[0m\u001b[32m'code'\u001b[0m: \u001b[32m'invalid_parameter_error'\u001b[0m, \u001b[32m'param'\u001b[0m:\n",
|
|
|
+ " \u001b[3;35mNone\u001b[0m, \u001b[32m'message'\u001b[0m: \u001b[32m\"\u001b[0m\u001b[32m<\u001b[0m\u001b[32m400\u001b[0m\u001b[32m>\u001b[0m\u001b[32m InternalError.Algo.InvalidParameter: 'messages' must contain the word 'json' in \u001b[0m \n",
|
|
|
+ " \u001b[32msome form, to use 'response_format' of type 'json_object'.\"\u001b[0m, \u001b[32m'type'\u001b[0m: \u001b[32m'invalid_request_error'\u001b[0m\u001b[1m}\u001b[0m, \u001b[32m'id'\u001b[0m: \n",
|
|
|
+ " \u001b[32m'chatcmpl-01755646-39d4-92a6-a669-82a9adee8a80'\u001b[0m, \u001b[32m'request_id'\u001b[0m: \u001b[32m'01755646-39d4-92a6-a669-82a9adee8a80'\u001b[0m\u001b[1m}\u001b[0m \n"
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ "metadata": {},
|
|
|
+ "output_type": "display_data"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "data": {
|
|
|
+ "text/html": [
|
|
|
+ "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #808000; text-decoration-color: #808000\">WARNING </span> Error in memory/summary operation: <span style=\"font-weight: bold\"><</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">400</span><span style=\"font-weight: bold\">></span> InternalError.Algo.InvalidParameter: <span style=\"color: #008000; text-decoration-color: #008000\">'messages'</span> must contain the \n",
|
|
|
+ " word <span style=\"color: #008000; text-decoration-color: #008000\">'json'</span> in some form, to use <span style=\"color: #008000; text-decoration-color: #008000\">'response_format'</span> of type <span style=\"color: #008000; text-decoration-color: #008000\">'json_object'</span>. \n",
|
|
|
+ "</pre>\n"
|
|
|
+ ],
|
|
|
+ "text/plain": [
|
|
|
+ "\u001b[33mWARNING \u001b[0m Error in memory/summary operation: \u001b[1m<\u001b[0m\u001b[1;36m400\u001b[0m\u001b[1m>\u001b[0m InternalError.Algo.InvalidParameter: \u001b[32m'messages'\u001b[0m must contain the \n",
|
|
|
+ " word \u001b[32m'json'\u001b[0m in some form, to use \u001b[32m'response_format'\u001b[0m of type \u001b[32m'json_object'\u001b[0m. \n"
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ "metadata": {},
|
|
|
+ "output_type": "display_data"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "data": {
|
|
|
+ "text/html": [
|
|
|
+ "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"></pre>\n"
|
|
|
+ ],
|
|
|
+ "text/plain": []
|
|
|
+ },
|
|
|
+ "metadata": {},
|
|
|
+ "output_type": "display_data"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "data": {
|
|
|
+ "application/vnd.jupyter.widget-view+json": {
|
|
|
+ "model_id": "ae031d34aceb41fcbca3de0448cf8295",
|
|
|
+ "version_major": 2,
|
|
|
+ "version_minor": 0
|
|
|
+ },
|
|
|
+ "text/plain": [
|
|
|
+ "Output()"
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ "metadata": {},
|
|
|
+ "output_type": "display_data"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "data": {
|
|
|
+ "text/html": [
|
|
|
+ "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #800000; text-decoration-color: #800000; font-weight: bold\">ERROR </span> API status error from OpenAI API: Error code: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">400</span> - <span style=\"font-weight: bold\">{</span><span style=\"color: #008000; text-decoration-color: #008000\">'error'</span>: <span style=\"font-weight: bold\">{</span><span style=\"color: #008000; text-decoration-color: #008000\">'code'</span>: <span style=\"color: #008000; text-decoration-color: #008000\">'invalid_parameter_error'</span>, <span style=\"color: #008000; text-decoration-color: #008000\">'param'</span>:\n",
|
|
|
+ " <span style=\"color: #800080; text-decoration-color: #800080; font-style: italic\">None</span>, <span style=\"color: #008000; text-decoration-color: #008000\">'message'</span>: <span style=\"color: #008000; text-decoration-color: #008000\">\"<400> InternalError.Algo.InvalidParameter: 'messages' must contain the word 'json' in </span> \n",
|
|
|
+ " <span style=\"color: #008000; text-decoration-color: #008000\">some form, to use 'response_format' of type 'json_object'.\"</span>, <span style=\"color: #008000; text-decoration-color: #008000\">'type'</span>: <span style=\"color: #008000; text-decoration-color: #008000\">'invalid_request_error'</span><span style=\"font-weight: bold\">}</span>, <span style=\"color: #008000; text-decoration-color: #008000\">'id'</span>: \n",
|
|
|
+ " <span style=\"color: #008000; text-decoration-color: #008000\">'chatcmpl-125922ae-83ae-9a7d-8e43-041960af93d4'</span>, <span style=\"color: #008000; text-decoration-color: #008000\">'request_id'</span>: <span style=\"color: #008000; text-decoration-color: #008000\">'125922ae-83ae-9a7d-8e43-041960af93d4'</span><span style=\"font-weight: bold\">}</span> \n",
|
|
|
+ "</pre>\n"
|
|
|
+ ],
|
|
|
+ "text/plain": [
|
|
|
+ "\u001b[1;31mERROR \u001b[0m API status error from OpenAI API: Error code: \u001b[1;36m400\u001b[0m - \u001b[1m{\u001b[0m\u001b[32m'error'\u001b[0m: \u001b[1m{\u001b[0m\u001b[32m'code'\u001b[0m: \u001b[32m'invalid_parameter_error'\u001b[0m, \u001b[32m'param'\u001b[0m:\n",
|
|
|
+ " \u001b[3;35mNone\u001b[0m, \u001b[32m'message'\u001b[0m: \u001b[32m\"\u001b[0m\u001b[32m<\u001b[0m\u001b[32m400\u001b[0m\u001b[32m>\u001b[0m\u001b[32m InternalError.Algo.InvalidParameter: 'messages' must contain the word 'json' in \u001b[0m \n",
|
|
|
+ " \u001b[32msome form, to use 'response_format' of type 'json_object'.\"\u001b[0m, \u001b[32m'type'\u001b[0m: \u001b[32m'invalid_request_error'\u001b[0m\u001b[1m}\u001b[0m, \u001b[32m'id'\u001b[0m: \n",
|
|
|
+ " \u001b[32m'chatcmpl-125922ae-83ae-9a7d-8e43-041960af93d4'\u001b[0m, \u001b[32m'request_id'\u001b[0m: \u001b[32m'125922ae-83ae-9a7d-8e43-041960af93d4'\u001b[0m\u001b[1m}\u001b[0m \n"
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ "metadata": {},
|
|
|
+ "output_type": "display_data"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "data": {
|
|
|
+ "text/html": [
|
|
|
+ "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #808000; text-decoration-color: #808000\">WARNING </span> Error in memory/summary operation: <span style=\"font-weight: bold\"><</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">400</span><span style=\"font-weight: bold\">></span> InternalError.Algo.InvalidParameter: <span style=\"color: #008000; text-decoration-color: #008000\">'messages'</span> must contain the \n",
|
|
|
+ " word <span style=\"color: #008000; text-decoration-color: #008000\">'json'</span> in some form, to use <span style=\"color: #008000; text-decoration-color: #008000\">'response_format'</span> of type <span style=\"color: #008000; text-decoration-color: #008000\">'json_object'</span>. \n",
|
|
|
+ "</pre>\n"
|
|
|
+ ],
|
|
|
+ "text/plain": [
|
|
|
+ "\u001b[33mWARNING \u001b[0m Error in memory/summary operation: \u001b[1m<\u001b[0m\u001b[1;36m400\u001b[0m\u001b[1m>\u001b[0m InternalError.Algo.InvalidParameter: \u001b[32m'messages'\u001b[0m must contain the \n",
|
|
|
+ " word \u001b[32m'json'\u001b[0m in some form, to use \u001b[32m'response_format'\u001b[0m of type \u001b[32m'json_object'\u001b[0m. \n"
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ "metadata": {},
|
|
|
+ "output_type": "display_data"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "data": {
|
|
|
+ "text/html": [
|
|
|
+ "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"></pre>\n"
|
|
|
+ ],
|
|
|
+ "text/plain": []
|
|
|
+ },
|
|
|
+ "metadata": {},
|
|
|
+ "output_type": "display_data"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "data": {
|
|
|
+ "application/vnd.jupyter.widget-view+json": {
|
|
|
+ "model_id": "f980a267cb2d4fd5bcb75cb53662f636",
|
|
|
+ "version_major": 2,
|
|
|
+ "version_minor": 0
|
|
|
+ },
|
|
|
+ "text/plain": [
|
|
|
+ "Output()"
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ "metadata": {},
|
|
|
+ "output_type": "display_data"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "data": {
|
|
|
+ "text/html": [
|
|
|
+ "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #800000; text-decoration-color: #800000; font-weight: bold\">ERROR </span> API status error from OpenAI API: Error code: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">400</span> - <span style=\"font-weight: bold\">{</span><span style=\"color: #008000; text-decoration-color: #008000\">'error'</span>: <span style=\"font-weight: bold\">{</span><span style=\"color: #008000; text-decoration-color: #008000\">'code'</span>: <span style=\"color: #008000; text-decoration-color: #008000\">'invalid_parameter_error'</span>, <span style=\"color: #008000; text-decoration-color: #008000\">'param'</span>:\n",
|
|
|
+ " <span style=\"color: #800080; text-decoration-color: #800080; font-style: italic\">None</span>, <span style=\"color: #008000; text-decoration-color: #008000\">'message'</span>: <span style=\"color: #008000; text-decoration-color: #008000\">\"<400> InternalError.Algo.InvalidParameter: 'messages' must contain the word 'json' in </span> \n",
|
|
|
+ " <span style=\"color: #008000; text-decoration-color: #008000\">some form, to use 'response_format' of type 'json_object'.\"</span>, <span style=\"color: #008000; text-decoration-color: #008000\">'type'</span>: <span style=\"color: #008000; text-decoration-color: #008000\">'invalid_request_error'</span><span style=\"font-weight: bold\">}</span>, <span style=\"color: #008000; text-decoration-color: #008000\">'id'</span>: \n",
|
|
|
+ " <span style=\"color: #008000; text-decoration-color: #008000\">'chatcmpl-e66c74dc-790f-97ec-8fe7-92317f6ead7b'</span>, <span style=\"color: #008000; text-decoration-color: #008000\">'request_id'</span>: <span style=\"color: #008000; text-decoration-color: #008000\">'e66c74dc-790f-97ec-8fe7-92317f6ead7b'</span><span style=\"font-weight: bold\">}</span> \n",
|
|
|
+ "</pre>\n"
|
|
|
+ ],
|
|
|
+ "text/plain": [
|
|
|
+ "\u001b[1;31mERROR \u001b[0m API status error from OpenAI API: Error code: \u001b[1;36m400\u001b[0m - \u001b[1m{\u001b[0m\u001b[32m'error'\u001b[0m: \u001b[1m{\u001b[0m\u001b[32m'code'\u001b[0m: \u001b[32m'invalid_parameter_error'\u001b[0m, \u001b[32m'param'\u001b[0m:\n",
|
|
|
+ " \u001b[3;35mNone\u001b[0m, \u001b[32m'message'\u001b[0m: \u001b[32m\"\u001b[0m\u001b[32m<\u001b[0m\u001b[32m400\u001b[0m\u001b[32m>\u001b[0m\u001b[32m InternalError.Algo.InvalidParameter: 'messages' must contain the word 'json' in \u001b[0m \n",
|
|
|
+ " \u001b[32msome form, to use 'response_format' of type 'json_object'.\"\u001b[0m, \u001b[32m'type'\u001b[0m: \u001b[32m'invalid_request_error'\u001b[0m\u001b[1m}\u001b[0m, \u001b[32m'id'\u001b[0m: \n",
|
|
|
+ " \u001b[32m'chatcmpl-e66c74dc-790f-97ec-8fe7-92317f6ead7b'\u001b[0m, \u001b[32m'request_id'\u001b[0m: \u001b[32m'e66c74dc-790f-97ec-8fe7-92317f6ead7b'\u001b[0m\u001b[1m}\u001b[0m \n"
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ "metadata": {},
|
|
|
+ "output_type": "display_data"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "data": {
|
|
|
+ "text/html": [
|
|
|
+ "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #808000; text-decoration-color: #808000\">WARNING </span> Error in memory/summary operation: <span style=\"font-weight: bold\"><</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">400</span><span style=\"font-weight: bold\">></span> InternalError.Algo.InvalidParameter: <span style=\"color: #008000; text-decoration-color: #008000\">'messages'</span> must contain the \n",
|
|
|
+ " word <span style=\"color: #008000; text-decoration-color: #008000\">'json'</span> in some form, to use <span style=\"color: #008000; text-decoration-color: #008000\">'response_format'</span> of type <span style=\"color: #008000; text-decoration-color: #008000\">'json_object'</span>. \n",
|
|
|
+ "</pre>\n"
|
|
|
+ ],
|
|
|
+ "text/plain": [
|
|
|
+ "\u001b[33mWARNING \u001b[0m Error in memory/summary operation: \u001b[1m<\u001b[0m\u001b[1;36m400\u001b[0m\u001b[1m>\u001b[0m InternalError.Algo.InvalidParameter: \u001b[32m'messages'\u001b[0m must contain the \n",
|
|
|
+ " word \u001b[32m'json'\u001b[0m in some form, to use \u001b[32m'response_format'\u001b[0m of type \u001b[32m'json_object'\u001b[0m. \n"
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ "metadata": {},
|
|
|
+ "output_type": "display_data"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "data": {
|
|
|
+ "text/html": [
|
|
|
+ "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"></pre>\n"
|
|
|
+ ],
|
|
|
+ "text/plain": []
|
|
|
+ },
|
|
|
+ "metadata": {},
|
|
|
+ "output_type": "display_data"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "name": "stdout",
|
|
|
+ "output_type": "stream",
|
|
|
+ "text": [
|
|
|
+ "对话结束。\n"
|
|
|
+ ]
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ "source": [
|
|
|
+ "# 主对话循环\n",
|
|
|
+ "agent.print_response(\"你好\", stream=True, user_id=user_id)\n",
|
|
|
+ "while True:\n",
|
|
|
+ " user_input = input(\"用户: \")\n",
|
|
|
+ " if user_input.lower() in ['exit', 'quit']:\n",
|
|
|
+ " print(\"对话结束。\")\n",
|
|
|
+ " break\n",
|
|
|
+ " if not user_input.strip():\n",
|
|
|
+ " print(\"输入不能为空,请重新输入。\")\n",
|
|
|
+ " continue\n",
|
|
|
+ "\n",
|
|
|
+ " agent.print_response(\"\"+user_input, stream=True, user_id=user_id)"
|
|
|
+ ]
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ "metadata": {
|
|
|
+ "kernelspec": {
|
|
|
+ "display_name": "ai-learning",
|
|
|
+ "language": "python",
|
|
|
+ "name": "python3"
|
|
|
+ },
|
|
|
+ "language_info": {
|
|
|
+ "codemirror_mode": {
|
|
|
+ "name": "ipython",
|
|
|
+ "version": 3
|
|
|
+ },
|
|
|
+ "file_extension": ".py",
|
|
|
+ "mimetype": "text/x-python",
|
|
|
+ "name": "python",
|
|
|
+ "nbconvert_exporter": "python",
|
|
|
+ "pygments_lexer": "ipython3",
|
|
|
+ "version": "3.11.13"
|
|
|
+ }
|
|
|
+ },
|
|
|
+ "nbformat": 4,
|
|
|
+ "nbformat_minor": 5
|
|
|
+}
|