Spaces:
Runtime error
Runtime error
Commit ·
89ab7c2
1
Parent(s): 1c36cb5
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,38 +1,16 @@
|
|
| 1 |
-
from gpt_index import SimpleDirectoryReader, GPTListIndex, GPTSimpleVectorIndex, LLMPredictor, PromptHelper
|
| 2 |
-
from langchain.chat_models import ChatOpenAI
|
| 3 |
-
import gradio as gr
|
| 4 |
-
import sys
|
| 5 |
import os
|
| 6 |
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
index = GPTSimpleVectorIndex(documents, llm_predictor=llm_predictor, prompt_helper=prompt_helper)
|
| 22 |
-
|
| 23 |
-
index.save_to_disk('index.json')
|
| 24 |
-
|
| 25 |
-
return index
|
| 26 |
-
|
| 27 |
-
def chatbot(input_text):
|
| 28 |
-
index = GPTSimpleVectorIndex.load_from_disk('index.json')
|
| 29 |
-
response = index.query(input_text, response_mode="compact")
|
| 30 |
-
return response.response
|
| 31 |
-
|
| 32 |
-
iface = gr.Interface(fn=chatbot,
|
| 33 |
-
inputs=gr.components.Textbox(lines=7, label="Enter your text"),
|
| 34 |
-
outputs="text",
|
| 35 |
-
title="Custom-trained AI Chatbot")
|
| 36 |
-
|
| 37 |
-
index = construct_index("docs")
|
| 38 |
-
iface.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import os
|
| 2 |
|
| 3 |
+
def delete_files_in_folder(folder_path):
|
| 4 |
+
try:
|
| 5 |
+
for filename in os.listdir(folder_path):
|
| 6 |
+
file_path = os.path.join(folder_path, filename)
|
| 7 |
+
if os.path.isfile(file_path):
|
| 8 |
+
os.remove(file_path)
|
| 9 |
+
print(f"Deleted: {filename}")
|
| 10 |
+
print("All files deleted successfully.")
|
| 11 |
+
except Exception as e:
|
| 12 |
+
print(f"An error occurred: {e}")
|
| 13 |
+
|
| 14 |
+
if __name__ == "__main__":
|
| 15 |
+
folder_to_clear = "docs" # Change this to your actual folder path
|
| 16 |
+
delete_files_in_folder(folder_to_clear)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|