Skip to content

Commit

Permalink
Merge branch 'harrison/mongo-loader' into mongo-document-loader
Browse files Browse the repository at this point in the history
  • Loading branch information
saginawj committed Sep 13, 2023
2 parents 44ed72c + c48f130 commit 272c63c
Show file tree
Hide file tree
Showing 112 changed files with 9,083 additions and 2,588 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,9 @@ jobs:
fi
- name: Run ${{matrix.test_type}} tests
run: |
make test
if [ "${{ matrix.test_type }}" == "core" ]; then
make test
else
make extended_tests
fi
shell: bash
7 changes: 6 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.PHONY: all clean format lint test tests test_watch integration_tests docker_tests help
.PHONY: all clean format lint test tests test_watch integration_tests docker_tests help extended_tests

all: help

Expand Down Expand Up @@ -40,6 +40,9 @@ test:
tests:
poetry run pytest $(TEST_FILE)

extended_tests:
poetry run pytest --only-extended tests/unit_tests

test_watch:
poetry run ptw --now . -- tests/unit_tests

Expand All @@ -59,7 +62,9 @@ help:
@echo 'format - run code formatters'
@echo 'lint - run linters'
@echo 'test - run unit tests'
@echo 'test - run unit tests'
@echo 'test TEST_FILE=<test_file> - run all tests in file'
@echo 'extended_tests - run only extended unit tests'
@echo 'test_watch - run unit tests in watch mode'
@echo 'integration_tests - run integration tests'
@echo 'docker_tests - run unit tests in docker'
283 changes: 283 additions & 0 deletions docs/ecosystem/rebuff.ipynb

Large diffs are not rendered by default.

127 changes: 122 additions & 5 deletions docs/modules/agents/agents/examples/structured_chat.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 1,
"id": "ccc8ff98",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -98,7 +98,7 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 5,
"id": "4f4aa234-9746-47d8-bec7-d76081ac3ef6",
"metadata": {
"tags": []
Expand All @@ -111,9 +111,17 @@
"\n",
"\n",
"\u001b[1m> Entering new AgentExecutor chain...\u001b[0m\n",
"\u001b[32;1m\u001b[1;3mAction:\n",
"```\n",
"{\n",
" \"action\": \"Final Answer\",\n",
" \"action_input\": \"Hello Erica, how can I assist you today?\"\n",
"}\n",
"```\n",
"\u001b[0m\n",
"\n",
"\u001b[1m> Finished chain.\u001b[0m\n",
"Hi Erica! How can I assist you today?\n"
"Hello Erica, how can I assist you today?\n"
]
}
],
Expand Down Expand Up @@ -274,10 +282,119 @@
"print(response)"
]
},
{
"cell_type": "markdown",
"id": "42473442",
"metadata": {},
"source": [
"## Adding in memory\n",
"\n",
"Here is how you add in memory to this agent"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "b5a0dd2a",
"metadata": {},
"outputs": [],
"source": [
"from langchain.prompts import MessagesPlaceholder\n",
"from langchain.memory import ConversationBufferMemory"
]
},
{
"cell_type": "code",
"execution_count": 7,
"id": "91b9288f",
"metadata": {},
"outputs": [],
"source": [
"chat_history = MessagesPlaceholder(variable_name=\"chat_history\")\n",
"memory = ConversationBufferMemory(memory_key=\"chat_history\", return_messages=True)"
]
},
{
"cell_type": "code",
"execution_count": 8,
"id": "dba9e0d9",
"metadata": {},
"outputs": [],
"source": [
"agent_chain = initialize_agent(\n",
" tools, \n",
" llm, \n",
" agent=AgentType.STRUCTURED_CHAT_ZERO_SHOT_REACT_DESCRIPTION, \n",
" verbose=True, \n",
" memory=memory, \n",
" agent_kwargs = {\n",
" \"memory_prompts\": [chat_history],\n",
" \"input_variables\": [\"input\", \"agent_scratchpad\", \"chat_history\"]\n",
" }\n",
")"
]
},
{
"cell_type": "code",
"execution_count": 9,
"id": "a9509461",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
"\n",
"\u001b[1m> Entering new AgentExecutor chain...\u001b[0m\n",
"\u001b[32;1m\u001b[1;3mAction:\n",
"```\n",
"{\n",
" \"action\": \"Final Answer\",\n",
" \"action_input\": \"Hi Erica! How can I assist you today?\"\n",
"}\n",
"```\n",
"\u001b[0m\n",
"\n",
"\u001b[1m> Finished chain.\u001b[0m\n",
"Hi Erica! How can I assist you today?\n"
]
}
],
"source": [
"response = await agent_chain.arun(input=\"Hi I'm Erica.\")\n",
"print(response)"
]
},
{
"cell_type": "code",
"execution_count": 10,
"id": "412cedd2",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
"\n",
"\u001b[1m> Entering new AgentExecutor chain...\u001b[0m\n",
"\u001b[32;1m\u001b[1;3mYour name is Erica.\u001b[0m\n",
"\n",
"\u001b[1m> Finished chain.\u001b[0m\n",
"Your name is Erica.\n"
]
}
],
"source": [
"response = await agent_chain.arun(input=\"whats my name?\")\n",
"print(response)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "ebd7ae33-f67d-4378-ac79-9d91e0c8f53a",
"id": "9af1a713",
"metadata": {},
"outputs": [],
"source": []
Expand All @@ -299,7 +416,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.2"
"version": "3.9.1"
}
},
"nbformat": 4,
Expand Down
10 changes: 5 additions & 5 deletions docs/modules/agents/toolkits/examples/python.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": 4,
"id": "f98e9c90-5c37-4fb9-af3e-d09693af8543",
"metadata": {
"tags": []
Expand All @@ -27,7 +27,7 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 5,
"id": "cc422f53-c51c-4694-a834-72ecd1e68363",
"metadata": {
"tags": []
Expand Down Expand Up @@ -206,9 +206,9 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"display_name": "LangChain",
"language": "python",
"name": "python3"
"name": "langchain"
},
"language_info": {
"codemirror_mode": {
Expand All @@ -220,7 +220,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.1"
"version": "3.9.16"
}
},
"nbformat": 4,
Expand Down
Loading

0 comments on commit 272c63c

Please sign in to comment.