gerasdf
commited on
Commit
·
7a5649e
1
Parent(s):
20528a7
hisotry now working, also with system prompt.
Browse files
query.py
CHANGED
@@ -265,23 +265,24 @@ def load_history(state, history_id):
|
|
265 |
history = history[:-1]
|
266 |
else:
|
267 |
user_input = ''
|
|
|
|
|
|
|
268 |
|
269 |
return state, history, history, user_input # state, Chatbot, ChatInterface.state, ChatInterface.textbox
|
270 |
|
|
|
|
|
|
|
|
|
271 |
def chat(message, history, state, request:gr.Request):
|
272 |
if not_authenticated(state):
|
273 |
yield "You need to authenticate first"
|
274 |
else:
|
275 |
if AI:
|
276 |
if not history:
|
277 |
-
|
278 |
-
|
279 |
-
state["system"] = system_prompt
|
280 |
-
|
281 |
-
# Next is commented out because astra has a limit on document size
|
282 |
-
# add_history(state, request, "system", system_prompt, name=message)
|
283 |
-
else:
|
284 |
-
system_prompt = state["system"]
|
285 |
|
286 |
add_history(state, request, "user", message)
|
287 |
|
|
|
265 |
history = history[:-1]
|
266 |
else:
|
267 |
user_input = ''
|
268 |
+
|
269 |
+
if history:
|
270 |
+
state["system"] = get_system_prompt(history[0][0])
|
271 |
|
272 |
return state, history, history, user_input # state, Chatbot, ChatInterface.state, ChatInterface.textbox
|
273 |
|
274 |
+
def get_system_prompt(message):
|
275 |
+
system_prompt = prompt_chain.invoke(message)
|
276 |
+
return system_prompt.messages[0]
|
277 |
+
|
278 |
def chat(message, history, state, request:gr.Request):
|
279 |
if not_authenticated(state):
|
280 |
yield "You need to authenticate first"
|
281 |
else:
|
282 |
if AI:
|
283 |
if not history:
|
284 |
+
state["system"] = get_system_prompt(message)
|
285 |
+
system_prompt = state["system"]
|
|
|
|
|
|
|
|
|
|
|
|
|
286 |
|
287 |
add_history(state, request, "user", message)
|
288 |
|