Skip to content

Commit

Permalink
Merge branch 'AlboCode-main' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
pieroit committed Oct 17, 2023
2 parents f667a96 + 0b1a269 commit b0466dc
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions core/cat/factory/llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ class LLMOpenAIChatConfig(LLMSettings):
openai_api_key: str
model_name: str = "gpt-3.5-turbo"
temperature: float = 0.7 # default value, from 0 to 1. Higher value create more creative and randomic answers, lower value create more focused and deterministc answers
streaming: bool = False
_pyclass: Type = ChatOpenAI

model_config = ConfigDict(
Expand Down
10 changes: 9 additions & 1 deletion core/cat/looking_glass/agent_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
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
Expand All @@ -14,6 +15,13 @@
from cat.log import log


class NewTokenHandler(BaseCallbackHandler):

def __init__(self, cat):
self.cat = cat
def on_llm_new_token(self, token: str, **kwargs) -> None:
self.cat.send_ws_message(token, "chat_token")



class AgentManager:
Expand Down Expand Up @@ -85,7 +93,7 @@ def execute_memory_chain(self, agent_input, prompt_prefix, prompt_suffix):
verbose=True
)

out = memory_chain(agent_input)
out = memory_chain(agent_input, callbacks=[NewTokenHandler(self.cat)])
out["output"] = out["text"]
del out["text"]
return out
Expand Down
2 changes: 1 addition & 1 deletion core/cat/looking_glass/cheshire_cat.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
from cat.factory.custom_llm import CustomOpenAI


MSG_TYPES = Literal["notification", "chat", "error"]
MSG_TYPES = Literal["notification", "chat", "error", "chat_token"]

# main class
class CheshireCat:
Expand Down

0 comments on commit b0466dc

Please sign in to comment.