Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -33,9 +33,13 @@ BUTTON_MIN_WIDTH = 180
|
|
| 33 |
STATUS_NOK = "404-MODEL UNREADY-critical"
|
| 34 |
STATUS_OK = "200-MODEL LOADED-9cf"
|
| 35 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
def get_status(inputs) -> str:
|
| 37 |
return f"""<img
|
| 38 |
-
src = "
|
| 39 |
style = "margin: 0 auto;"
|
| 40 |
>"""
|
| 41 |
|
|
@@ -45,21 +49,25 @@ MODEL_DONE = get_status(STATUS_OK)
|
|
| 45 |
|
| 46 |
MODEL_WARNING = "Please paste your OpenAI API Key from openai.com and press 'Enter' to initialize this application!"
|
| 47 |
|
|
|
|
|
|
|
|
|
|
| 48 |
|
| 49 |
webui_title = """
|
| 50 |
# OpenAI Chatbot Based on Vector Database
|
| 51 |
## Example of 3GPP
|
| 52 |
"""
|
| 53 |
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
KEY_CLEAR = "Clear"
|
| 57 |
|
| 58 |
init_message = f"""Welcome to use 3GPP Chatbot, this demo toolkit is based on OpenAI with LangChain and Pinecone
|
| 59 |
1. Insert your OpenAI API key and click `{KEY_INIT}`
|
| 60 |
2. Insert your Question and click `{KEY_SUBMIT}`
|
| 61 |
"""
|
| 62 |
|
|
|
|
|
|
|
| 63 |
#----------------------------------------------------------------------------------------------------------
|
| 64 |
#----------------------------------------------------------------------------------------------------------
|
| 65 |
|
|
@@ -170,13 +178,14 @@ with gr.Blocks(
|
|
| 170 |
llm_chain = gr.State()
|
| 171 |
vector_db = gr.State()
|
| 172 |
gr.Markdown(webui_title)
|
|
|
|
| 173 |
gr.Markdown(init_message)
|
| 174 |
|
| 175 |
with gr.Row():
|
| 176 |
with gr.Column(scale=10):
|
| 177 |
llm_api_textbox = gr.Textbox(
|
| 178 |
label = "OpenAI API Key",
|
| 179 |
-
show_label = False,
|
| 180 |
value = OPENAI_API_KEY,
|
| 181 |
placeholder = "Paste Your OpenAI API Key (sk-...) and Hit ENTER",
|
| 182 |
lines=1,
|
|
@@ -191,16 +200,7 @@ with gr.Blocks(
|
|
| 191 |
with gr.Row():
|
| 192 |
with gr.Column(scale=10):
|
| 193 |
chatbot = gr.Chatbot(elem_classes="bigbox")
|
| 194 |
-
|
| 195 |
-
with gr.Column(scale=1, min_width=BUTTON_MIN_WIDTH):
|
| 196 |
-
temp = gr.Slider(0,
|
| 197 |
-
2,
|
| 198 |
-
value=OPENAI_TEMP,
|
| 199 |
-
step=0.1,
|
| 200 |
-
label="temperature",
|
| 201 |
-
interactive=True)
|
| 202 |
-
init = gr.Button("Init")
|
| 203 |
-
'''
|
| 204 |
with gr.Row():
|
| 205 |
with gr.Column(scale=10):
|
| 206 |
query = gr.Textbox(label="Question:",
|
|
@@ -272,6 +272,8 @@ with gr.Blocks(
|
|
| 272 |
[chatbot, ref, detail_panel]
|
| 273 |
)
|
| 274 |
|
|
|
|
|
|
|
| 275 |
clear.click(lambda: (None,None,None), None, [query, ref, chatbot], queue=False)
|
| 276 |
|
| 277 |
#----------------------------------------------------------------------------------------------------------
|
|
|
|
| 33 |
STATUS_NOK = "404-MODEL UNREADY-critical"
|
| 34 |
STATUS_OK = "200-MODEL LOADED-9cf"
|
| 35 |
|
| 36 |
+
|
| 37 |
+
def get_logo(inputs, logo) -> str:
|
| 38 |
+
return f"""https://img.shields.io/badge/{inputs}?style=flat&logo={logo}&logoColor=white"""
|
| 39 |
+
|
| 40 |
def get_status(inputs) -> str:
|
| 41 |
return f"""<img
|
| 42 |
+
src = "{get_logo(inputs, "openai")}";
|
| 43 |
style = "margin: 0 auto;"
|
| 44 |
>"""
|
| 45 |
|
|
|
|
| 49 |
|
| 50 |
MODEL_WARNING = "Please paste your OpenAI API Key from openai.com and press 'Enter' to initialize this application!"
|
| 51 |
|
| 52 |
+
KEY_INIT = "Initialize Model"
|
| 53 |
+
KEY_SUBMIT = "Submit"
|
| 54 |
+
KEY_CLEAR = "Clear"
|
| 55 |
|
| 56 |
webui_title = """
|
| 57 |
# OpenAI Chatbot Based on Vector Database
|
| 58 |
## Example of 3GPP
|
| 59 |
"""
|
| 60 |
|
| 61 |
+
dup_link = f'''<a href="https://huggingface.co/spaces/ShawnAI/3GPP-ChatBot?duplicate=true">
|
| 62 |
+
<img src="{get_logo("Fork-HuggingFace Space-9cf", "addthis")}"></a> '''
|
|
|
|
| 63 |
|
| 64 |
init_message = f"""Welcome to use 3GPP Chatbot, this demo toolkit is based on OpenAI with LangChain and Pinecone
|
| 65 |
1. Insert your OpenAI API key and click `{KEY_INIT}`
|
| 66 |
2. Insert your Question and click `{KEY_SUBMIT}`
|
| 67 |
"""
|
| 68 |
|
| 69 |
+
|
| 70 |
+
|
| 71 |
#----------------------------------------------------------------------------------------------------------
|
| 72 |
#----------------------------------------------------------------------------------------------------------
|
| 73 |
|
|
|
|
| 178 |
llm_chain = gr.State()
|
| 179 |
vector_db = gr.State()
|
| 180 |
gr.Markdown(webui_title)
|
| 181 |
+
gr.HTML(dup_link)
|
| 182 |
gr.Markdown(init_message)
|
| 183 |
|
| 184 |
with gr.Row():
|
| 185 |
with gr.Column(scale=10):
|
| 186 |
llm_api_textbox = gr.Textbox(
|
| 187 |
label = "OpenAI API Key",
|
| 188 |
+
# show_label = False,
|
| 189 |
value = OPENAI_API_KEY,
|
| 190 |
placeholder = "Paste Your OpenAI API Key (sk-...) and Hit ENTER",
|
| 191 |
lines=1,
|
|
|
|
| 200 |
with gr.Row():
|
| 201 |
with gr.Column(scale=10):
|
| 202 |
chatbot = gr.Chatbot(elem_classes="bigbox")
|
| 203 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 204 |
with gr.Row():
|
| 205 |
with gr.Column(scale=10):
|
| 206 |
query = gr.Textbox(label="Question:",
|
|
|
|
| 272 |
[chatbot, ref, detail_panel]
|
| 273 |
)
|
| 274 |
|
| 275 |
+
print(dup_link)
|
| 276 |
+
|
| 277 |
clear.click(lambda: (None,None,None), None, [query, ref, chatbot], queue=False)
|
| 278 |
|
| 279 |
#----------------------------------------------------------------------------------------------------------
|