Upload app.py
Browse files
app.py
CHANGED
@@ -69,23 +69,6 @@ def translate(target, text):
|
|
69 |
res = response.json()
|
70 |
return res[0]["translations"][0]["text"]
|
71 |
|
72 |
-
'''
|
73 |
-
def get_response(user_input):
|
74 |
-
Takes user_input in English and invokes the infer API for response.
|
75 |
-
|
76 |
-
Parameters:
|
77 |
-
user_input (string): User Query in English.
|
78 |
-
Returns:
|
79 |
-
res (string): Response from the LLM.
|
80 |
-
url = f"https://whole-icons-hammer.loca.lt/infer/{user_id}"
|
81 |
-
headers = {"Content-Type": "application/x-www-form-urlencoded"}
|
82 |
-
data = {"user_input": user_input}
|
83 |
-
response = requests.post(url, headers=headers, data=data)
|
84 |
-
print(response)
|
85 |
-
res = response.json()
|
86 |
-
return res["data"]
|
87 |
-
'''
|
88 |
-
|
89 |
def infer(user_input: str):
|
90 |
'''
|
91 |
Returns the translated response from the LLM in response to a user query.
|
@@ -110,14 +93,10 @@ def infer(user_input: str):
|
|
110 |
]
|
111 |
)
|
112 |
|
113 |
-
runnable = prompt | agent_executor # define a chain
|
114 |
|
115 |
-
conversation = RunnableSequence( # wrap the chain along with chat history and user input
|
116 |
-
runnable,
|
117 |
-
)
|
118 |
|
119 |
-
response =
|
120 |
-
{"
|
121 |
config={"configurable": {"thread_id":user_id}}
|
122 |
)
|
123 |
|
|
|
69 |
res = response.json()
|
70 |
return res[0]["translations"][0]["text"]
|
71 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
72 |
def infer(user_input: str):
|
73 |
'''
|
74 |
Returns the translated response from the LLM in response to a user query.
|
|
|
93 |
]
|
94 |
)
|
95 |
|
|
|
96 |
|
|
|
|
|
|
|
97 |
|
98 |
+
response = agent_executor.invoke( # invoke the chain by giving the user input and the chat history
|
99 |
+
{"messages": [HumanMessage(content=user_input)]},
|
100 |
config={"configurable": {"thread_id":user_id}}
|
101 |
)
|
102 |
|