Skip to content

Commit

Permalink
[Doc] Improvement: Fix docs of ChatMLX (#28884)
Browse files Browse the repository at this point in the history
- `ChatMLX` doesn't supports the role of system.
- Fix #28532
#28532
  • Loading branch information
ZhangShenao authored Dec 23, 2024
1 parent 41b6a86 commit 4b4d09f
Showing 1 changed file with 43 additions and 3 deletions.
46 changes: 43 additions & 3 deletions docs/docs/integrations/chat/mlx.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,48 @@
"tools = load_tools([\"serpapi\", \"llm-math\"], llm=llm)\n",
"\n",
"# setup ReAct style prompt\n",
"prompt = hub.pull(\"hwchase17/react-json\")\n",
"prompt = prompt.partial(\n",
"# Based on 'hwchase17/react' prompt modification, cause mlx does not support the `System` role\n",
"human_prompt = \"\"\"\n",
"Answer the following questions as best you can. You have access to the following tools:\n",
"\n",
"{tools}\n",
"\n",
"The way you use the tools is by specifying a json blob.\n",
"Specifically, this json should have a `action` key (with the name of the tool to use) and a `action_input` key (with the input to the tool going here).\n",
"\n",
"The only values that should be in the \"action\" field are: {tool_names}\n",
"\n",
"The $JSON_BLOB should only contain a SINGLE action, do NOT return a list of multiple actions. Here is an example of a valid $JSON_BLOB:\n",
"\n",
"```\n",
"{{\n",
" \"action\": $TOOL_NAME,\n",
" \"action_input\": $INPUT\n",
"}}\n",
"```\n",
"\n",
"ALWAYS use the following format:\n",
"\n",
"Question: the input question you must answer\n",
"Thought: you should always think about what to do\n",
"Action:\n",
"```\n",
"$JSON_BLOB\n",
"```\n",
"Observation: the result of the action\n",
"... (this Thought/Action/Observation can repeat N times)\n",
"Thought: I now know the final answer\n",
"Final Answer: the final answer to the original input question\n",
"\n",
"Begin! Reminder to always use the exact characters `Final Answer` when responding.\n",
"\n",
"{input}\n",
"\n",
"{agent_scratchpad}\n",
"\n",
"\"\"\"\n",
"\n",
"prompt = human_prompt.partial(\n",
" tools=render_text_description(tools),\n",
" tool_names=\", \".join([t.name for t in tools]),\n",
")\n",
Expand Down Expand Up @@ -207,7 +247,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.18"
"version": "3.12.7"
}
},
"nbformat": 4,
Expand Down

0 comments on commit 4b4d09f

Please sign in to comment.