Skip to content

Commit

Permalink
Merge branch 'langchain-ai:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
gitchrisqueen authored Jan 2, 2024
2 parents 8f17ad1 + 5a43e0e commit 5b26987
Show file tree
Hide file tree
Showing 319 changed files with 16,837 additions and 19,392 deletions.
2 changes: 1 addition & 1 deletion .github/actions/poetry_setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ inputs:
runs:
using: composite
steps:
- uses: actions/setup-python@v4
- uses: actions/setup-python@v5
name: Setup python ${{ inputs.python-version }}
with:
python-version: ${{ inputs.python-version }}
Expand Down
7 changes: 1 addition & 6 deletions .github/workflows/check_diffs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,6 @@ on:
push:
branches: [master]
pull_request:
paths:
- ".github/actions/**"
- ".github/tools/**"
- ".github/workflows/**"
- "libs/**"

# If another push to the same PR or branch happens while this workflow is still running,
# cancel the earlier run in favor of the next run.
Expand All @@ -26,7 +21,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
- uses: actions/setup-python@v5
with:
python-version: '3.10'
- id: files
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/scheduled_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:

- name: 'Authenticate to Google Cloud'
id: 'auth'
uses: 'google-github-actions/auth@v1'
uses: google-github-actions/auth@v2
with:
credentials_json: '${{ secrets.GOOGLE_CREDENTIALS }}'

