teleport/lib/ai
Hugo Shaka 2b15263e49
assist: Refactor token counting (#29224)
With the actor model, tokens can be used in multiple ways (picking
tools, invoking them, ...), which don't necessarily end up in a final
action (sometimes we return a nextStep instead). Streaming responses
were another challenge: the agent returned without the completion being
over (it returned a routine streaming the deltas sent by the model).

This PR introduces a TokenCounter interface that abstracts synchronous
and asynchronous token counting. All token-consuming operations must
return a TokenCounter. TokensCounters are stored in the agent state and
returned once the agent exists. Finally, the token counters are
evaluated asynchronously to give the streaming completion requests
enough time to finish.
2023-07-21 21:43:53 +00:00
..
model assist: Refactor token counting (#29224) 2023-07-21 21:43:53 +00:00
testutils assist: support recording non-interactive forwarded sessions (#28677) 2023-07-14 15:03:57 +00:00
chat.go assist: Refactor token counting (#29224) 2023-07-21 21:43:53 +00:00
chat_test.go assist: Refactor token counting (#29224) 2023-07-21 21:43:53 +00:00
client.go assist: support recording non-interactive forwarded sessions (#28677) 2023-07-14 15:03:57 +00:00
embedding.go [Assist] Include embeddings in the prompt (#28116) 2023-06-27 20:57:20 +00:00
embeddings.go [Assist] Provide interactive updates during agent execution (#27893) 2023-07-03 14:48:06 +00:00
embeddings_test.go [Assist] Include embeddings in the prompt (#28116) 2023-06-27 20:57:20 +00:00
knnretriever.go ai: Add a node embedding watcher (#27204) 2023-06-21 01:28:56 +00:00
knnretriever_test.go ai: Add a node embedding watcher (#27204) 2023-06-21 01:28:56 +00:00
simpleretriever.go [Assist] Include embeddings in the prompt (#28116) 2023-06-27 20:57:20 +00:00
simpleretriever_test.go [Assist] Include embeddings in the prompt (#28116) 2023-06-27 20:57:20 +00:00