Skip to content

Commit e9ad74a

Browse files
committed
fix: async cache
1 parent 4cdb9f2 commit e9ad74a

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

openagent/executors/project_executor.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
from typing import Optional, Type
55

66
import aiohttp
7-
from cachetools import TTLCache, cached
7+
from aiocache import Cache
8+
from aiocache.decorators import cached
89
from langchain.callbacks.manager import (
910
AsyncCallbackManagerForToolRun,
1011
CallbackManagerForToolRun,
@@ -21,8 +22,6 @@
2122
"Content-Type": "application/json",
2223
}
2324

24-
cache = TTLCache(maxsize=100, ttl=24 * 60 * 60)
25-
2625

2726
class ARGS(BaseModel):
2827
keyword: str = Field(description="keyword")
@@ -70,7 +69,7 @@ async def fetch_project_detail(session, project_id: int) -> dict:
7069
return json.loads(response_text)["data"]
7170

7271

73-
@cached(cache)
72+
@cached(ttl=300, cache=Cache.MEMORY)
7473
async def fetch_project(keyword: str) -> list:
7574
url = "https://api.rootdata.com/open/ser_inv"
7675
payload = json.dumps({"query": keyword, "variables": {}})

0 commit comments

Comments
 (0)