news memory + get_news tool (news-07..12): feed summaries, deduped rolling store (schema v6), on-demand filtered retrieval
This commit is contained in:
@@ -14,6 +14,7 @@ from .codex import DEFAULT_LIMIT as CODEX_DEFAULT_LIMIT
|
||||
from .codex import CodexSearch
|
||||
from .igdblib import IGDBQuery
|
||||
from .leonardo_draw import LeonardoAIDrawMixIn
|
||||
from .news import GET_NEWS_TOOL, query_news
|
||||
from .quota import QuotaLedger
|
||||
from .url_reader import FETCH_URL_TOOL, URLReader
|
||||
|
||||
@@ -180,6 +181,8 @@ class OpenAIResponder(AIResponder, LeonardoAIDrawMixIn):
|
||||
functions.append(FETCH_URL_TOOL)
|
||||
if self.codex.enabled(): # CDX-01
|
||||
functions.append(CODEX_SEARCH_TOOL)
|
||||
if self.config.get("enable-news-tool", False) and self.store is not None: # NEWS-10
|
||||
functions.append(GET_NEWS_TOOL)
|
||||
return functions
|
||||
|
||||
async def _dispatch_tool(self, name: str, args: Dict[str, Any], author: str) -> Any:
|
||||
@@ -197,6 +200,13 @@ class OpenAIResponder(AIResponder, LeonardoAIDrawMixIn):
|
||||
self.ledger._add(f"codex:{author}", 1)
|
||||
limit = int(self.config.get("codex-limit", CODEX_DEFAULT_LIMIT))
|
||||
return await self.codex.search(str(args.get("query", "")), str(args.get("lang", "en")), limit)
|
||||
if name == "get_news":
|
||||
per_user_cap = int(self.config.get("news-daily-per-user", 30))
|
||||
if self.ledger._get(f"news:{author}") >= per_user_cap: # NEWS-12
|
||||
return {"error": "daily news lookup limit reached"}
|
||||
self.ledger._add(f"news:{author}", 1)
|
||||
summary_chars = int(self.config.get("news-summary-chars", 200))
|
||||
return query_news(self.store, args.get("topic"), args.get("source"), args.get("limit", 10), summary_chars)
|
||||
return await self._execute_igdb_function(name, args)
|
||||
|
||||
async def draw_openai(self, description: str, count: int = 1) -> List[BytesIO]:
|
||||
|
||||
Reference in New Issue
Block a user