alexkueck commited on
Commit
3e27c33
1 Parent(s): 440da72

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -4
app.py CHANGED
@@ -297,6 +297,24 @@ def generate_prompt_with_history(text, history, max_length=4048):
297
  else:
298
  return None
299
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
300
  #Prompt und History für OPenAi Schnittstelle
301
  def generate_prompt_with_history_openai(prompt, history):
302
  history_openai_format = []
@@ -379,13 +397,19 @@ def generate_auswahl(prompt, file, history, rag_option, model_option, openai_api
379
  print("history vor Zusatz...........")
380
  print(history)
381
  history[-1][1] = result
382
- #return history, "Success"
 
383
  for character in result:
384
  history[-1][1] += character
385
  time.sleep(0.03)
386
  yield history, "Generating"
387
-
388
-
 
 
 
 
 
389
 
390
  def generate_bild(prompt):
391
  data = {"inputs": prompt}
@@ -410,7 +434,7 @@ def generate_text (prompt, file, history, rag_option, model_option, openai_api_k
410
  if (file == None):
411
  history_text_und_prompt = generate_prompt_with_history(prompt, history)
412
  else:
413
- history_file_und_prompt = generate_prompt_with_history(prompt, history)
414
 
415
  #history für HuggingFace Models formatieren
416
  #history_text_und_prompt = generate_prompt_with_history_hf(prompt, history)
 
297
  else:
298
  return None
299
 
300
+ def generate_prompt_and_file_with_history(text, history, file):
301
+ #prompt = "The following is a conversation between a human and an AI assistant named Baize (named after a mythical creature in Chinese folklore). Baize is an open-source AI assistant developed by UCSD and Sun Yat-Sen University. The human and the AI assistant take turns chatting. Human statements start with [|Human|] and AI assistant statements start with [|AI|]. The AI assistant always provides responses in as much detail as possible, and in Markdown format. The AI assistant always declines to engage with topics, questions and instructions related to unethical, controversial, or sensitive issues. Complete the transcript in exactly that format.\n[|Human|]Hello!\n[|AI|]Hi!"
302
+ #prompt = "Das folgende ist eine Unterhaltung in deutsch zwischen einem Menschen und einem KI-Assistenten, der Baize genannt wird. Baize ist ein open-source KI-Assistent, der von UCSD entwickelt wurde. Der Mensch und der KI-Assistent chatten abwechselnd miteinander in deutsch. Die Antworten des KI Assistenten sind immer so ausführlich wie möglich und in Markdown Schreibweise und in deutscher Sprache. Wenn nötig übersetzt er sie ins Deutsche. Die Antworten des KI-Assistenten vermeiden Themen und Antworten zu unethischen, kontroversen oder sensiblen Themen. Die Antworten sind immer sehr höflich formuliert..\n[|Human|]Hallo!\n[|AI|]Hi!"
303
+ prompt=""
304
+ history = ["\n{}\n{}".format(x[0],x[1]) for x in history]
305
+ history.append("\n{}\n".format(text))
306
+ history_text = ""
307
+ flag = False
308
+ for x in history[::-1]:
309
+ history_text = x + history_text
310
+ flag = True
311
+ print ("Prompt: ..........................")
312
+ print(prompt+history_text)
313
+ if flag:
314
+ return prompt+history_text
315
+ else:
316
+ return None
317
+
318
  #Prompt und History für OPenAi Schnittstelle
319
  def generate_prompt_with_history_openai(prompt, history):
320
  history_openai_format = []
 
397
  print("history vor Zusatz...........")
398
  print(history)
399
  history[-1][1] = result
400
+ return history, "Success"
401
+ """
402
  for character in result:
403
  history[-1][1] += character
404
  time.sleep(0.03)
405
  yield history, "Generating"
406
+ if shared_state.interrupted:
407
+ shared_state.recover()
408
+ try:
409
+ yield history, "Stop: Success"
410
+ except:
411
+ pass
412
+ """
413
 
414
  def generate_bild(prompt):
415
  data = {"inputs": prompt}
 
434
  if (file == None):
435
  history_text_und_prompt = generate_prompt_with_history(prompt, history)
436
  else:
437
+ history_file_und_prompt = generate_prompt_history(prompt, file, history)
438
 
439
  #history für HuggingFace Models formatieren
440
  #history_text_und_prompt = generate_prompt_with_history_hf(prompt, history)