MikeMann commited on
Commit
fcaf284
·
1 Parent(s): 859bd68

fixed response

Browse files
Files changed (1) hide show
  1. app.py +29 -3
app.py CHANGED
@@ -477,7 +477,32 @@ class BSIChatbot:
477
  def launchGr(self):
478
  gr.Interface.from_pipeline(self.llmpipeline).launch()
479
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
480
 
 
 
 
 
 
481
 
482
  if __name__ == '__main__':
483
  #RAW_KNOWLEDGE_BASE = []
@@ -551,9 +576,10 @@ if __name__ == '__main__':
551
  # token = f"\n{token}"
552
  #if re.match(r"^[1-9]\.",token.choices[0].delta.content):
553
  # token = f"\n{token}"
554
- if token.choices != None:
555
- history[-1]['content'] += token.choices[0].delta.content
556
- yield history, image_gallery
 
557
  end = time.time()
558
  print("End2End Query took", end - start, "seconds!")
559
 
 
477
  def launchGr(self):
478
  gr.Interface.from_pipeline(self.llmpipeline).launch()
479
 
480
+ def queryRemoteLLM(self, systemPrompt, query):
481
+ chat_completion = self.llm_client.chat.completions.create(
482
+ messages=[{"role": "system", "content": systemRole},
483
+ {"role": "user", "content": "Step-Back Frage, die neu gestellt werden soll: " + query}],
484
+ model=self.llm_remote_model,
485
+ )
486
+ return Answer
487
+
488
+ def stepBackPrompt(self, query):
489
+ systemPrompt = """
490
+ Sie sind ein Experte für den IT-Grundschutz des BSI.
491
+ Ihre Aufgabe ist es, eine Frage neu zu formulieren und sie in eine
492
+ Rückfrage umzuformulieren, die nach einem Grundkonzept der Begrifflichkeit fragt.
493
+
494
+ Hier sind ein paar Beispiele:
495
+ Ursprüngliche Frage: Welche Bausteine werden auf einen Webserver angewendet?
496
+ Stepback-Frage: Wie werden Bausteine im IT-Grundschutz angewendet?
497
+
498
+ Ursprüngliche Frage: Wer war der Ehemann von Anna Karina von 1968 bis 1974?
499
+ Stepback-Frage: Wer waren die Ehegatten von Anna Karina?
500
 
501
+ Ursprüngliche Frage: Welche Inhalte enthält der Standard 200-1?
502
+ Stepback Frage: Welche Standards gibt es im IT-Grundschutz?
503
+ """
504
+ stepBackQuery = queryRemoteLLM(systemPrompt, query)
505
+ return stepBackQuery
506
 
507
  if __name__ == '__main__':
508
  #RAW_KNOWLEDGE_BASE = []
 
576
  # token = f"\n{token}"
577
  #if re.match(r"^[1-9]\.",token.choices[0].delta.content):
578
  # token = f"\n{token}"
579
+ if token.choices and len(token.choices) > 0:
580
+ if token.choices[0].delta.content != "":
581
+ history[-1]['content'] += token.choices[0].delta.content
582
+ yield history, image_gallery
583
  end = time.time()
584
  print("End2End Query took", end - start, "seconds!")
585