Kushagra8041 commited on
Commit
0541773
·
verified ·
1 Parent(s): 7578e12

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -7
app.py CHANGED
@@ -20,11 +20,16 @@ You also provide a step by step solution and dont miss even small steps so even
20
  Also you tend to get strict on anything which is outside of the curriculum as you are strictly meant for academic usage and specially to assist students with BEEE only\
21
  You are strictly not supposed to answer anything unrelated to BEEE and bluntly refuse to answer stating the reason that your prime existance is to help in BEEE and not in any other subject or domain."
22
 
23
- def chat(message, history):
24
  messages = [{"role": "system", "content": system_prompt}]
25
 
26
- for msg in history:
27
- messages.append({"role": msg["role"], "content": msg["content"]})
 
 
 
 
 
28
 
29
  messages.append({"role": "user", "content": message})
30
 
@@ -37,8 +42,7 @@ def chat(message, history):
37
 
38
  gr.ChatInterface(
39
  fn=chat,
40
- type="messages", # add this line
41
- title="My Llama 3.1 Chatbot",
42
- description="Powered by Llama 3.1 via Groq",
43
- examples=["Hello!", "What can you do?"]
44
  ).launch()
 
20
  Also you tend to get strict on anything which is outside of the curriculum as you are strictly meant for academic usage and specially to assist students with BEEE only\
21
  You are strictly not supposed to answer anything unrelated to BEEE and bluntly refuse to answer stating the reason that your prime existance is to help in BEEE and not in any other subject or domain."
22
 
23
+ ddef chat(message, history):
24
  messages = [{"role": "system", "content": system_prompt}]
25
 
26
+ for item in history:
27
+ if isinstance(item, dict):
28
+ messages.append({"role": item["role"], "content": item["content"]})
29
+ else:
30
+ user_msg, assistant_msg = item
31
+ messages.append({"role": "user", "content": user_msg})
32
+ messages.append({"role": "assistant", "content": assistant_msg})
33
 
34
  messages.append({"role": "user", "content": message})
35
 
 
42
 
43
  gr.ChatInterface(
44
  fn=chat,
45
+ title="BEEE Assistant",
46
+ description="Ask me anything about BEEE!",
47
+ examples=["What is BEEE?", "Help me with BEEE"]
 
48
  ).launch()