Expand Down
2 changes: 1 addition & 1 deletion .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ build:
tools:
python: "3.11"
commands:
- python -mvirtualenv $READTHEDOCS_VIRTUALENV_PATH
- python -m virtualenv $READTHEDOCS_VIRTUALENV_PATH
- python -m pip install --upgrade --no-cache-dir pip setuptools
- python -m pip install --upgrade --no-cache-dir sphinx readthedocs-sphinx-ext
- python -m pip install ./libs/partners/*
Expand Down
3 changes: 2 additions & 1 deletion cookbook/LLaMA2_sql_chat.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@
"id": "654b3577-baa2-4e12-a393-f40e5db49ac7",
"metadata": {},
"source": [
"## Query a SQL DB \n",
"## Query a SQL Database \n",
"\n",
"Follow the runnables workflow [here](https://python.langchain.com/docs/expression_language/cookbook/sql_db)."
]
Expand All @@ -151,6 +151,7 @@
"# Prompt\n",
"from langchain.prompts import ChatPromptTemplate\n",
"\n",
"# Update the template based on the type of SQL Database like MySQL, Microsoft SQL Server and so on\n",
"template = \"\"\"Based on the table schema below, write a SQL query that would answer the user's question:\n",
"{schema}\n",
"\n",
Expand Down
2 changes: 1 addition & 1 deletion cookbook/Multi_modal_RAG.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@
"Add raw docs and doc summaries to [Multi Vector Retriever](https://python.langchain.com/docs/modules/data_connection/retrievers/multi_vector#summary): \n",
"\n",
"* Store the raw texts, tables, and images in the `docstore`.\n",
"* Store the texts, table summaries, and image summaries in the `vectorstore` for semantic retrieval."
"* Store the texts, table summaries, and image summaries in the `vectorstore` for efficient semantic retrieval."
]
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"id": "9b22020a",
"metadata": {},
Expand Down Expand Up @@ -146,7 +145,6 @@
"source": []
},
{
"attachments": {},
"cell_type": "markdown",
"id": "c0a6c031",
"metadata": {},
Expand Down Expand Up @@ -280,7 +278,6 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"id": "787a9b5e",
"metadata": {},
Expand All @@ -289,7 +286,6 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"id": "9161ba91",
"metadata": {},
Expand Down Expand Up @@ -411,7 +407,6 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"id": "49a0cbbe",
"metadata": {},
Expand Down Expand Up @@ -525,7 +520,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.3"
"version": "3.10.1"
}
},
"nbformat": 4,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
"source": [
"# Custom agent with tool retrieval\n",
"\n",
"This notebook builds off of [this notebook](/docs/modules/agents/how_to/custom_llm_agent) and assumes familiarity with how agents work.\n",
"\n",
"The novel idea introduced in this notebook is the idea of using retrieval to select the set of tools to use to answer an agent query. This is useful when you have many many tools to select from. You cannot put the description of all the tools in the prompt (because of context length issues) so instead you dynamically select the N tools you do want to consider using at run time.\n",
"\n",
"In this notebook we will create a somewhat contrived example. We will have one legitimate tool (search) and then 99 fake tools which are just nonsense. We will then add a step in the prompt template that takes the user input and retrieves tool relevant to the query."
Expand Down Expand Up @@ -489,7 +487,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.3"
"version": "3.10.1"
},
"vscode": {
"interpreter": {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
44 changes: 22 additions & 22 deletions docs/docs/expression_language/cookbook/agent.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,20 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": 8,
"id": "af4381de",
"metadata": {},
"outputs": [],
"source": [
"from langchain.agents import AgentExecutor, XMLAgent, tool\n",
"from langchain import hub\n",
"from langchain.agents import AgentExecutor, tool\n",
"from langchain.agents.output_parsers import XMLAgentOutputParser\n",
"from langchain.chat_models import ChatAnthropic"
]
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 3,
"id": "24cc8134",
"metadata": {},
"outputs": [],
Expand All @@ -33,7 +35,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 4,
"id": "67c0b0e4",
"metadata": {},
"outputs": [],
Expand All @@ -46,7 +48,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 5,
"id": "7203b101",
"metadata": {},
"outputs": [],
Expand All @@ -56,18 +58,18 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 6,
"id": "b68e756d",
"metadata": {},
"outputs": [],
"source": [
"# Get prompt to use\n",
"prompt = XMLAgent.get_default_prompt()"
"# Get the prompt to use - you can modify this!\n",
"prompt = hub.pull(\"hwchase17/xml-agent-convo\")"
]
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 7,
"id": "61ab3e9a",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -107,27 +109,27 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 12,
"id": "e92f1d6f",
"metadata": {},
"outputs": [],
"source": [
"agent = (\n",
" {\n",
" \"question\": lambda x: x[\"question\"],\n",
" \"intermediate_steps\": lambda x: convert_intermediate_steps(\n",
" \"input\": lambda x: x[\"input\"],\n",
" \"agent_scratchpad\": lambda x: convert_intermediate_steps(\n",
" x[\"intermediate_steps\"]\n",
" ),\n",
" }\n",
" | prompt.partial(tools=convert_tools(tool_list))\n",
" | model.bind(stop=[\"</tool_input>\", \"</final_answer>\"])\n",
" | XMLAgent.get_default_output_parser()\n",
" | XMLAgentOutputParser()\n",
")"
]
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": 13,
"id": "6ce6ec7a",
"metadata": {},
"outputs": [],
Expand All @@ -137,7 +139,7 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": 14,
"id": "fb5cb2e3",
"metadata": {},
"outputs": [
Expand All @@ -148,28 +150,26 @@
"\n",
"\n",
"\u001b[1m> Entering new AgentExecutor chain...\u001b[0m\n",
"\u001b[32;1m\u001b[1;3m <tool>search</tool>\n",
"<tool_input>weather in new york\u001b[0m\u001b[36;1m\u001b[1;3m32 degrees\u001b[0m\u001b[32;1m\u001b[1;3m\n",
"\n",
"<final_answer>The weather in New York is 32 degrees\u001b[0m\n",
"\u001b[32;1m\u001b[1;3m <tool>search</tool><tool_input>weather in New York\u001b[0m\u001b[36;1m\u001b[1;3m32 degrees\u001b[0m\u001b[32;1m\u001b[1;3m <tool>search</tool>\n",
"<tool_input>weather in New York\u001b[0m\u001b[36;1m\u001b[1;3m32 degrees\u001b[0m\u001b[32;1m\u001b[1;3m <final_answer>The weather in New York is 32 degrees\u001b[0m\n",
"\n",
"\u001b[1m> Finished chain.\u001b[0m\n"
]
},
{
"data": {
"text/plain": [
"{'question': 'whats the weather in New york?',\n",
"{'input': 'whats the weather in New york?',\n",
" 'output': 'The weather in New York is 32 degrees'}"
]
},
"execution_count": 9,
"execution_count": 14,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"agent_executor.invoke({\"question\": \"whats the weather in New york?\"})"
"agent_executor.invoke({\"input\": \"whats the weather in New york?\"})"
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/expression_language/how_to/passthrough.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
"\n",
"In the second line, we used `RunnablePastshrough.assign` with a lambda that multiplies the numerical value by 3. In this cased, `extra` was set with `{'num': 1, 'mult': 3}` which is the original value with the `mult` key added. \n",
"\n",
"Finally, we also set a third key in the map with `modified` which uses a labmda to set a single value adding 1 to the num, which resulted in `modified` key with the value of `2`."
"Finally, we also set a third key in the map with `modified` which uses a lambda to set a single value adding 1 to the num, which resulted in `modified` key with the value of `2`."
]
},
{
Expand Down
Loading

0 comments on commit 5b26987

Please sign in to comment.