Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -26,12 +26,14 @@ def add_details(lst):
|
|
| 26 |
|
| 27 |
|
| 28 |
prompt_template = "Instructions: Compose a comprehensive reply to the query using the search results given. " \
|
|
|
|
| 29 |
"If the search results mention multiple subjects " \
|
| 30 |
"with the same name, create separate answers for each. Only include information found in the results and " \
|
| 31 |
"don't add any additional information. Make sure the answer is correct and don't output false content. " \
|
| 32 |
"Ignore outlier search results which has nothing to do with the question. Only answer what is asked. " \
|
| 33 |
"The answer should be short and concise. \n\nQuery: {question}\nAnswer: "
|
| 34 |
|
|
|
|
| 35 |
MODELS = ["text-davinci-001", "text-davinci-002", "text-davinci-003"]
|
| 36 |
LANGUAGES = [
|
| 37 |
"English",
|
|
@@ -127,7 +129,6 @@ def get_top_chunks(inp_emb, data, n_neighbors=5):
|
|
| 127 |
|
| 128 |
|
| 129 |
def predict(
|
| 130 |
-
my_api_key,
|
| 131 |
history,
|
| 132 |
chatbot,
|
| 133 |
inputs,
|
|
@@ -164,7 +165,6 @@ def predict(
|
|
| 164 |
chatbot.append((old_inputs, ""))
|
| 165 |
else:
|
| 166 |
chatbot.append((inputs, ""))
|
| 167 |
-
openai.api_key = my_api_key
|
| 168 |
completions = openai.Completion.create(
|
| 169 |
engine=selected_model,
|
| 170 |
prompt=inputs,
|
|
@@ -236,8 +236,6 @@ with gr.Blocks(css=customCSS, theme=beautiful_theme) as demo:
|
|
| 236 |
with gr.Column(min_width=50, scale=1):
|
| 237 |
with gr.Tab(label="ChatGPT"):
|
| 238 |
gr.Markdown(f'<p style="text-align:center">Get your Open AI API key <a '
|
| 239 |
-
f'href="https://platform.openai.com/account/api-keys">here</a></p>')
|
| 240 |
-
openAI_key=gr.Textbox(label='Enter your OpenAI API key here')
|
| 241 |
f'href="https://platform.openai.com/account/api-keys">here</a></p>')
|
| 242 |
openAI_key=gr.Textbox(label='Enter your OpenAI API key here and press Enter')
|
| 243 |
model_select_dropdown = gr.Dropdown(
|
|
@@ -250,7 +248,6 @@ with gr.Blocks(css=customCSS, theme=beautiful_theme) as demo:
|
|
| 250 |
with gr.Tab(label="Advanced"):
|
| 251 |
gr.Markdown(
|
| 252 |
"⚠️Be careful to change ⚠️\n\nIf you can't use it, please restore the default settings")
|
| 253 |
-
with gr.Tab(label="Advanced"):
|
| 254 |
with gr.Accordion("Parameter", open=False):
|
| 255 |
temperature = gr.Slider(
|
| 256 |
minimum=-0,
|
|
@@ -267,4 +264,4 @@ with gr.Blocks(css=customCSS, theme=beautiful_theme) as demo:
|
|
| 267 |
submitBtn.click(predict, inputs=[history, chatbot, user_input, temperature, language_select_dropdown, model_select_dropdown, index_files],
|
| 268 |
outputs=[chatbot, history])
|
| 269 |
submitBtn.click(lambda: "", None, user_input)
|
| 270 |
-
demo.queue(concurrency_count=10).launch(server_name="0.0.0.0", server_port=
|
|
|
|
| 26 |
|
| 27 |
|
| 28 |
prompt_template = "Instructions: Compose a comprehensive reply to the query using the search results given. " \
|
| 29 |
+
"Make sure to cite results using [number] notation after the reference. " \
|
| 30 |
"If the search results mention multiple subjects " \
|
| 31 |
"with the same name, create separate answers for each. Only include information found in the results and " \
|
| 32 |
"don't add any additional information. Make sure the answer is correct and don't output false content. " \
|
| 33 |
"Ignore outlier search results which has nothing to do with the question. Only answer what is asked. " \
|
| 34 |
"The answer should be short and concise. \n\nQuery: {question}\nAnswer: "
|
| 35 |
|
| 36 |
+
# MODELS = ["universal-sentence-encoder", "instructor-large"]
|
| 37 |
MODELS = ["text-davinci-001", "text-davinci-002", "text-davinci-003"]
|
| 38 |
LANGUAGES = [
|
| 39 |
"English",
|
|
|
|
| 129 |
|
| 130 |
|
| 131 |
def predict(
|
|
|
|
| 132 |
history,
|
| 133 |
chatbot,
|
| 134 |
inputs,
|
|
|
|
| 165 |
chatbot.append((old_inputs, ""))
|
| 166 |
else:
|
| 167 |
chatbot.append((inputs, ""))
|
|
|
|
| 168 |
completions = openai.Completion.create(
|
| 169 |
engine=selected_model,
|
| 170 |
prompt=inputs,
|
|
|
|
| 236 |
with gr.Column(min_width=50, scale=1):
|
| 237 |
with gr.Tab(label="ChatGPT"):
|
| 238 |
gr.Markdown(f'<p style="text-align:center">Get your Open AI API key <a '
|
|
|
|
|
|
|
| 239 |
f'href="https://platform.openai.com/account/api-keys">here</a></p>')
|
| 240 |
openAI_key=gr.Textbox(label='Enter your OpenAI API key here and press Enter')
|
| 241 |
model_select_dropdown = gr.Dropdown(
|
|
|
|
| 248 |
with gr.Tab(label="Advanced"):
|
| 249 |
gr.Markdown(
|
| 250 |
"⚠️Be careful to change ⚠️\n\nIf you can't use it, please restore the default settings")
|
|
|
|
| 251 |
with gr.Accordion("Parameter", open=False):
|
| 252 |
temperature = gr.Slider(
|
| 253 |
minimum=-0,
|
|
|
|
| 264 |
submitBtn.click(predict, inputs=[history, chatbot, user_input, temperature, language_select_dropdown, model_select_dropdown, index_files],
|
| 265 |
outputs=[chatbot, history])
|
| 266 |
submitBtn.click(lambda: "", None, user_input)
|
| 267 |
+
demo.queue(concurrency_count=10).launch(server_name="0.0.0.0", server_port=7860)
|