Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -21,19 +21,17 @@ def construct_index(directory_path):
|
|
21 |
prompt_helper = PromptHelper(max_input_size, num_outputs, max_chunk_overlap, chunk_size_limit=chunk_size_limit)
|
22 |
|
23 |
|
24 |
-
def ask_ai(question,
|
|
|
|
|
|
|
25 |
index = GPTSimpleVectorIndex.load_from_disk('index.json')
|
26 |
response = index.query(question, response_mode="compact")
|
27 |
return response.response
|
28 |
|
29 |
|
30 |
-
|
31 |
-
|
32 |
-
os.environ["OPENAI_API_KEY"] = "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"
|
33 |
-
|
34 |
construct_index("data")
|
35 |
|
|
|
36 |
|
37 |
-
iface
|
38 |
-
|
39 |
-
iface.launch()
|
|
|
21 |
prompt_helper = PromptHelper(max_input_size, num_outputs, max_chunk_overlap, chunk_size_limit=chunk_size_limit)
|
22 |
|
23 |
|
24 |
+
def ask_ai(question, api_key):
|
25 |
+
if api_key == "":
|
26 |
+
api_key = "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"
|
27 |
+
os.environ["OPENAI_API_KEY"] = api_key
|
28 |
index = GPTSimpleVectorIndex.load_from_disk('index.json')
|
29 |
response = index.query(question, response_mode="compact")
|
30 |
return response.response
|
31 |
|
32 |
|
|
|
|
|
|
|
|
|
33 |
construct_index("data")
|
34 |
|
35 |
+
iface = gr.Interface(fn=ask_ai, inputs=["text", "text"] ,outputs="text", title="Jim's Chatbot")
|
36 |
|
37 |
+
iface.launch()
|
|
|
|