mou3az commited on
Commit
9e9de3d
1 Parent(s): 86a73bb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -10
app.py CHANGED
@@ -46,7 +46,7 @@ def handle_message(message: str, mode: str):
46
  result_text = "Select a valid mode."
47
 
48
  return result_text, result_image
49
-
50
  def chat_message(message: str):
51
  global messages
52
 
@@ -73,9 +73,7 @@ def web_search(message: str):
73
 
74
  augmented_prompt = f"""
75
  If the answer to the next query is not contained in the Web Search, say 'No Answer Is Available' and then just give guidance for the query.
76
-
77
  Query: {message}
78
-
79
  Web Search:
80
  {source_knowledge}
81
  """
@@ -112,17 +110,11 @@ def chart_generator(message: str):
112
  return f"IT-Assistant: {response.content}", chart_url
113
  else:
114
  return f"Can't generate this image. Please provide valid chart details.", None
115
-
116
- def custom_display_text_and_image(result_text, result_image):
117
- if result_image:
118
- display(HTML(f"<p>{result_text}</p><img src='{result_image}'/>"))
119
- else:
120
- print(result_text)
121
 
122
  demo = gr.Interface(
123
  fn=handle_message,
124
  inputs=["text", gr.Radio(["Chat-Message", "Web-Search", "Chart-Generator"], label="mode", info="Choose a mode and enter your message, then click submit to interact.")],
125
- outputs=custom_display_text_and_image,
126
  title="IT Assistant")
127
 
128
  demo.launch()
 
46
  result_text = "Select a valid mode."
47
 
48
  return result_text, result_image
49
+
50
  def chat_message(message: str):
51
  global messages
52
 
 
73
 
74
  augmented_prompt = f"""
75
  If the answer to the next query is not contained in the Web Search, say 'No Answer Is Available' and then just give guidance for the query.
 
76
  Query: {message}
 
77
  Web Search:
78
  {source_knowledge}
79
  """
 
110
  return f"IT-Assistant: {response.content}", chart_url
111
  else:
112
  return f"Can't generate this image. Please provide valid chart details.", None
 
 
 
 
 
 
113
 
114
  demo = gr.Interface(
115
  fn=handle_message,
116
  inputs=["text", gr.Radio(["Chat-Message", "Web-Search", "Chart-Generator"], label="mode", info="Choose a mode and enter your message, then click submit to interact.")],
117
+ outputs=[gr.Textbox(label="Response"), gr.Image(label="Chart if generated", type="filepath")],
118
  title="IT Assistant")
119
 
120
  demo.launch()