chef_agent
This commit is contained in:
194
lg/approve.ipynb
Normal file
194
lg/approve.ipynb
Normal file
File diff suppressed because one or more lines are too long
75
lg/steam_out.ipynb
Normal file
75
lg/steam_out.ipynb
Normal file
@@ -0,0 +1,75 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "initial_id",
|
||||
"metadata": {
|
||||
"collapsed": true
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"from langgraph.graph import StateGraph, START, END, MessagesState\n",
|
||||
"from langchain.messages import HumanMessage\n",
|
||||
"from langchain_deepseek import ChatDeepSeek\n",
|
||||
"\n",
|
||||
"from core.config.settings import settings\n",
|
||||
"\n",
|
||||
"model = ChatDeepSeek(\n",
|
||||
" model=\"deepseek-v4-flash\",\n",
|
||||
" api_key=settings.DEEPSEEK_API_KEY,\n",
|
||||
" extra_body={\n",
|
||||
" \"thinking\": {\n",
|
||||
" \"type\": \"disabled\"\n",
|
||||
" }\n",
|
||||
" }\n",
|
||||
")\n",
|
||||
"\n",
|
||||
"def llm_node(state: MessagesState) -> MessagesState:\n",
|
||||
" messages = state[\"messages\"]\n",
|
||||
" response = model.invoke(messages)\n",
|
||||
"\n",
|
||||
" return {\n",
|
||||
" \"messages\": [response],\n",
|
||||
" }\n",
|
||||
"\n",
|
||||
"builder = StateGraph(state_schema=MessagesState)\n",
|
||||
"builder.add_node(\"llm_node\", llm_node)\n",
|
||||
"builder.add_edge(START, \"llm_node\")\n",
|
||||
"builder.add_edge(\"llm_node\", END)\n",
|
||||
"\n",
|
||||
"graph = builder.compile()\n",
|
||||
"\n",
|
||||
"# 使用流式输出\n",
|
||||
"for chunk in graph.stream(\n",
|
||||
" {\n",
|
||||
" \"messages\":[HumanMessage(content=\"你好!\")]\n",
|
||||
" },\n",
|
||||
" stream_mode=[\"values\",\"messages\"],\n",
|
||||
"):\n",
|
||||
" print(chunk)"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
},
|
||||
"language_info": {
|
||||
"codemirror_mode": {
|
||||
"name": "ipython",
|
||||
"version": 2
|
||||
},
|
||||
"file_extension": ".py",
|
||||
"mimetype": "text/x-python",
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython2",
|
||||
"version": "2.7.6"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 5
|
||||
}
|
||||
Reference in New Issue
Block a user