Spaces:
Runtime error
Runtime error
DylanASHillier
commited on
Commit
•
7453741
1
Parent(s):
f6a1730
adds user password
Browse files
app.py
CHANGED
@@ -1,4 +1,7 @@
|
|
1 |
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
2 |
"""CaseStudyQA
|
3 |
|
4 |
Automatically generated by Colaboratory.
|
@@ -399,19 +402,10 @@ import asyncio
|
|
399 |
|
400 |
API_KEY = os.environ.get("API_KEY")
|
401 |
|
402 |
-
def
|
403 |
-
# Check if the provided API key matches the expected key
|
404 |
-
return api_key == API_KEY
|
405 |
-
|
406 |
-
def get_answer(question, api_key):
|
407 |
-
# Authenticate the API key
|
408 |
-
if not authenticate(api_key):
|
409 |
-
return "Invalid API key. Access denied."
|
410 |
-
|
411 |
-
# Send a POST request to the API endpoint
|
412 |
response = asyncio.run(run_query(question, query_filter={}))
|
413 |
|
414 |
-
return f"{response[
|
415 |
|
416 |
DESCRIPTION = """This tool is a demo for allowing you to ask questions over your case studies.
|
417 |
|
@@ -421,13 +415,21 @@ When you ask a question the tool will search for the most relevant case study to
|
|
421 |
# Create a Gradio interface
|
422 |
iface = gr.Interface(
|
423 |
fn=get_answer,
|
424 |
-
inputs=["text"
|
425 |
-
outputs="
|
426 |
title="Glyphic Case Study Question Answering",
|
427 |
description=DESCRIPTION,
|
428 |
theme="default",
|
429 |
-
layout="vertical"
|
|
|
430 |
)
|
431 |
|
|
|
|
|
|
|
432 |
# Launch the Gradio interface
|
433 |
-
iface.launch(
|
|
|
|
|
|
|
|
|
|
1 |
# -*- coding: utf-8 -*-
|
2 |
+
import dotenv
|
3 |
+
dotenv.load_dotenv()
|
4 |
+
|
5 |
"""CaseStudyQA
|
6 |
|
7 |
Automatically generated by Colaboratory.
|
|
|
402 |
|
403 |
API_KEY = os.environ.get("API_KEY")
|
404 |
|
405 |
+
def get_answer(question):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
406 |
response = asyncio.run(run_query(question, query_filter={}))
|
407 |
|
408 |
+
return response[0], f"<a href='{response[1]}'>{response[1]}</a>"
|
409 |
|
410 |
DESCRIPTION = """This tool is a demo for allowing you to ask questions over your case studies.
|
411 |
|
|
|
415 |
# Create a Gradio interface
|
416 |
iface = gr.Interface(
|
417 |
fn=get_answer,
|
418 |
+
inputs=["text"],
|
419 |
+
outputs=[gr.outputs.Textbox(label="Answer:"), gr.outputs.HTML(label="Source:")],
|
420 |
title="Glyphic Case Study Question Answering",
|
421 |
description=DESCRIPTION,
|
422 |
theme="default",
|
423 |
+
layout="vertical",
|
424 |
+
thumbnail="favicon.ico",
|
425 |
)
|
426 |
|
427 |
+
USERNAME = os.environ.get("DEMO_USER")
|
428 |
+
PASSWORD = os.environ.get("DEMO_PASSWORD")
|
429 |
+
|
430 |
# Launch the Gradio interface
|
431 |
+
iface.launch(
|
432 |
+
share=True,
|
433 |
+
auth=(USERNAME, PASSWORD),
|
434 |
+
auth_message="Please enter the password to access this tool, or contact Glyphic for access."
|
435 |
+
)
|