Skip to content

Commit

Permalink
update how-tos
Browse files Browse the repository at this point in the history
  • Loading branch information
ccurme committed Nov 25, 2024
1 parent 04be284 commit 4acbc46
Show file tree
Hide file tree
Showing 3 changed files with 457 additions and 185 deletions.
15 changes: 12 additions & 3 deletions docs/docs/how_to/qa_chat_history_how_to.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -281,8 +281,17 @@
"# Step 3: Generate a response using the retrieved content.\n",
"def generate(state: MessagesState):\n",
" \"\"\"Generate answer.\"\"\"\n",
" last_message = state[\"messages\"][-1] # will be ToolMessage\n",
" docs_content = last_message.content # Retrieved context\n",
" # Get generated ToolMessages\n",
" recent_tool_messages = []\n",
" for message in reversed(state[\"messages\"]):\n",
" if message.type == \"tool\":\n",
" recent_tool_messages.append(message)\n",
" else:\n",
" break\n",
" tool_messages = recent_tool_messages[::-1]\n",
"\n",
" # Format into prompt\n",
" docs_content = \"\\n\\n\".join(doc.content for doc in tool_messages)\n",
" system_message_content = (\n",
" \"You are an assistant for question-answering tasks. \"\n",
" \"Use the following pieces of retrieved context to answer \"\n",
Expand Down Expand Up @@ -371,7 +380,7 @@
},
{
"cell_type": "code",
"execution_count": 13,
"execution_count": 12,
"id": "e59541dd-405b-4032-847f-73becf6aefd0",
"metadata": {},
"outputs": [
Expand Down
Loading

0 comments on commit 4acbc46

Please sign in to comment.