Create controller.py
Browse files- controller.py +23 -0
controller.py
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from logger import log_response
|
| 2 |
+
from custom_agent import CustomHfAgent
|
| 3 |
+
|
| 4 |
+
def handle_submission(user_message, selected_tools, url_endpoint):
|
| 5 |
+
|
| 6 |
+
log_response("User input \n {}".format(user_message))
|
| 7 |
+
log_response("selected_tools \n {}".format(selected_tools))
|
| 8 |
+
log_response("url_endpoint \n {}".format(url_endpoint))
|
| 9 |
+
|
| 10 |
+
agent = CustomHfAgent(
|
| 11 |
+
url_endpoint=url_endpoint,
|
| 12 |
+
token=os.environ['HF_token'],
|
| 13 |
+
additional_tools=selected_tools,
|
| 14 |
+
input_params={"max_new_tokens": 192},
|
| 15 |
+
)
|
| 16 |
+
|
| 17 |
+
response = agent.run(user_message)
|
| 18 |
+
|
| 19 |
+
log_response("Agent Response\n {}".format(response))
|
| 20 |
+
|
| 21 |
+
return response
|
| 22 |
+
|
| 23 |
+
|