diff --git a/libs/superagent/.env.example b/libs/superagent/.env.example index 088b080bf..f5705ab6f 100644 --- a/libs/superagent/.env.example +++ b/libs/superagent/.env.example @@ -5,8 +5,7 @@ DATABASE_MIGRATION_URL= DATABASE_SHADOW_URL= # Mandatory for Neon DB JWT_SECRET= # Memory (mandatory) -MOTORHEAD_API_KEY= -MOTORHEAD_CLIENT_ID= +MEMORY_API_URL=https://memory.superagent.sh # Vectorstores (mandatory if you plan on loading datasources) PINECONE_ENVIRONMENT= PINECONE_API_KEY= diff --git a/libs/superagent/app/agents/base.py b/libs/superagent/app/agents/base.py index 4f5ae979c..d0b38dd74 100644 --- a/libs/superagent/app/agents/base.py +++ b/libs/superagent/app/agents/base.py @@ -92,10 +92,11 @@ async def _get_prompt(self, agent: Agent) -> SystemMessage: async def _get_memory(self) -> MotorheadMemory: memory = MotorheadMemory( - session_id=f"{self.agent_id}-{self.session_id}", + session_id=f"{self.agent_id}-{self.session_id}" + if self.session_id + else f"{self.agent_id}", memory_key="chat_history", - client_id=config("MOTORHEAD_CLIENT_ID"), - api_key=config("MOTORHEAD_API_KEY"), + url=config("MEMORY_API_URL"), return_messages=True, output_key="output", ) @@ -117,6 +118,7 @@ async def get_agent(self) -> Any: llm = await self._get_llm(agent_llm=config.llms[0], model=config.llmModel) prompt = await self._get_prompt(agent=config) memory = await self._get_memory() + if len(tools) > 0: agent = initialize_agent( tools, @@ -148,7 +150,6 @@ async def get_agent(self) -> Any: memory=memory, output_key="output", verbose=True, - return_final_only=True, prompt=PromptTemplate.from_template(prompt), ) return agent diff --git a/libs/superagent/poetry.lock b/libs/superagent/poetry.lock index 331eac2c2..ccf6b082e 100644 --- a/libs/superagent/poetry.lock +++ b/libs/superagent/poetry.lock @@ -1598,19 +1598,21 @@ yaml = ["pyyaml (>=6.0,<7.0)"] [[package]] name = "langchain" -version = "0.0.297" +version = "0.0.300" description = "Building applications with LLMs through composability" optional = false python-versions = ">=3.8.1,<4.0" files = [ - {file = "langchain-0.0.297-py3-none-any.whl", hash = "sha256:118141ebba33038d56c5362817ea64afa328f9b00fcedffea27afed70a0d675b"}, - {file = "langchain-0.0.297.tar.gz", hash = "sha256:d914cf7f98ade3d9172f0c25b2f8a2cc86ffc8b0d3eab7dfa82023ddcdb8ba4d"}, + {file = "langchain-0.0.300-py3-none-any.whl", hash = "sha256:ae84580a78c5f022cfd8b5be6642ec477a7d95c234ced49fa1c2d12c7e6d10c6"}, + {file = "langchain-0.0.300.tar.gz", hash = "sha256:c6337778928b56ce4f162f9ccba82212750b8a3ff2735085af5d7dac33f7901a"}, ] [package.dependencies] aiohttp = ">=3.8.3,<4.0.0" +anyio = "<4.0" async-timeout = {version = ">=4.0.0,<5.0.0", markers = "python_version < \"3.11\""} dataclasses-json = ">=0.5.7,<0.7" +jsonpatch = ">=1.33,<2.0" langsmith = ">=0.0.38,<0.1.0" numexpr = ">=2.8.4,<3.0.0" numpy = ">=1,<2" @@ -1627,7 +1629,7 @@ clarifai = ["clarifai (>=9.1.0)"] cohere = ["cohere (>=4,<5)"] docarray = ["docarray[hnswlib] (>=0.32.0,<0.33.0)"] embeddings = ["sentence-transformers (>=2,<3)"] -extended-testing = ["amazon-textract-caller (<2)", "assemblyai (>=0.17.0,<0.18.0)", "atlassian-python-api (>=3.36.0,<4.0.0)", "beautifulsoup4 (>=4,<5)", "bibtexparser (>=1.4.0,<2.0.0)", "cassio (>=0.1.0,<0.2.0)", "chardet (>=5.1.0,<6.0.0)", "dashvector (>=1.0.1,<2.0.0)", "esprima (>=4.0.1,<5.0.0)", "faiss-cpu (>=1,<2)", "feedparser (>=6.0.10,<7.0.0)", "geopandas (>=0.13.1,<0.14.0)", "gitpython (>=3.1.32,<4.0.0)", "gql (>=3.4.1,<4.0.0)", "html2text (>=2020.1.16,<2021.0.0)", "jinja2 (>=3,<4)", "jq (>=1.4.1,<2.0.0)", "lxml (>=4.9.2,<5.0.0)", "markdownify (>=0.11.6,<0.12.0)", "mwparserfromhell (>=0.6.4,<0.7.0)", "mwxml (>=0.3.3,<0.4.0)", "newspaper3k (>=0.2.8,<0.3.0)", "openai (>=0,<1)", "openapi-schema-pydantic (>=1.2,<2.0)", "pandas (>=2.0.1,<3.0.0)", "pdfminer-six (>=20221105,<20221106)", "pgvector (>=0.1.6,<0.2.0)", "psychicapi (>=0.8.0,<0.9.0)", "py-trello (>=0.19.0,<0.20.0)", "pymupdf (>=1.22.3,<2.0.0)", "pypdf (>=3.4.0,<4.0.0)", "pypdfium2 (>=4.10.0,<5.0.0)", "pyspark (>=3.4.0,<4.0.0)", "rank-bm25 (>=0.2.2,<0.3.0)", "rapidfuzz (>=3.1.1,<4.0.0)", "requests-toolbelt (>=1.0.0,<2.0.0)", "scikit-learn (>=1.2.2,<2.0.0)", "sqlite-vss (>=0.1.2,<0.2.0)", "streamlit (>=1.18.0,<2.0.0)", "sympy (>=1.12,<2.0)", "telethon (>=1.28.5,<2.0.0)", "tqdm (>=4.48.0)", "xata (>=1.0.0a7,<2.0.0)", "xmltodict (>=0.13.0,<0.14.0)"] +extended-testing = ["amazon-textract-caller (<2)", "assemblyai (>=0.17.0,<0.18.0)", "atlassian-python-api (>=3.36.0,<4.0.0)", "beautifulsoup4 (>=4,<5)", "bibtexparser (>=1.4.0,<2.0.0)", "cassio (>=0.1.0,<0.2.0)", "chardet (>=5.1.0,<6.0.0)", "dashvector (>=1.0.1,<2.0.0)", "esprima (>=4.0.1,<5.0.0)", "faiss-cpu (>=1,<2)", "feedparser (>=6.0.10,<7.0.0)", "geopandas (>=0.13.1,<0.14.0)", "gitpython (>=3.1.32,<4.0.0)", "gql (>=3.4.1,<4.0.0)", "html2text (>=2020.1.16,<2021.0.0)", "jinja2 (>=3,<4)", "jq (>=1.4.1,<2.0.0)", "lxml (>=4.9.2,<5.0.0)", "markdownify (>=0.11.6,<0.12.0)", "mwparserfromhell (>=0.6.4,<0.7.0)", "mwxml (>=0.3.3,<0.4.0)", "newspaper3k (>=0.2.8,<0.3.0)", "openai (>=0,<1)", "openapi-schema-pydantic (>=1.2,<2.0)", "pandas (>=2.0.1,<3.0.0)", "pdfminer-six (>=20221105,<20221106)", "pgvector (>=0.1.6,<0.2.0)", "psychicapi (>=0.8.0,<0.9.0)", "py-trello (>=0.19.0,<0.20.0)", "pymupdf (>=1.22.3,<2.0.0)", "pypdf (>=3.4.0,<4.0.0)", "pypdfium2 (>=4.10.0,<5.0.0)", "pyspark (>=3.4.0,<4.0.0)", "rank-bm25 (>=0.2.2,<0.3.0)", "rapidfuzz (>=3.1.1,<4.0.0)", "requests-toolbelt (>=1.0.0,<2.0.0)", "scikit-learn (>=1.2.2,<2.0.0)", "sqlite-vss (>=0.1.2,<0.2.0)", "streamlit (>=1.18.0,<2.0.0)", "sympy (>=1.12,<2.0)", "telethon (>=1.28.5,<2.0.0)", "timescale-vector (>=0.0.1,<0.0.2)", "tqdm (>=4.48.0)", "xata (>=1.0.0a7,<2.0.0)", "xmltodict (>=0.13.0,<0.14.0)"] javascript = ["esprima (>=4.0.1,<5.0.0)"] llms = ["clarifai (>=9.1.0)", "cohere (>=4,<5)", "huggingface_hub (>=0,<1)", "manifest-ml (>=0.0.1,<0.0.2)", "nlpcloud (>=1,<2)", "openai (>=0,<1)", "openlm (>=0.0.5,<0.0.6)", "torch (>=1,<3)", "transformers (>=4,<5)"] openai = ["openai (>=0,<1)", "tiktoken (>=0.3.2,<0.4.0)"] @@ -4545,4 +4547,4 @@ testing = ["big-O", "jaraco.functools", "jaraco.itertools", "more-itertools", "p [metadata] lock-version = "2.0" python-versions = "^3.9" -content-hash = "762e709c0cab023742d2587ae10da70e8abb0d376dfa96f32dd6a0c4d890057f" +content-hash = "a2c708fb2fbb44c09303a9fdb19d54277c7c975897bc29025e37511e9f25f19c" diff --git a/libs/superagent/pyproject.toml b/libs/superagent/pyproject.toml index b5bca32db..0783fbf33 100644 --- a/libs/superagent/pyproject.toml +++ b/libs/superagent/pyproject.toml @@ -43,9 +43,9 @@ openpyxl = "^3.1.2" unstructured = "^0.10.16" python-docx = "^0.8.11" langsmith = "^0.0.39" -langchain = "^0.0.297" requests = "^2.31.0" wolframalpha = "^5.0.0" +langchain = "^0.0.300" [build-system]