RahulGanapathy commited on
Commit
c128f47
·
verified ·
1 Parent(s): d3bf06e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -8
app.py CHANGED
@@ -25,12 +25,12 @@ class Message(BaseModel):
25
  def respond(
26
  message,
27
  history: list[tuple[str, str]],
28
- system_message,
29
- max_tokens,
30
- temperature,
31
- top_p,
32
  ):
33
- messages = [{"role": "system", "content": "You are a helpful Assistant. You let the user to know if the information they share with you is true or false. You return the actual facts behind the information given, after stating the state of Truth or False."}]
34
 
35
  for val in history:
36
  if val[0]:
@@ -50,13 +50,16 @@ def respond(
50
  top_p=top_p,
51
  ):
52
  token = message.choices[0].delta.content
53
-
54
  response += token
55
  yield response
56
 
 
 
 
 
57
 
58
- # Mount Gradio UI on the root `/`
59
- app = gr.mount_gradio_app(app, path="/")
60
 
61
  @app.post("/predict")
62
  def predict(data: Message):
 
25
  def respond(
26
  message,
27
  history: list[tuple[str, str]],
28
+ system_message="You are a helpful Assistant. You let the user know if the information they share with you is true or false. You return the actual facts behind the information given, after stating the state of Truth or False.",
29
+ max_tokens=512,
30
+ temperature=0.7,
31
+ top_p=0.9,
32
  ):
33
+ messages = [{"role": "system", "content": system_message}]
34
 
35
  for val in history:
36
  if val[0]:
 
50
  top_p=top_p,
51
  ):
52
  token = message.choices[0].delta.content
 
53
  response += token
54
  yield response
55
 
56
+ # ✅ Define Gradio Chatbot UI
57
+ demo = gr.ChatInterface(
58
+ respond, chatbot=gr.Chatbot(type="messages")
59
+ )
60
 
61
+ # Mount Gradio UI to FastAPI
62
+ app = gr.mount_gradio_app(app, demo, path="/")
63
 
64
  @app.post("/predict")
65
  def predict(data: Message):