cafierom commited on
Commit
4573299
·
verified ·
1 Parent(s): 0442d3e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -7
app.py CHANGED
@@ -59,7 +59,9 @@ def chat(prompt, tools, voice_choice):
59
  instructions = 'You are a drug design assistant. Use tools provided for information; do not insert \
60
  your own knowledge if the information can be obtained from a tool. When calling a tool give complete \
61
  sentences for the task parameter. For example, do not define the task as "fetch smiles", rather, say: \
62
- "find the smiles string for the molecule".',
 
 
63
  model = "o4-mini",
64
  tools = cafchem_tools,
65
  input=prompt,
@@ -70,7 +72,9 @@ def chat(prompt, tools, voice_choice):
70
  instructions = 'You are a drug design assistant. Use tools provided for information; do not insert \
71
  your own knowledge if the information can be obtained from a tool. When calling a tool give complete \
72
  sentences for the task parameter. For example, do not define the task as "fetch smiles", rather, say: \
73
- "find the smiles string for the molecule".',
 
 
74
  model = "o4-mini",
75
  tools = cafchem_tools,
76
  input=prompt
@@ -185,9 +189,10 @@ def dock_accordions():
185
  return audio_player, messages
186
 
187
  with gr.Blocks() as forest:
188
- gr.Markdown(
189
  """
190
- # Chat with MoDrAg! OpenAI 04-mini can tap into Modrag through an MCP and use all of your favourite drug design tools.
 
191
  - Currently using the tools below:
192
  """)
193
  with gr.Row():
@@ -232,9 +237,9 @@ with gr.Blocks() as forest:
232
 
233
  chatbot = gr.Chatbot()
234
 
235
- with gr.Row():
236
- msg = gr.Textbox(label="Type your messages here and hit enter.", scale = 2)
237
- chat_btn = gr.Button(value = "Send", scale = 0)
238
  talk_ele = gr.HTML()
239
 
240
  clear = gr.ClearButton([msg, chatbot])
@@ -250,5 +255,13 @@ with gr.Blocks() as forest:
250
  combined_workflow.click(combo_workflow, outputs = [talk_ele, chatbot])
251
  clear.click(clear_history)
252
 
 
 
 
 
 
 
 
 
253
  if __name__ == "__main__":
254
  forest.launch(debug=False, share=True)
 
59
  instructions = 'You are a drug design assistant. Use tools provided for information; do not insert \
60
  your own knowledge if the information can be obtained from a tool. When calling a tool give complete \
61
  sentences for the task parameter. For example, do not define the task as "fetch smiles", rather, say: \
62
+ "find the smiles string for the molecule". If you need to call the ProteinAgent_ProteinAgent tool for \
63
+ either IC50 prediction or novel molecule generation, then you need to call have the tool get bioactive \
64
+ molecules first, so that the correct dataset can be obtained.',
65
  model = "o4-mini",
66
  tools = cafchem_tools,
67
  input=prompt,
 
72
  instructions = 'You are a drug design assistant. Use tools provided for information; do not insert \
73
  your own knowledge if the information can be obtained from a tool. When calling a tool give complete \
74
  sentences for the task parameter. For example, do not define the task as "fetch smiles", rather, say: \
75
+ "find the smiles string for the molecule". If you need to call the ProteinAgent_ProteinAgent tool for \
76
+ either IC50 prediction or novel molecule generation, then you need to call have the tool get bioactive \
77
+ molecules first, so that the correct dataset can be obtained.',
78
  model = "o4-mini",
79
  tools = cafchem_tools,
80
  input=prompt
 
189
  return audio_player, messages
190
 
191
  with gr.Blocks() as forest:
192
+ top = gr.Markdown(
193
  """
194
+ # Chat with MoDrAg! Use the *Mo*dular *Dr*ug Design *Ag*ent's Drug design tools through
195
+ OpenAI 04-mini using the Model Context Protocol! (MCP)
196
  - Currently using the tools below:
197
  """)
198
  with gr.Row():
 
237
 
238
  chatbot = gr.Chatbot()
239
 
240
+
241
+ msg = gr.Textbox(label="Type your messages here and hit enter.", scale = 2)
242
+ chat_btn = gr.Button(value = "Send", scale = 0)
243
  talk_ele = gr.HTML()
244
 
245
  clear = gr.ClearButton([msg, chatbot])
 
255
  combined_workflow.click(combo_workflow, outputs = [talk_ele, chatbot])
256
  clear.click(clear_history)
257
 
258
+ @gr.render(inputs=top)
259
+ def get_speech(args):
260
+ audio_file = 'MoDrAg_hello.mp3'
261
+ with open(audio_file, 'rb') as audio_bytes:
262
+ audio = base64.b64encode(audio_bytes.read()).decode("utf-8")
263
+ audio_player = f'<audio src="data:audio/mpeg;base64,{audio}" controls autoplay></audio>'
264
+ talk_ele = gr.HTML(audio_player)
265
+
266
  if __name__ == "__main__":
267
  forest.launch(debug=False, share=True)