feat:增加移动端提示词
This commit is contained in:
2
.idea/sweet-hut-agent.iml
generated
2
.idea/sweet-hut-agent.iml
generated
@@ -5,7 +5,7 @@
|
|||||||
<excludeFolder url="file://$MODULE_DIR$/.venv" />
|
<excludeFolder url="file://$MODULE_DIR$/.venv" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/venv" />
|
<excludeFolder url="file://$MODULE_DIR$/venv" />
|
||||||
</content>
|
</content>
|
||||||
<orderEntry type="jdk" jdkName="Python 3.12 (sweet-hut-agent) (2)" jdkType="Python SDK" />
|
<orderEntry type="jdk" jdkName="Python 3.12 (sweet-hut-agent)" jdkType="Python SDK" />
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
</component>
|
</component>
|
||||||
</module>
|
</module>
|
||||||
84
.idea/workspace.xml
generated
84
.idea/workspace.xml
generated
@@ -5,18 +5,11 @@
|
|||||||
</component>
|
</component>
|
||||||
<component name="ChangeListManager">
|
<component name="ChangeListManager">
|
||||||
<list default="true" id="fca82301-8db7-46f2-bd02-1f76c1dc566b" name="Changes" comment="">
|
<list default="true" id="fca82301-8db7-46f2-bd02-1f76c1dc566b" name="Changes" comment="">
|
||||||
<change beforePath="$PROJECT_DIR$/.env" beforeDir="false" afterPath="$PROJECT_DIR$/.env" afterDir="false" />
|
<change afterPath="$PROJECT_DIR$/prompt/mobile.py" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/.gitignore" beforeDir="false" afterPath="$PROJECT_DIR$/.gitignore" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/.idea/sweet-hut-agent.iml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/sweet-hut-agent.iml" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/agent.py" beforeDir="false" />
|
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/config/db.py" beforeDir="false" />
|
<change beforePath="$PROJECT_DIR$/modes/agent.py" beforeDir="false" afterPath="$PROJECT_DIR$/modes/agent.py" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/main.py" beforeDir="false" afterPath="$PROJECT_DIR$/main.py" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/services.py" beforeDir="false" afterPath="$PROJECT_DIR$/services.py" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/model.py" beforeDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/prompt/sql.py" beforeDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/prompt/system.py" beforeDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/prompt/table.py" beforeDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/requirements.txt" beforeDir="false" afterPath="$PROJECT_DIR$/requirements.txt" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/router.py" beforeDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/services/agent_service.py" beforeDir="false" />
|
|
||||||
</list>
|
</list>
|
||||||
<option name="SHOW_DIALOG" value="false" />
|
<option name="SHOW_DIALOG" value="false" />
|
||||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||||
@@ -43,37 +36,42 @@
|
|||||||
<option name="hideEmptyMiddlePackages" value="true" />
|
<option name="hideEmptyMiddlePackages" value="true" />
|
||||||
<option name="showLibraryContents" value="true" />
|
<option name="showLibraryContents" value="true" />
|
||||||
</component>
|
</component>
|
||||||
<component name="PropertiesComponent">{
|
<component name="PropertiesComponent"><![CDATA[{
|
||||||
"keyToString": {
|
"keyToString": {
|
||||||
"FastAPI.sweet-hut-agent.executor": "Run",
|
"Docker.Dockerfile.executor": "Run",
|
||||||
"RunOnceActivity.ShowReadmeOnStart": "true",
|
"FastAPI.sweet-hut-agent.executor": "Run",
|
||||||
"RunOnceActivity.TerminalTabsStorage.copyFrom.TerminalArrangementManager.252": "true",
|
"RunOnceActivity.ShowReadmeOnStart": "true",
|
||||||
"RunOnceActivity.git.unshallow": "true",
|
"RunOnceActivity.TerminalTabsStorage.copyFrom.TerminalArrangementManager.252": "true",
|
||||||
"RunOnceActivity.typescript.service.memoryLimit.init": "true",
|
"RunOnceActivity.git.unshallow": "true",
|
||||||
"git-widget-placeholder": "master",
|
"RunOnceActivity.typescript.service.memoryLimit.init": "true",
|
||||||
"last_opened_file_path": "D:/Cxx/PythonProjects/sweet-hut-agent/prompt",
|
"git-widget-placeholder": "master",
|
||||||
"node.js.detected.package.eslint": "true",
|
"last_opened_file_path": "D:/Projects/GithubProjects/sweet-hut-agent",
|
||||||
"node.js.detected.package.tslint": "true",
|
"node.js.detected.package.eslint": "true",
|
||||||
"node.js.selected.package.eslint": "(autodetect)",
|
"node.js.detected.package.tslint": "true",
|
||||||
"node.js.selected.package.tslint": "(autodetect)",
|
"node.js.selected.package.eslint": "(autodetect)",
|
||||||
"nodejs_package_manager_path": "npm",
|
"node.js.selected.package.tslint": "(autodetect)",
|
||||||
"vue.rearranger.settings.migration": "true"
|
"nodejs_package_manager_path": "npm",
|
||||||
|
"settings.editor.selected.configurable": "com.jetbrains.python.configuration.PyActiveSdkModuleConfigurable",
|
||||||
|
"vue.rearranger.settings.migration": "true"
|
||||||
}
|
}
|
||||||
}</component>
|
}]]></component>
|
||||||
<component name="RecentsManager">
|
<component name="RecentsManager">
|
||||||
<key name="CopyFile.RECENT_KEYS">
|
<key name="CopyFile.RECENT_KEYS">
|
||||||
<recent name="D:\Cxx\PythonProjects\sweet-hut-agent\prompt" />
|
<recent name="D:\Cxx\PythonProjects\sweet-hut-agent\prompt" />
|
||||||
<recent name="D:\Cxx\PythonProjects\sweet-hut-agent" />
|
<recent name="D:\Cxx\PythonProjects\sweet-hut-agent" />
|
||||||
</key>
|
</key>
|
||||||
|
<key name="MoveFile.RECENT_KEYS">
|
||||||
|
<recent name="D:\Projects\GithubProjects\sweet-hut-agent\prompt" />
|
||||||
|
</key>
|
||||||
</component>
|
</component>
|
||||||
<component name="RunManager">
|
<component name="RunManager" selected="FastAPI.sweet-hut-agent">
|
||||||
<configuration name="sweet-hut-agent" type="Python.FastAPI">
|
<configuration name="sweet-hut-agent" type="Python.FastAPI">
|
||||||
<option name="file" value="$PROJECT_DIR$/main.py" />
|
<option name="file" value="D:\Projects\GithubProjects\sweet-hut-agent\main.py" />
|
||||||
<module name="sweet-hut-agent" />
|
<module name="sweet-hut-agent" />
|
||||||
<option name="ENV_FILES" value="" />
|
<option name="ENV_FILES" value="" />
|
||||||
<option name="INTERPRETER_OPTIONS" value="" />
|
<option name="INTERPRETER_OPTIONS" value="" />
|
||||||
<option name="PARENT_ENVS" value="true" />
|
<option name="PARENT_ENVS" value="true" />
|
||||||
<option name="SDK_HOME" value="" />
|
<option name="SDK_HOME" value="$PROJECT_DIR$/venv/Scripts/python.exe" />
|
||||||
<option name="WORKING_DIRECTORY" value="" />
|
<option name="WORKING_DIRECTORY" value="" />
|
||||||
<option name="IS_MODULE_SDK" value="false" />
|
<option name="IS_MODULE_SDK" value="false" />
|
||||||
<option name="ADD_CONTENT_ROOTS" value="true" />
|
<option name="ADD_CONTENT_ROOTS" value="true" />
|
||||||
@@ -83,6 +81,25 @@
|
|||||||
<option name="launchJavascriptDebuger" value="false" />
|
<option name="launchJavascriptDebuger" value="false" />
|
||||||
<method v="2" />
|
<method v="2" />
|
||||||
</configuration>
|
</configuration>
|
||||||
|
<configuration name="Dockerfile" type="docker-deploy" factoryName="dockerfile" temporary="true" server-name="FnOS">
|
||||||
|
<deployment type="dockerfile">
|
||||||
|
<settings>
|
||||||
|
<option name="imageTag" value="cxx/agent-service:0.0.1" />
|
||||||
|
<option name="buildOnly" value="true" />
|
||||||
|
<option name="sourceFilePath" value="Dockerfile" />
|
||||||
|
</settings>
|
||||||
|
</deployment>
|
||||||
|
<method v="2" />
|
||||||
|
</configuration>
|
||||||
|
<configuration default="true" type="docker-deploy" factoryName="dockerfile" temporary="true">
|
||||||
|
<deployment type="dockerfile" />
|
||||||
|
<method v="2" />
|
||||||
|
</configuration>
|
||||||
|
<recent_temporary>
|
||||||
|
<list>
|
||||||
|
<item itemvalue="Docker.Dockerfile" />
|
||||||
|
</list>
|
||||||
|
</recent_temporary>
|
||||||
</component>
|
</component>
|
||||||
<component name="SharedIndexes">
|
<component name="SharedIndexes">
|
||||||
<attachedChunks>
|
<attachedChunks>
|
||||||
@@ -104,6 +121,9 @@
|
|||||||
<workItem from="1780488022005" duration="10000" />
|
<workItem from="1780488022005" duration="10000" />
|
||||||
<workItem from="1780971608037" duration="7293000" />
|
<workItem from="1780971608037" duration="7293000" />
|
||||||
<workItem from="1783001713796" duration="2000" />
|
<workItem from="1783001713796" duration="2000" />
|
||||||
|
<workItem from="1783001739320" duration="123000" />
|
||||||
|
<workItem from="1783001898877" duration="308000" />
|
||||||
|
<workItem from="1783154148904" duration="5949000" />
|
||||||
</task>
|
</task>
|
||||||
<servers />
|
<servers />
|
||||||
</component>
|
</component>
|
||||||
@@ -111,6 +131,6 @@
|
|||||||
<option name="version" value="3" />
|
<option name="version" value="3" />
|
||||||
</component>
|
</component>
|
||||||
<component name="com.intellij.coverage.CoverageDataManagerImpl">
|
<component name="com.intellij.coverage.CoverageDataManagerImpl">
|
||||||
<SUITE FILE_PATH="coverage/sweet_hut_agent$sweet_hut_agent.coverage" NAME="sweet-hut-agent Coverage Results" MODIFIED="1780976147915" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="false" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="" />
|
<SUITE FILE_PATH="coverage/sweet_hut_agent$sweet_hut_agent.coverage" NAME="sweet-hut-agent Coverage Results" MODIFIED="1783163395097" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="false" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
||||||
@@ -2,3 +2,4 @@ from pydantic import BaseModel
|
|||||||
|
|
||||||
class QueryRequest(BaseModel):
|
class QueryRequest(BaseModel):
|
||||||
message: str
|
message: str
|
||||||
|
platform: str | None = None
|
||||||
8
prompt/mobile.py
Normal file
8
prompt/mobile.py
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
mobile_prompt = """
|
||||||
|
你正在为移动端用户回答问题。
|
||||||
|
|
||||||
|
请严格遵守以下输出规范:
|
||||||
|
|
||||||
|
1. 不要使用 Markdown 表格
|
||||||
|
2. 适合手机竖屏阅读
|
||||||
|
"""
|
||||||
12
services.py
12
services.py
@@ -1,9 +1,10 @@
|
|||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
from langchain_core.messages import HumanMessage, AIMessageChunk
|
from langchain_core.messages import HumanMessage, AIMessageChunk, SystemMessage, BaseMessage
|
||||||
|
|
||||||
from agent.bill import bill_agent
|
from agent.bill import bill_agent
|
||||||
from modes.agent import QueryRequest
|
from modes.agent import QueryRequest
|
||||||
|
from prompt.mobile import mobile_prompt
|
||||||
|
|
||||||
|
|
||||||
async def query_bill_agent(query: QueryRequest):
|
async def query_bill_agent(query: QueryRequest):
|
||||||
@@ -11,19 +12,22 @@ async def query_bill_agent(query: QueryRequest):
|
|||||||
print(query)
|
print(query)
|
||||||
today = datetime.today().strftime("%Y-%m-%d")
|
today = datetime.today().strftime("%Y-%m-%d")
|
||||||
|
|
||||||
message_content = (
|
date_content = (
|
||||||
f"[当前系统日期: {today}]\n\n"
|
f"[当前系统日期: {today}]\n\n"
|
||||||
f"{query.message}"
|
f"{query.message}"
|
||||||
)
|
)
|
||||||
|
|
||||||
message = HumanMessage(content=message_content)
|
messages: list[BaseMessage] = [HumanMessage(content=date_content)]
|
||||||
|
|
||||||
|
if query.platform == "mobile":
|
||||||
|
messages.insert(0, SystemMessage(content=mobile_prompt))
|
||||||
|
|
||||||
tool_called = False
|
tool_called = False
|
||||||
content_generate = False
|
content_generate = False
|
||||||
|
|
||||||
# 流式调用Agent
|
# 流式调用Agent
|
||||||
for chunk, metadata in bill_agent.stream(
|
for chunk, metadata in bill_agent.stream(
|
||||||
{"messages": [message]},
|
{"messages": messages},
|
||||||
stream_mode="messages"
|
stream_mode="messages"
|
||||||
):
|
):
|
||||||
# print(chunk)
|
# print(chunk)
|
||||||
|
|||||||
Reference in New Issue
Block a user