Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -21,21 +21,22 @@ def construct_index(directory_path):
|
|
| 21 |
llm_predictor = LLMPredictor(llm=OpenAI(temperature=0.5, model_name="gpt-3.5-turbo", max_tokens=num_outputs))
|
| 22 |
prompt_helper = PromptHelper(max_input_size, num_outputs, max_chunk_overlap, chunk_size_limit=chunk_size_limit)
|
| 23 |
|
| 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 |
|
| 34 |
index = GPTSimpleVectorIndex.load_from_disk('index.json')
|
| 35 |
response = index.query(question, response_mode="compact")
|
| 36 |
return response.response
|
| 37 |
|
| 38 |
-
|
| 39 |
api_key = gr.inputs.Textbox(label="OpenAI API Key")
|
| 40 |
iface = gr.Interface(fn=ask_ai, inputs=["text", api_key], outputs="text", title="Chatbot")
|
| 41 |
|
|
|
|
| 21 |
llm_predictor = LLMPredictor(llm=OpenAI(temperature=0.5, model_name="gpt-3.5-turbo", max_tokens=num_outputs))
|
| 22 |
prompt_helper = PromptHelper(max_input_size, num_outputs, max_chunk_overlap, chunk_size_limit=chunk_size_limit)
|
| 23 |
|
| 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")
|
| 34 |
|
| 35 |
index = GPTSimpleVectorIndex.load_from_disk('index.json')
|
| 36 |
response = index.query(question, response_mode="compact")
|
| 37 |
return response.response
|
| 38 |
|
| 39 |
+
construct_index("data")
|
| 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 |
|