mobinln commited on
Commit
c109793
·
verified ·
1 Parent(s): a09beae

make thinking tokens italic

Browse files
Files changed (1) hide show
  1. app.py +4 -2
app.py CHANGED
@@ -1,3 +1,4 @@
 
1
  import gradio as gr
2
  from llama_cpp import Llama
3
 
@@ -44,8 +45,9 @@ def respond(
44
  for message in completion:
45
  delta = message['choices'][0]['delta']
46
  if 'content' in delta:
47
- response += delta['content']
48
- yield response
 
49
 
50
 
51
  demo = gr.ChatInterface(
 
1
+ import re
2
  import gradio as gr
3
  from llama_cpp import Llama
4
 
 
45
  for message in completion:
46
  delta = message['choices'][0]['delta']
47
  if 'content' in delta:
48
+ # response += delta['content']
49
+ formatted_response = re.sub(r'<think>(.*?)</think>', r'*\1*', response)
50
+ yield formatted_response
51
 
52
 
53
  demo = gr.ChatInterface(