-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* streaming and refactor * remove old code * save full response * fix thought not being passed * add tags * commonize the init * Refactor stream and save functionality to use async iterators - Refactored the `stream_and_save` function to use a new class, `Streamable`, which wraps the async iterator and saves the content on completion via a callback. - Updated the `think` and `respond` methods in the `BloomChain` class to return an instance of `Streamable` instead of string content. - Modified the `stream_and_save` function to iterate through the `thought_iterator` and `response_iterator` using `async for`, and update the placeholders with the received content. - Updated the `BloomChain` class to utilize the `Streamable` wrapper for the `think` and `respond` methods. - Updated the `stream_and_save` function to pass the correct arguments to the `think` and `respond` methods.
- Loading branch information
Showing
5 changed files
with
117 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import os | ||
from agent.cache import LRUCache | ||
from agent.chain import BloomChain | ||
|
||
|
||
def init(): | ||
CACHE = LRUCache(50) | ||
BLOOM_CHAIN = BloomChain() | ||
THOUGHT_CHANNEL = os.environ["THOUGHT_CHANNEL_ID"] | ||
TOKEN = os.environ['BOT_TOKEN'] | ||
|
||
return CACHE, BLOOM_CHAIN, (THOUGHT_CHANNEL, TOKEN) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters