billwang37 commited on
Commit
86dce9c
·
verified ·
1 Parent(s): 817755a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -2
app.py CHANGED
@@ -30,8 +30,11 @@ SYSTEM_PROMPT = "You are MathBioAgent, an expert AI assistant specialized in mat
30
  def chat(message, history):
31
  messages = [{"role": "system", "content": SYSTEM_PROMPT}]
32
  for h in history:
33
- messages.append({"role": "user", "content": h[0]})
34
- messages.append({"role": "assistant", "content": h[1]})
 
 
 
35
  messages.append({"role": "user", "content": message})
36
 
37
  prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
@@ -50,6 +53,7 @@ def chat(message, history):
50
 
51
  demo = gr.ChatInterface(
52
  fn=chat,
 
53
  title="MathBio AI — Mathematical Biology Assistant",
54
  description="A specialized LLM for mathematical biology, epidemic modeling, PDEs, and operator learning. Fine-tuned on 27K arxiv-derived examples.",
55
  examples=[
 
30
  def chat(message, history):
31
  messages = [{"role": "system", "content": SYSTEM_PROMPT}]
32
  for h in history:
33
+ if isinstance(h, dict):
34
+ messages.append(h)
35
+ else:
36
+ messages.append({"role": "user", "content": h[0]})
37
+ messages.append({"role": "assistant", "content": h[1]})
38
  messages.append({"role": "user", "content": message})
39
 
40
  prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
 
53
 
54
  demo = gr.ChatInterface(
55
  fn=chat,
56
+ type="messages",
57
  title="MathBio AI — Mathematical Biology Assistant",
58
  description="A specialized LLM for mathematical biology, epidemic modeling, PDEs, and operator learning. Fine-tuned on 27K arxiv-derived examples.",
59
  examples=[