AFischer1985 commited on
Commit
639562c
·
verified ·
1 Parent(s): af54abc

Update run.py

Browse files
Files changed (1) hide show
  1. run.py +3 -2
run.py CHANGED
@@ -2,7 +2,7 @@
2
  # Title: Gradio Writing Assistant
3
  # Author: Andreas Fischer
4
  # Date: May 23th, 2024
5
- # Last update: May 23th, 2024
6
  ##########################################################################################
7
 
8
  #https://github.com/abetlen/llama-cpp-python/issues/306
@@ -194,7 +194,7 @@ def extend_prompt(message="", history=None, system=None, RAGAddon=None, system2=
194
  for user_message, bot_response in history[-historylimit:]:
195
  if user_message is None: user_message = ""
196
  if bot_response is None: bot_response = ""
197
- bot_response = re.sub("\n\n<details>((.|\n)*?)</details>","", bot_response) # remove RAG-compontents
198
  if removeHTML==True: bot_response = re.sub("<(.*?)>","\n", bot_response) # remove HTML-components in general (may cause bugs with markdown-rendering)
199
  if user_message is not None: prompt += template1.format(message=user_message[:zeichenlimit])
200
  if bot_response is not None: prompt += template2.format(response=bot_response[:zeichenlimit])
@@ -204,6 +204,7 @@ def extend_prompt(message="", history=None, system=None, RAGAddon=None, system2=
204
  return startOfString+prompt
205
 
206
 
 
207
  import gradio as gr
208
  import requests
209
  import json
 
2
  # Title: Gradio Writing Assistant
3
  # Author: Andreas Fischer
4
  # Date: May 23th, 2024
5
+ # Last update: May 29th, 2024
6
  ##########################################################################################
7
 
8
  #https://github.com/abetlen/llama-cpp-python/issues/306
 
194
  for user_message, bot_response in history[-historylimit:]:
195
  if user_message is None: user_message = ""
196
  if bot_response is None: bot_response = ""
197
+ bot_response = re.sub("\n\n<details(| open)>.*?</details>","", bot_response, flags=re.DOTALL) # remove RAG-compontents
198
  if removeHTML==True: bot_response = re.sub("<(.*?)>","\n", bot_response) # remove HTML-components in general (may cause bugs with markdown-rendering)
199
  if user_message is not None: prompt += template1.format(message=user_message[:zeichenlimit])
200
  if bot_response is not None: prompt += template2.format(response=bot_response[:zeichenlimit])
 
204
  return startOfString+prompt
205
 
206
 
207
+
208
  import gradio as gr
209
  import requests
210
  import json