hash-map commited on
Commit
7d25ed6
·
verified ·
1 Parent(s): 5063dd1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -9
app.py CHANGED
@@ -3,24 +3,23 @@ from rag import respond_rag_ollama # Your custom RAG function using Ollama
3
 
4
  history = []
5
 
6
- def respond(message, chat_history, temperature=0.5, max_tokens=512, top_p=0.3):
7
- response = respond_rag_ollama(message, temperature=temperature,num_predict=max_tokens,top_p=top_p) # send only message & temperature
8
  chat_history.append((message, response))
9
  return "", chat_history
10
 
11
  with gr.Blocks() as demo:
12
- gr.Markdown("# RAG with Ollama Chatbot")
13
 
14
  chatbot = gr.Chatbot()
15
- msg = gr.Textbox(label="Your Message")
 
16
  temp = gr.Slider(0.0, 1.0, value=0.5, label="Temperature")
17
- max_tokens=gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens")
18
-
19
- top_p=gr.Slider(minimum=0.1, maximum=1.0, value=0.95, step=0.05, label="Top-p")
20
  clear = gr.Button("Clear")
21
-
22
 
23
- msg.submit(respond, [msg, chatbot, temp,max_tokens,top_p], [msg, chatbot])
24
  clear.click(lambda: ([], ""), None, [chatbot, msg])
25
 
26
  demo.launch()
 
3
 
4
  history = []
5
 
6
+ def respond(message, chat_history, temperature=0.5, max_tokens=512 ):
7
+ response = respond_rag_ollama(message, temperature=temperature,num_predict=max_tokens) # send only message & temperature
8
  chat_history.append((message, response))
9
  return "", chat_history
10
 
11
  with gr.Blocks() as demo:
12
+ gr.Markdown("# Game of Thrones Q&A bot")
13
 
14
  chatbot = gr.Chatbot()
15
+ msg = gr.Textbox(label="Tell me something about 7 kingdoms")
16
+
17
  temp = gr.Slider(0.0, 1.0, value=0.5, label="Temperature")
18
+ max_tokens = gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens")
19
+
 
20
  clear = gr.Button("Clear")
 
21
 
22
+ msg.submit(respond, [msg, chatbot, temp, max_tokens], [msg, chatbot])
23
  clear.click(lambda: ([], ""), None, [chatbot, msg])
24
 
25
  demo.launch()