anekcb commited on
Commit
7d588cc
·
verified ·
1 Parent(s): fe46068

Delete app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -57
app.py DELETED
@@ -1,57 +0,0 @@
1
- import os
2
- import gradio
3
- from groq import Groq
4
- from gradio import Textbox, Outputs
5
-
6
-
7
- # Initialize the GROQ client with your API key
8
- client = Groq(api_key=os.environ.get("GROQ_API_KEY"))
9
-
10
- # Initialize an empty conversation history list
11
- conversation_history = []
12
-
13
- def chatbot_with_submit(user_input):
14
- global conversation_history
15
-
16
- # If this is the first user input, provide the chatbot introduction message
17
- if not conversation_history:
18
- conversation_history.append({"role": "user", "content": "You are a medical chatbot and your name is Dr.BeeAi, Please provide information and advice on medical topics only. This includes questions related to symptoms, diagnoses, treatments, medications, and general health concerns. Please avoid responding to non-medical topics or questions that are not related to health or wellness."})
19
-
20
- # Add the user input to the conversation history
21
- conversation_history.append({"role": "user", "content": user_input})
22
-
23
- # Use GROQ Cloud API to generate a response
24
- chat_completion = client.chat.completions.create(
25
- messages=conversation_history,
26
- model="mixtral-8x7b-32768"
27
- )
28
-
29
- # Add the chatbot's response to the conversation history
30
- chatbot_reply = chat_completion.choices[0].message.content
31
- conversation_history.append({"role": "bot", "content": chatbot_reply})
32
-
33
- # Return the chatbot's response
34
- return chatbot_reply
35
-
36
- # You can keep the rest of the code for the Gradio interface as it is
37
-
38
- textbox = Textbox("Enter something:")
39
- output = Outputs("Here's the output:")
40
-
41
- interface_title = "Bee4Med Ai - GROQ"
42
- examples = [
43
- ["What are the symptoms of a common cold?"],
44
- ["How can I treat a migraine?"],
45
- ["Is it safe to take aspirin while pregnant?"]
46
- ]
47
-
48
- demo = gradio.Interface(
49
- fn=chatbot_with_submit,
50
- inputs=[my_input],
51
- outputs=my_output,
52
- title=interface_title,
53
- description=''' Warning: please consult a doctor in emergency situations, Our predictions may get wrong at times''',
54
- examples=examples
55
- )
56
-
57
- demo.launch()