Chris4K commited on
Commit
a164c8b
·
1 Parent(s): 76d85d9
controller.py CHANGED
@@ -1,7 +1,7 @@
1
  import os
2
  from app_agent_config import AgentConfig
3
  from utils.logger import log_response
4
- from model.custom_agent import CustomHfAgent
5
  from model.conversation_chain_singleton import ConversationChainSingleton
6
 
7
  def cut_text_after_keyword(text, keyword):
@@ -17,19 +17,17 @@ class Controller:
17
  #self.app_config = AppConfig()
18
 
19
  image = []
20
- def handle_submission(self, user_message ):
21
-
22
  log_response("User input \n {}".format(user_message))
23
  log_response("selected_tools \n {}".format(self.agent_config.tool_checkboxes))
24
  log_response("url_endpoint \n {}".format(self.agent_config.url_endpoint))
25
  log_response("document \n {}".format(self.agent_config.document))
26
  log_response("image \n {}".format(self.agent_config.image))
27
- log_response("context \n {}".format(self.agent_config.context))
28
-
29
  agent = CustomHfAgent(
30
  url_endpoint=self.agent_config.url_endpoint,
31
  token=os.environ['HF_token'],
32
- additional_tools=self.agent_config.elected_tools,
33
  input_params={"max_new_tokens": 192},
34
  )
35
 
@@ -41,15 +39,12 @@ class Controller:
41
 
42
  def handle_submission_chat(self, user_message, angent_respone):
43
  # os.environ['HUGGINGFACEHUB_API_TOKEN'] = os.environ['HF_token']
44
- agent_chat_bot = ConversationChainSingleton().get_conversation_chain()
45
-
46
  if angent_respone is not None:
47
  text = agent_chat_bot.predict(input=user_message + angent_respone)
48
  else:
49
  text = agent_chat_bot.predict(input=user_message)
50
 
51
  result = cut_text_after_keyword(text, "Human:")
52
-
53
  print(result)
54
-
55
  return result
 
1
  import os
2
  from app_agent_config import AgentConfig
3
  from utils.logger import log_response
4
+ from model.custom_agent import CustomHfAgent
5
  from model.conversation_chain_singleton import ConversationChainSingleton
6
 
7
  def cut_text_after_keyword(text, keyword):
 
17
  #self.app_config = AppConfig()
18
 
19
  image = []
20
+ def handle_submission(self, user_message ):
 
21
  log_response("User input \n {}".format(user_message))
22
  log_response("selected_tools \n {}".format(self.agent_config.tool_checkboxes))
23
  log_response("url_endpoint \n {}".format(self.agent_config.url_endpoint))
24
  log_response("document \n {}".format(self.agent_config.document))
25
  log_response("image \n {}".format(self.agent_config.image))
26
+ log_response("context \n {}".format(self.agent_config.context))
 
27
  agent = CustomHfAgent(
28
  url_endpoint=self.agent_config.url_endpoint,
29
  token=os.environ['HF_token'],
30
+ additional_tools=self.agent_config.tool_checkboxes,
31
  input_params={"max_new_tokens": 192},
32
  )
33
 
 
39
 
40
  def handle_submission_chat(self, user_message, angent_respone):
41
  # os.environ['HUGGINGFACEHUB_API_TOKEN'] = os.environ['HF_token']
42
+ agent_chat_bot = ConversationChainSingleton().get_conversation_chain()
 
43
  if angent_respone is not None:
44
  text = agent_chat_bot.predict(input=user_message + angent_respone)
45
  else:
46
  text = agent_chat_bot.predict(input=user_message)
47
 
48
  result = cut_text_after_keyword(text, "Human:")
 
49
  print(result)
 
50
  return result
model/conversation_chain_singleton.py CHANGED
@@ -1,6 +1,5 @@
1
- from langchain.vectorstores import FAISS
2
  from langchain.memory import ConversationBufferMemory
3
- from langchain.chains import ConversationalRetrievalChain, ConversationChain
4
  from langchain.llms import HuggingFaceHub
5
 
6
  class ConversationChainSingleton:
 
 
1
  from langchain.memory import ConversationBufferMemory
2
+ from langchain.chains import ConversationChain
3
  from langchain.llms import HuggingFaceHub
4
 
5
  class ConversationChainSingleton:
model/custom_agent_config.py CHANGED
@@ -1,4 +1,4 @@
1
 
2
  class CustomHfAgentConfig():
3
- def __init__():
4
-
 
1
 
2
  class CustomHfAgentConfig():
3
+ def __init__(self):
4
+ print("")