mirror of
https://github.com/langchain-ai/langgraph.git
synced 2026-08-24 16:42:24 +02:00
Merge branch 'main' into v1
This commit is contained in:
@@ -63,7 +63,7 @@ Next, add a "`chatbot`" node. **Nodes** represent units of work and are typicall
|
||||
|
||||
Let's first select a chat model:
|
||||
|
||||
{!snippets/chat_model_tabs.md!}
|
||||
{% include-markdown "../../../snippets/chat_model_tabs.md" %}
|
||||
|
||||
<!---
|
||||
```python
|
||||
|
||||
@@ -73,7 +73,7 @@ For the `StateGraph` you created in the [first tutorial](./1-build-basic-chatbot
|
||||
|
||||
Let's first select our LLM:
|
||||
|
||||
{!snippets/chat_model_tabs.md!}
|
||||
{% include-markdown "../../../snippets/chat_model_tabs.md" %}
|
||||
|
||||
<!---
|
||||
```python
|
||||
@@ -286,7 +286,7 @@ For ease of use, adjust your code to replace the following with LangGraph prebui
|
||||
- `BasicToolNode` is replaced with the prebuilt [ToolNode](https://langchain-ai.github.io/langgraph/reference/prebuilt/#toolnode)
|
||||
- `route_tools` is replaced with the prebuilt [tools_condition](https://langchain-ai.github.io/langgraph/reference/prebuilt/#tools_condition)
|
||||
|
||||
{!snippets/chat_model_tabs.md!}
|
||||
{% include-markdown "../../../snippets/chat_model_tabs.md" %}
|
||||
|
||||
|
||||
```python hl_lines="25 30"
|
||||
|
||||
@@ -154,7 +154,7 @@ The snapshot above contains the current state values, corresponding config, and
|
||||
|
||||
Check out the code snippet below to review the graph from this tutorial:
|
||||
|
||||
{!snippets/chat_model_tabs.md!}
|
||||
{% include-markdown "../../../snippets/chat_model_tabs.md" %}
|
||||
|
||||
<!---
|
||||
```python
|
||||
|
||||
@@ -14,7 +14,7 @@ Starting with the existing code from the [Add memory to the chatbot](./3-add-mem
|
||||
|
||||
Let's first select a chat model:
|
||||
|
||||
{!snippets/chat_model_tabs.md!}
|
||||
{% include-markdown "../../../snippets/chat_model_tabs.md" %}
|
||||
|
||||
<!---
|
||||
```python
|
||||
@@ -221,7 +221,7 @@ The input has been received and processed as a tool message. Review this call's
|
||||
|
||||
Check out the code snippet below to review the graph from this tutorial:
|
||||
|
||||
{!snippets/chat_model_tabs.md!}
|
||||
{% include-markdown "../../../snippets/chat_model_tabs.md" %}
|
||||
|
||||
```python
|
||||
from typing import Annotated
|
||||
|
||||
@@ -221,7 +221,7 @@ Manual state updates will [generate a trace](https://smith.langchain.com/public/
|
||||
|
||||
Check out the code snippet below to review the graph from this tutorial:
|
||||
|
||||
{!snippets/chat_model_tabs.md!}
|
||||
{% include-markdown "../../../snippets/chat_model_tabs.md" %}
|
||||
|
||||
<!---
|
||||
```python
|
||||
|
||||
@@ -14,7 +14,7 @@ You can create these types of experiences using LangGraph's built-in **time trav
|
||||
|
||||
Rewind your graph by fetching a checkpoint using the graph's `get_state_history` method. You can then resume execution at this previous point in time.
|
||||
|
||||
{!snippets/chat_model_tabs.md!}
|
||||
{% include-markdown "../../../snippets/chat_model_tabs.md" %}
|
||||
|
||||
<!---
|
||||
```python
|
||||
|
||||
@@ -540,11 +540,11 @@
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"================================\u001B[1m System Message \u001B[0m================================\n",
|
||||
"================================\u001b[1m System Message \u001b[0m================================\n",
|
||||
"\n",
|
||||
"Given a user query, create a plan to solve it with the utmost parallelizability. Each plan should comprise an action from the following \u001B[33;1m\u001B[1;3m{num_tools}\u001B[0m types:\n",
|
||||
"\u001B[33;1m\u001B[1;3m{tool_descriptions}\u001B[0m\n",
|
||||
"\u001B[33;1m\u001B[1;3m{num_tools}\u001B[0m. join(): Collects and combines results from prior actions.\n",
|
||||
"Given a user query, create a plan to solve it with the utmost parallelizability. Each plan should comprise an action from the following \u001b[33;1m\u001b[1;3m{num_tools}\u001b[0m types:\n",
|
||||
"\u001b[33;1m\u001b[1;3m{tool_descriptions}\u001b[0m\n",
|
||||
"\u001b[33;1m\u001b[1;3m{num_tools}\u001b[0m. join(): Collects and combines results from prior actions.\n",
|
||||
"\n",
|
||||
" - An LLM agent is called upon invoking join() to either finalize the user query or wait until the plans are executed.\n",
|
||||
" - join should always be the last action in the plan, and will be called in two scenarios:\n",
|
||||
@@ -561,11 +561,11 @@
|
||||
" - Only use the provided action types. If a query cannot be addressed using these, invoke the join action for the next steps.\n",
|
||||
" - Never introduce new actions other than the ones provided.\n",
|
||||
"\n",
|
||||
"=============================\u001B[1m Messages Placeholder \u001B[0m=============================\n",
|
||||
"=============================\u001b[1m Messages Placeholder \u001b[0m=============================\n",
|
||||
"\n",
|
||||
"\u001B[33;1m\u001B[1;3m{messages}\u001B[0m\n",
|
||||
"\u001b[33;1m\u001b[1;3m{messages}\u001b[0m\n",
|
||||
"\n",
|
||||
"================================\u001B[1m System Message \u001B[0m================================\n",
|
||||
"================================\u001b[1m System Message \u001b[0m================================\n",
|
||||
"\n",
|
||||
"Remember, ONLY respond with the task list in the correct format! E.g.:\n",
|
||||
"idx. tool(arg_name=args)\n",
|
||||
@@ -605,7 +605,7 @@
|
||||
" llm: BaseChatModel, tools: Sequence[BaseTool], base_prompt: ChatPromptTemplate\n",
|
||||
"):\n",
|
||||
" tool_descriptions = \"\\n\".join(\n",
|
||||
" f\"{i+1}. {tool.description}\\n\"\n",
|
||||
" f\"{i + 1}. {tool.description}\\n\"\n",
|
||||
" for i, tool in enumerate(\n",
|
||||
" tools\n",
|
||||
" ) # +1 to offset the 0 starting index, we want it count normally from 1.\n",
|
||||
|
||||
@@ -378,7 +378,7 @@
|
||||
"\n",
|
||||
"async def execute_step(state: PlanExecute):\n",
|
||||
" plan = state[\"plan\"]\n",
|
||||
" plan_str = \"\\n\".join(f\"{i+1}. {step}\" for i, step in enumerate(plan))\n",
|
||||
" plan_str = \"\\n\".join(f\"{i + 1}. {step}\" for i, step in enumerate(plan))\n",
|
||||
" task = plan[0]\n",
|
||||
" task_formatted = f\"\"\"For the following plan:\n",
|
||||
"{plan_str}\\n\\nYou are tasked with executing step {1}, {task}.\"\"\"\n",
|
||||
|
||||
@@ -302,7 +302,7 @@
|
||||
"def format_docs(docs: List[Doc]) -> str:\n",
|
||||
" xml_table = \"<conversations>\\n\"\n",
|
||||
" for doc in docs:\n",
|
||||
" xml_table += f'<conv_summ id={doc[\"id\"]}>{doc[\"summary\"]}</conv_summ>\\n'\n",
|
||||
" xml_table += f\"<conv_summ id={doc['id']}>{doc['summary']}</conv_summ>\\n\"\n",
|
||||
" xml_table += \"</conversations>\"\n",
|
||||
" return xml_table\n",
|
||||
"\n",
|
||||
@@ -311,9 +311,9 @@
|
||||
" xml = \"<cluster_table>\\n\"\n",
|
||||
" for label in clusters:\n",
|
||||
" xml += \" <cluster>\\n\"\n",
|
||||
" xml += f' <id>{label[\"id\"]}</id>\\n'\n",
|
||||
" xml += f' <name>{label[\"name\"]}</name>\\n'\n",
|
||||
" xml += f' <description>{label[\"description\"]}</description>\\n'\n",
|
||||
" xml += f\" <id>{label['id']}</id>\\n\"\n",
|
||||
" xml += f\" <name>{label['name']}</name>\\n\"\n",
|
||||
" xml += f\" <description>{label['description']}</description>\\n\"\n",
|
||||
" xml += \" </cluster>\\n\"\n",
|
||||
" xml += \"</cluster_table>\"\n",
|
||||
" return xml\n",
|
||||
@@ -600,13 +600,13 @@
|
||||
" turns.append(\n",
|
||||
" f\"\"\"\n",
|
||||
"<human idx={idx}>\n",
|
||||
"{run.inputs['question']}\n",
|
||||
"{run.inputs[\"question\"]}\n",
|
||||
"</human>\"\"\"\n",
|
||||
" )\n",
|
||||
" if run.outputs and run.outputs[\"output\"]:\n",
|
||||
" turns.append(\n",
|
||||
" f\"\"\"<ai idx={idx+1}>\n",
|
||||
"{run.outputs['output']}\n",
|
||||
" f\"\"\"<ai idx={idx + 1}>\n",
|
||||
"{run.outputs[\"output\"]}\n",
|
||||
"</ai>\"\"\"\n",
|
||||
" )\n",
|
||||
" return {\n",
|
||||
|
||||
Reference in New Issue
Block a user