Skip to content

Commit

Permalink
revie streaming PR
Browse files Browse the repository at this point in the history
  • Loading branch information
pieroit committed Oct 17, 2023
1 parent 2c6271c commit 0b1a269
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions core/cat/looking_glass/agent_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,16 @@
from langchain.docstore.document import Document
from langchain.prompts import PromptTemplate
from langchain.chains import LLMChain
from langchain.callbacks.base import BaseCallbackHandler
from langchain.agents import AgentExecutor, LLMSingleActionAgent

from cat.looking_glass import prompts
from cat.looking_glass.output_parser import ToolOutputParser
from cat.utils import verbal_timedelta
from cat.log import log
from langchain.callbacks.streaming_stdout import StreamingStdOutCallbackHandler
from langchain.callbacks.base import BaseCallbackHandler


class MyCustomHandler(BaseCallbackHandler):
class NewTokenHandler(BaseCallbackHandler):

def __init__(self, cat):
self.cat = cat
Expand Down Expand Up @@ -94,7 +93,7 @@ def execute_memory_chain(self, agent_input, prompt_prefix, prompt_suffix):
verbose=True
)

out = memory_chain(agent_input, callbacks=[MyCustomHandler(self.cat)])
out = memory_chain(agent_input, callbacks=[NewTokenHandler(self.cat)])
out["output"] = out["text"]
del out["text"]
return out
Expand Down

0 comments on commit 0b1a269

Please sign in to comment.