mirror of
https://github.com/hwchase17/langchain.git
synced 2025-07-01 10:54:15 +00:00
docs: format (#17143)
This commit is contained in:
parent
2187268208
commit
d397721a34
@ -90,16 +90,20 @@
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"system = \"You are a helpful assistant that translates {input_language} to {output_language}.\"\n",
|
||||
"system = (\n",
|
||||
" \"You are a helpful assistant that translates {input_language} to {output_language}.\"\n",
|
||||
")\n",
|
||||
"human = \"{text}\"\n",
|
||||
"prompt = ChatPromptTemplate.from_messages([(\"system\", system), (\"human\", human)])\n",
|
||||
"\n",
|
||||
"chain = prompt | chat\n",
|
||||
"chain.invoke({\n",
|
||||
"chain.invoke(\n",
|
||||
" {\n",
|
||||
" \"input_language\": \"English\",\n",
|
||||
" \"output_language\": \"Korean\",\n",
|
||||
" \"text\": \"I love Python\",\n",
|
||||
"})"
|
||||
" }\n",
|
||||
")"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
@ -424,9 +424,7 @@
|
||||
"human = \"{text}\"\n",
|
||||
"prompt = ChatPromptTemplate.from_messages([(\"system\", system), (\"human\", human)])\n",
|
||||
"\n",
|
||||
"chat = ChatVertexAI(\n",
|
||||
" model_name=\"chat-bison\", max_output_tokens=1000, temperature=0.5\n",
|
||||
")\n",
|
||||
"chat = ChatVertexAI(model_name=\"chat-bison\", max_output_tokens=1000, temperature=0.5)\n",
|
||||
"chain = prompt | chat\n",
|
||||
"\n",
|
||||
"asyncio.run(\n",
|
||||
|
@ -460,9 +460,7 @@
|
||||
"Given a user question, write the Python code to answer it. \\\n",
|
||||
"Return ONLY the valid Python code and nothing else. \\\n",
|
||||
"Don't assume you have access to any libraries other than built-in Python ones and pandas.\"\"\"\n",
|
||||
"prompt = ChatPromptTemplate.from_messages(\n",
|
||||
" [(\"system\", system), (\"human\", \"{question}\")]\n",
|
||||
")\n",
|
||||
"prompt = ChatPromptTemplate.from_messages([(\"system\", system), (\"human\", \"{question}\")])\n",
|
||||
"code_chain = prompt | llm_with_tools | parser\n",
|
||||
"code_chain.invoke({\"question\": \"What's the correlation between age and fare\"})"
|
||||
]
|
||||
|
@ -721,7 +721,9 @@
|
||||
"\n",
|
||||
"If the question does not seem related to the database, just return \"I don't know\" as the answer.\"\"\"\n",
|
||||
"\n",
|
||||
"prompt = ChatPromptTemplate.from_messages([(\"system\", system), (\"human\", \"{input}\"), MessagesPlaceholder(\"agent_scratchpad\")])\n",
|
||||
"prompt = ChatPromptTemplate.from_messages(\n",
|
||||
" [(\"system\", system), (\"human\", \"{input}\"), MessagesPlaceholder(\"agent_scratchpad\")]\n",
|
||||
")\n",
|
||||
"agent = create_sql_agent(\n",
|
||||
" llm=llm,\n",
|
||||
" db=db,\n",
|
||||
|
@ -294,11 +294,15 @@
|
||||
"First draft: <<FIRST_DRAFT_QUERY>>\n",
|
||||
"Final answer: <<FINAL_ANSWER_QUERY>>\n",
|
||||
"\"\"\"\n",
|
||||
"prompt = ChatPromptTemplate.from_messages([(\"system\", system), (\"human\", \"{input}\")]).partial(dialect=db.dialect)\n",
|
||||
"prompt = ChatPromptTemplate.from_messages(\n",
|
||||
" [(\"system\", system), (\"human\", \"{input}\")]\n",
|
||||
").partial(dialect=db.dialect)\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"def parse_final_answer(output: str) -> str:\n",
|
||||
" return output.split(\"Final answer: \")[1]\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"chain = create_sql_query_chain(llm, db, prompt=prompt) | parse_final_answer\n",
|
||||
"prompt.pretty_print()"
|
||||
]
|
||||
|
Loading…
Reference in New Issue
Block a user