Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -46,8 +46,7 @@ def analyze_question(question):
|
|
| 46 |
max_tokens=2000,
|
| 47 |
temperature=0.0
|
| 48 |
)
|
| 49 |
-
|
| 50 |
-
|
| 51 |
if response.choices[0].message.content == "Not a question":
|
| 52 |
yield "Question Analysis Done", "The question is not a question, can not continue"
|
| 53 |
|
|
@@ -60,6 +59,9 @@ def analyze_question(question):
|
|
| 60 |
question_analysis_string += cleaned_line + "\n"
|
| 61 |
|
| 62 |
yield "Question Analysis Done", question_analysis_string
|
|
|
|
|
|
|
|
|
|
| 63 |
|
| 64 |
except openai.OpenAIError as e:
|
| 65 |
return (f"An error occurred: {str(e)}")
|
|
@@ -77,7 +79,10 @@ for metadata in stored_documents['metadatas']:
|
|
| 77 |
document_list = list(document_names)
|
| 78 |
document_list.insert(0, "All Documents")
|
| 79 |
|
| 80 |
-
with gr.Blocks(
|
|
|
|
|
|
|
|
|
|
| 81 |
with gr.Row():
|
| 82 |
with gr.Column(scale=1):
|
| 83 |
|
|
@@ -86,12 +91,17 @@ with gr.Blocks() as demo:
|
|
| 86 |
label="Document",
|
| 87 |
)
|
| 88 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 89 |
|
| 90 |
temperature_slider = gr.Slider(
|
| 91 |
minimum=0,
|
| 92 |
maximum=1,
|
| 93 |
step=0.1,
|
| 94 |
-
#value=0.3,
|
| 95 |
label="Temperature",
|
| 96 |
info="Controls randomness: 0 = deterministic, 1 = creative/unexpected answers. If you can't get an answer try increasing the temperature but keep in mind that the accuracy can lower by doing this."
|
| 97 |
)
|
|
@@ -99,7 +109,8 @@ with gr.Blocks() as demo:
|
|
| 99 |
|
| 100 |
question_input = gr.Textbox(
|
| 101 |
label="Enter your question",
|
| 102 |
-
placeholder="Type your question here..."
|
|
|
|
| 103 |
)
|
| 104 |
|
| 105 |
|
|
@@ -111,7 +122,8 @@ with gr.Blocks() as demo:
|
|
| 111 |
question_analysis_output = gr.Textbox(
|
| 112 |
label="Question Analysis",
|
| 113 |
placeholder="The analysis will be shown here...",
|
| 114 |
-
interactive=False
|
|
|
|
| 115 |
)
|
| 116 |
|
| 117 |
with gr.Row():
|
|
|
|
| 46 |
max_tokens=2000,
|
| 47 |
temperature=0.0
|
| 48 |
)
|
| 49 |
+
|
|
|
|
| 50 |
if response.choices[0].message.content == "Not a question":
|
| 51 |
yield "Question Analysis Done", "The question is not a question, can not continue"
|
| 52 |
|
|
|
|
| 59 |
question_analysis_string += cleaned_line + "\n"
|
| 60 |
|
| 61 |
yield "Question Analysis Done", question_analysis_string
|
| 62 |
+
|
| 63 |
+
|
| 64 |
+
|
| 65 |
|
| 66 |
except openai.OpenAIError as e:
|
| 67 |
return (f"An error occurred: {str(e)}")
|
|
|
|
| 79 |
document_list = list(document_names)
|
| 80 |
document_list.insert(0, "All Documents")
|
| 81 |
|
| 82 |
+
with gr.Blocks(css="""
|
| 83 |
+
#question_input_box {height: 150px;}
|
| 84 |
+
#question_analysis_box {height: 400px;}
|
| 85 |
+
""") as demo:
|
| 86 |
with gr.Row():
|
| 87 |
with gr.Column(scale=1):
|
| 88 |
|
|
|
|
| 91 |
label="Document",
|
| 92 |
)
|
| 93 |
|
| 94 |
+
quotes_to_fetch = gr.Slider(
|
| 95 |
+
minimum=1,
|
| 96 |
+
maximum=5,
|
| 97 |
+
step=1,
|
| 98 |
+
label="How many quotes you want from the source",
|
| 99 |
+
)
|
| 100 |
|
| 101 |
temperature_slider = gr.Slider(
|
| 102 |
minimum=0,
|
| 103 |
maximum=1,
|
| 104 |
step=0.1,
|
|
|
|
| 105 |
label="Temperature",
|
| 106 |
info="Controls randomness: 0 = deterministic, 1 = creative/unexpected answers. If you can't get an answer try increasing the temperature but keep in mind that the accuracy can lower by doing this."
|
| 107 |
)
|
|
|
|
| 109 |
|
| 110 |
question_input = gr.Textbox(
|
| 111 |
label="Enter your question",
|
| 112 |
+
placeholder="Type your question here...",
|
| 113 |
+
elem_id="question_input_box"
|
| 114 |
)
|
| 115 |
|
| 116 |
|
|
|
|
| 122 |
question_analysis_output = gr.Textbox(
|
| 123 |
label="Question Analysis",
|
| 124 |
placeholder="The analysis will be shown here...",
|
| 125 |
+
interactive=False,
|
| 126 |
+
elem_id="question_analysis_box"
|
| 127 |
)
|
| 128 |
|
| 129 |
with gr.Row():
|