summaryrefslogtreecommitdiff
path: root/Omni/Agent/Telegram.hs
diff options
context:
space:
mode:
Diffstat (limited to 'Omni/Agent/Telegram.hs')
-rw-r--r--Omni/Agent/Telegram.hs17
1 files changed, 10 insertions, 7 deletions
diff --git a/Omni/Agent/Telegram.hs b/Omni/Agent/Telegram.hs
index d224acc..c55dc5a 100644
--- a/Omni/Agent/Telegram.hs
+++ b/Omni/Agent/Telegram.hs
@@ -83,6 +83,7 @@ import qualified Omni.Agent.Tools.Calendar as Calendar
import qualified Omni.Agent.Tools.Notes as Notes
import qualified Omni.Agent.Tools.Pdf as Pdf
import qualified Omni.Agent.Tools.Todos as Todos
+import qualified Omni.Agent.Tools.WebReader as WebReader
import qualified Omni.Agent.Tools.WebSearch as WebSearch
import qualified Omni.Test as Test
import System.Environment (lookupEnv)
@@ -423,6 +424,7 @@ handleAuthorizedMessage tgConfig provider engineCfg msg uid userName chatId = do
searchTools = case Types.tgKagiApiKey tgConfig of
Just kagiKey -> [WebSearch.webSearchTool kagiKey]
Nothing -> []
+ webReaderTools = [WebReader.webReaderTool (Types.tgOpenRouterApiKey tgConfig)]
pdfTools = [Pdf.pdfTool]
notesTools =
[ Notes.noteAddTool uid,
@@ -440,7 +442,7 @@ handleAuthorizedMessage tgConfig provider engineCfg msg uid userName chatId = do
Todos.todoCompleteTool uid,
Todos.todoDeleteTool uid
]
- tools = memoryTools <> searchTools <> pdfTools <> notesTools <> calendarTools <> todoTools
+ tools = memoryTools <> searchTools <> webReaderTools <> pdfTools <> notesTools <> calendarTools <> todoTools
let agentCfg =
Engine.defaultAgentConfig
@@ -472,7 +474,7 @@ handleAuthorizedMessage tgConfig provider engineCfg msg uid userName chatId = do
sendMessage tgConfig chatId "hmm, i don't have a response for that"
else sendMessage tgConfig chatId response
- checkAndSummarize provider uid chatId
+ checkAndSummarize (Types.tgOpenRouterApiKey tgConfig) uid chatId
putText
<| "Responded to "
@@ -487,8 +489,8 @@ maxConversationTokens = 4000
summarizationThreshold :: Int
summarizationThreshold = 3000
-checkAndSummarize :: Provider.Provider -> Text -> Int -> IO ()
-checkAndSummarize provider uid chatId = do
+checkAndSummarize :: Text -> Text -> Int -> IO ()
+checkAndSummarize openRouterKey uid chatId = do
(_, currentTokens) <- Memory.getConversationContext uid chatId maxConversationTokens
when (currentTokens > summarizationThreshold) <| do
putText <| "Context at " <> tshow currentTokens <> " tokens, summarizing..."
@@ -498,9 +500,10 @@ checkAndSummarize provider uid chatId = do
[ (if Memory.cmRole m == Memory.UserRole then "User: " else "Assistant: ") <> Memory.cmContent m
| m <- reverse recentMsgs
]
+ gemini = Provider.defaultOpenRouter openRouterKey "google/gemini-2.0-flash-001"
summaryResult <-
Provider.chat
- provider
+ gemini
[]
[ Provider.Message Provider.System "You are a conversation summarizer. Summarize the key points, decisions, and context from this conversation in 2-3 paragraphs. Focus on information that would be useful for continuing the conversation later." Nothing Nothing,
Provider.Message Provider.User ("Summarize this conversation:\n\n" <> conversationText) Nothing Nothing
@@ -510,7 +513,7 @@ checkAndSummarize provider uid chatId = do
Right summaryMsg -> do
let summary = Provider.msgContent summaryMsg
_ <- Memory.summarizeAndArchive uid chatId summary
- putText "Conversation summarized and archived"
+ putText "Conversation summarized and archived (gemini)"
checkOllama :: IO (Either Text ())
checkOllama = do
@@ -610,7 +613,7 @@ startBot maybeToken = do
Just key -> do
let orKey = Text.pack key
tgConfig = Types.defaultTelegramConfig token allowedIds kagiKey orKey
- provider = Provider.defaultOpenRouter orKey "anthropic/claude-sonnet-4"
+ provider = Provider.defaultOpenRouter orKey "anthropic/claude-sonnet-4.5"
putText <| "Allowed user IDs: " <> tshow allowedIds
putText <| "Kagi search: " <> if isJust kagiKey then "enabled" else "disabled"
runTelegramBot tgConfig provider