diff options
| author | Ben Sima <ben@bensima.com> | 2025-12-13 11:37:10 -0500 |
|---|---|---|
| committer | Ben Sima <ben@bensima.com> | 2025-12-13 11:37:10 -0500 |
| commit | 0936eb15144e2fc15b073e989d6c5d700dc47435 (patch) | |
| tree | 20e77aa1205dea43f398bf54deac12759fd54b7c /Omni/Agent/Provider.hs | |
| parent | ed629a3335c6c5a172322a8d7387f0c6990b0ae5 (diff) | |
Add knowledge graph with typed relations to Memory module
- Add RelationType with 6 relation types
- Add MemoryLink type and memory_links table
- Add graph functions: linkMemories, getMemoryLinks, queryGraph
- Add link_memories and query_graph agent tools
- Wire up graph tools to Telegram bot
- Include memory ID in recall results for linking
- Fix streaming usage parsing for cost tracking
Closes t-255
Amp-Thread-ID: https://ampcode.com/threads/T-019b181f-d6cd-70de-8857-c445baef7508
Co-authored-by: Amp <amp@ampcode.com>
Diffstat (limited to 'Omni/Agent/Provider.hs')
| -rw-r--r-- | Omni/Agent/Provider.hs | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/Omni/Agent/Provider.hs b/Omni/Agent/Provider.hs index fd6920d..1bb4f04 100644 --- a/Omni/Agent/Provider.hs +++ b/Omni/Agent/Provider.hs @@ -589,6 +589,11 @@ parseStreamChunk obj = do _ -> "Unknown error" Just (StreamError errMsg) _ -> do + let usageChunk = case KeyMap.lookup "usage" obj of + Just usageVal -> case Aeson.fromJSON usageVal of + Aeson.Success usage -> Just (StreamDone (ChatResult (Message Assistant "" Nothing Nothing) (Just usage))) + _ -> Nothing + _ -> Nothing case KeyMap.lookup "choices" obj of Just (Aeson.Array choices) | not (null choices) -> do case toList choices of @@ -603,15 +608,10 @@ parseStreamChunk obj = do | not (null tcs) -> parseToolCallDelta (toList tcs) _ -> Nothing - contentChunk <|> toolCallChunk - _ -> Nothing - _ -> Nothing - _ -> do - case KeyMap.lookup "usage" obj of - Just usageVal -> case Aeson.fromJSON usageVal of - Aeson.Success usage -> Just (StreamDone (ChatResult (Message Assistant "" Nothing Nothing) (Just usage))) - _ -> Nothing - _ -> Nothing + contentChunk <|> toolCallChunk <|> usageChunk + _ -> usageChunk + _ -> usageChunk + _ -> usageChunk parseToolCallDelta :: [Aeson.Value] -> Maybe StreamChunk parseToolCallDelta [] = Nothing |
