Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -6,6 +6,20 @@ from huggingface_hub import InferenceClient
|
|
| 6 |
from sentence_transformers import SentenceTransformer
|
| 7 |
import torch
|
| 8 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
#STEP 2 FROM SEMANTIC SEARCH
|
| 11 |
# Open the water_cycle.txt file in read mode with UTF-8 encoding
|
|
@@ -102,7 +116,7 @@ client=InferenceClient("HuggingFaceH4/zephyr-7b-beta")
|
|
| 102 |
def respond(message, history):
|
| 103 |
top_results= get_top_chunks(message, chunk_embeddings, cleaned_chunks)
|
| 104 |
str_top_results= '\n'.join(top_results)
|
| 105 |
-
messages = [{'role':'system', 'content': f'You are a friend chatbot. Complete all your sentences
|
| 106 |
if history:
|
| 107 |
messages.extend(history)
|
| 108 |
|
|
@@ -110,33 +124,19 @@ def respond(message, history):
|
|
| 110 |
|
| 111 |
response = client.chat_completion(
|
| 112 |
messages,
|
| 113 |
-
max_tokens =
|
| 114 |
temperature = 0.2
|
| 115 |
)
|
| 116 |
return response['choices'][0]['message']['content'].strip()
|
| 117 |
|
| 118 |
demo = gr.ChatInterface(respond, type="messages", autofocus=False)
|
| 119 |
|
| 120 |
-
theme =
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
# Your exact hex colors applied via CSS
|
| 127 |
-
custom_css = """
|
| 128 |
-
:root {
|
| 129 |
-
--color-primary-500: #CC338B;
|
| 130 |
-
--color-secondary-500: #EAA221;
|
| 131 |
-
--color-neutral-500: #43B3AE;
|
| 132 |
-
}
|
| 133 |
|
| 134 |
-
.dark {
|
| 135 |
-
--color-primary-500: #CC338B;
|
| 136 |
-
--color-secondary-500: #EAA221;
|
| 137 |
-
--color-neutral-500: #43B3AE;
|
| 138 |
-
}
|
| 139 |
-
"""
|
| 140 |
|
| 141 |
|
| 142 |
demo.launch()
|
|
|
|
| 6 |
from sentence_transformers import SentenceTransformer
|
| 7 |
import torch
|
| 8 |
|
| 9 |
+
theme = gr.themes.Soft(
|
| 10 |
+
primary_hue="rose",
|
| 11 |
+
secondary_hue="zinc",
|
| 12 |
+
neutral_hue="pink"
|
| 13 |
+
)
|
| 14 |
+
|
| 15 |
+
custom_css = """
|
| 16 |
+
:root { /* This applies to the light mode */
|
| 17 |
+
--background-fill-primary: *primary_100 !important; /* Light pink */
|
| 18 |
+
}
|
| 19 |
+
.dark { /* This applies to the dark mode */
|
| 20 |
+
--background-fill-primary: #FFB6C1 !important; /* Hot pink */
|
| 21 |
+
}
|
| 22 |
+
"""
|
| 23 |
|
| 24 |
#STEP 2 FROM SEMANTIC SEARCH
|
| 25 |
# Open the water_cycle.txt file in read mode with UTF-8 encoding
|
|
|
|
| 116 |
def respond(message, history):
|
| 117 |
top_results= get_top_chunks(message, chunk_embeddings, cleaned_chunks)
|
| 118 |
str_top_results= '\n'.join(top_results)
|
| 119 |
+
messages = [{'role':'system', 'content': f'You are a friend chatbot. Complete all your sentences, and do not cut yourself off. The word limit is 100 words. Start off by only giving a career, and then if prompted by the user provide more information like salary, college course,etc. Base your response on the provided context:\n{str_top_results}'}]
|
| 120 |
if history:
|
| 121 |
messages.extend(history)
|
| 122 |
|
|
|
|
| 124 |
|
| 125 |
response = client.chat_completion(
|
| 126 |
messages,
|
| 127 |
+
max_tokens = 1000,
|
| 128 |
temperature = 0.2
|
| 129 |
)
|
| 130 |
return response['choices'][0]['message']['content'].strip()
|
| 131 |
|
| 132 |
demo = gr.ChatInterface(respond, type="messages", autofocus=False)
|
| 133 |
|
| 134 |
+
with gr.Blocks (theme = theme) as chatbot:
|
| 135 |
+
gr.ChatInterface(respond, type = "messages",
|
| 136 |
+
title = "Hi, I'm PathPilot! ",
|
| 137 |
+
textbox= gr.Textbox(placeholder="Share Your Age and Ask Me Anything!"),
|
| 138 |
+
description = "This tool is here to listen and provide information on STEM Careers, and all discussions will be kept confidential. ❤️🩹",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 139 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 140 |
|
| 141 |
|
| 142 |
demo.launch()
|