Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,14 +1,24 @@
|
|
1 |
-
# main.py
|
2 |
-
|
3 |
from openai import OpenAI
|
4 |
-
import gradio as gr
|
5 |
from gradio.chat_interface import ChatInterface
|
6 |
import os
|
7 |
from dotenv import load_dotenv
|
|
|
|
|
|
|
|
|
|
|
8 |
load_dotenv()
|
9 |
|
10 |
-
|
|
|
|
|
|
|
|
|
11 |
|
|
|
|
|
|
|
|
|
12 |
|
13 |
# System prompt
|
14 |
system_prompt = """
|
@@ -31,7 +41,8 @@ examples = [
|
|
31 |
"Vad är symptomen för covid-19?",
|
32 |
"Vilka läkemedel finns det för smärtlindring?",
|
33 |
"Hur kan jag bäst lindra mina symtom på pollenallergi?",
|
34 |
-
"Vad kan jag göra för att förbättra min sömn?"
|
|
|
35 |
]
|
36 |
|
37 |
|
@@ -91,8 +102,11 @@ def predict(message, history):
|
|
91 |
yield partial_message
|
92 |
|
93 |
def main():
|
94 |
-
|
95 |
-
ChatInterface(predict, title="Välkommen till 1177 AI-chatbot! 🔍🤒", theme="
|
96 |
-
|
|
|
|
|
97 |
if __name__ == "__main__":
|
98 |
main()
|
|
|
|
|
|
|
|
1 |
from openai import OpenAI
|
|
|
2 |
from gradio.chat_interface import ChatInterface
|
3 |
import os
|
4 |
from dotenv import load_dotenv
|
5 |
+
from gradio.themes.soft import Soft
|
6 |
+
from gradio.themes import colors
|
7 |
+
from gradio.components import Textbox
|
8 |
+
from gradio.components import Chatbot
|
9 |
+
from RAG_class import RAG_1177
|
10 |
load_dotenv()
|
11 |
|
12 |
+
textbox = Textbox(placeholder="Skriv ditt fråga här...",scale=4)
|
13 |
+
chatbot = Chatbot(placeholder="Varsågod och ställ din fråga nedanför 😊",scale=3, height=250, show_copy_button=True, label="1177 chatbot")
|
14 |
+
|
15 |
+
new_primary_color = colors.red
|
16 |
+
new_secondary_color = colors.red
|
17 |
|
18 |
+
my_custom_theme = Soft(
|
19 |
+
primary_hue=new_primary_color,
|
20 |
+
secondary_hue=new_secondary_color
|
21 |
+
)
|
22 |
|
23 |
# System prompt
|
24 |
system_prompt = """
|
|
|
41 |
"Vad är symptomen för covid-19?",
|
42 |
"Vilka läkemedel finns det för smärtlindring?",
|
43 |
"Hur kan jag bäst lindra mina symtom på pollenallergi?",
|
44 |
+
"Vad kan jag göra för att förbättra min sömn?",
|
45 |
+
"vad kan jag göra om mitt barn får magsjuka?"
|
46 |
]
|
47 |
|
48 |
|
|
|
102 |
yield partial_message
|
103 |
|
104 |
def main():
|
105 |
+
|
106 |
+
ChatInterface(predict, textbox=textbox, chatbot=chatbot, title="Välkommen till 1177 AI-chatbot! 🔍🤒", theme=my_custom_theme,submit_btn="Skicka",
|
107 |
+
retry_btn="🔄Försök igen", undo_btn="↩️ Ångra", clear_btn="🗑️ Rensa",
|
108 |
+
examples=examples, cache_examples=False, description=description).launch(share=True)
|
109 |
+
|
110 |
if __name__ == "__main__":
|
111 |
main()
|
112 |
+
|