Skip to content

Commit

Permalink
Merge branch 'main' of github.com:homanp/superagent
Browse files Browse the repository at this point in the history
  • Loading branch information
homanp committed May 13, 2024
2 parents 0eb5cf5 + 4bf763b commit 2503f54
Show file tree
Hide file tree
Showing 15 changed files with 435 additions and 211 deletions.
5 changes: 4 additions & 1 deletion fern/apis/legacy/generators.yml
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
{}
api:
path: ./openapi/openapi.yaml
settings:
use-title: false
4 changes: 4 additions & 0 deletions fern/apis/prod/generators.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
api:
path: ./openapi/openapi.yaml
settings:
use-title: false
groups:
publish:
generators:
Expand Down
2 changes: 1 addition & 1 deletion fern/fern.config.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"organization": "superagent",
"version": "0.16.43"
"version": "0.26.3"
}
6 changes: 6 additions & 0 deletions libs/superagent/app/agents/base.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from abc import ABC, abstractmethod
from functools import cached_property
from typing import Any, List, Optional

from langchain.agents import AgentExecutor
Expand Down Expand Up @@ -78,6 +79,11 @@ def prompt(self) -> Any:
def tools(self) -> Any:
...

# TODO: Set a proper return type when we remove Langchain agent type
@cached_property
async def memory(self) -> Any:
...

@abstractmethod
def get_agent(self) -> AgentExecutor:
...
Expand Down
8 changes: 4 additions & 4 deletions libs/superagent/app/agents/langchain.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import datetime
from functools import cached_property

from decouple import config
from langchain.agents import AgentType, initialize_agent
Expand Down Expand Up @@ -62,9 +63,8 @@ def _get_llm(self):
max_tokens=llm_data.params.max_tokens,
)

async def _get_memory(
self,
) -> None | MotorheadMemory | ConversationBufferWindowMemory:
@cached_property
async def memory(self) -> None | MotorheadMemory | ConversationBufferWindowMemory:
# if memory is already set, in the main agent base class, return it
if not self.session_id:
raise ValueError("Session ID is required to initialize memory")
Expand Down Expand Up @@ -95,7 +95,7 @@ async def _get_memory(

async def get_agent(self):
llm = self._get_llm()
memory = await self._get_memory()
memory = await self.memory
tools = self.tools
prompt = self.prompt

Expand Down
Loading

0 comments on commit 2503f54

Please sign in to comment.