alexkueck commited on
Commit
555c5b0
1 Parent(s): e6477f6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -2
app.py CHANGED
@@ -197,6 +197,16 @@ def generate_prompt_with_history_hf(prompt, history):
197
 
198
  messages = "".join(["".join(["\n<human>:"+item[0], "\n<bot>:"+item[1]]) #curr_system_message +
199
  for item in history_transformer_format])
 
 
 
 
 
 
 
 
 
 
200
 
201
 
202
  ###################################################
@@ -211,8 +221,10 @@ def invoke (prompt, history, openai_api_key, rag_option, temperature=0.9, max_ne
211
  #history_text_und_prompt = generate_prompt_with_history_hf(prompt, history)
212
 
213
  #history für openAi formatieren
214
- history_text_und_prompt = generate_prompt_with_history_openai(prompt, history)
215
-
 
 
216
 
217
  if (openai_api_key == "" or openai_api_key == "sk-"):
218
  #raise gr.Error("OpenAI API Key is required.")
 
197
 
198
  messages = "".join(["".join(["\n<human>:"+item[0], "\n<bot>:"+item[1]]) #curr_system_message +
199
  for item in history_transformer_format])
200
+
201
+ #Prompt und History für Langchain Schnittstelle
202
+ def generate_prompt_with_history_langchain(prompt, history):
203
+ history_langchain_format = []
204
+ for human, ai in history:
205
+ history_langchain_format.append(HumanMessage(content=human))
206
+ history_langchain_format.append(AIMessage(content=ai))
207
+ history_langchain_format.append(HumanMessage(content=message))
208
+
209
+ return history_langchain_format
210
 
211
 
212
  ###################################################
 
221
  #history_text_und_prompt = generate_prompt_with_history_hf(prompt, history)
222
 
223
  #history für openAi formatieren
224
+ #history_text_und_prompt = generate_prompt_with_history_openai(prompt, history)
225
+
226
+ #history für Langchain formatieren
227
+ history_text_und_prompt = generate_prompt_with_history_langchain(prompt, history)
228
 
229
  if (openai_api_key == "" or openai_api_key == "sk-"):
230
  #raise gr.Error("OpenAI API Key is required.")