Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -24,10 +24,12 @@ def construct_index(directory_path):
|
|
| 24 |
|
| 25 |
|
| 26 |
os.environ["OPENAI_API_KEY"] = "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"
|
|
|
|
| 27 |
def ask_ai(question,api_key):
|
| 28 |
|
| 29 |
if openai_api_key == "":
|
| 30 |
-
|
|
|
|
| 31 |
else:
|
| 32 |
os.environ["OPENAI_API_KEY"] = openai_api_key
|
| 33 |
construct_index("data")
|
|
@@ -36,7 +38,7 @@ def ask_ai(question,api_key):
|
|
| 36 |
response = index.query(question, response_mode="compact")
|
| 37 |
return response.response
|
| 38 |
|
| 39 |
-
|
| 40 |
api_key = gr.inputs.Textbox(label="OpenAI API Key")
|
| 41 |
iface = gr.Interface(fn=ask_ai, inputs=["text", api_key], outputs="text", title="Chatbot")
|
| 42 |
|
|
|
|
| 24 |
|
| 25 |
|
| 26 |
os.environ["OPENAI_API_KEY"] = "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"
|
| 27 |
+
construct_index("data")
|
| 28 |
def ask_ai(question,api_key):
|
| 29 |
|
| 30 |
if openai_api_key == "":
|
| 31 |
+
os.environ["OPENAI_API_KEY"] = "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"
|
| 32 |
+
construct_index("data")
|
| 33 |
else:
|
| 34 |
os.environ["OPENAI_API_KEY"] = openai_api_key
|
| 35 |
construct_index("data")
|
|
|
|
| 38 |
response = index.query(question, response_mode="compact")
|
| 39 |
return response.response
|
| 40 |
|
| 41 |
+
|
| 42 |
api_key = gr.inputs.Textbox(label="OpenAI API Key")
|
| 43 |
iface = gr.Interface(fn=ask_ai, inputs=["text", api_key], outputs="text", title="Chatbot")
|
| 44 |
|