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