Update app.py
Browse files
app.py
CHANGED
@@ -6,24 +6,15 @@ from langchain.chains.question_answering import load_qa_chain
|
|
6 |
from langchain_openai import OpenAI
|
7 |
import gradio as gr
|
8 |
|
9 |
-
# Set your OpenAI API key
|
10 |
-
os.environ["OPENAI_API_KEY"] = "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"
|
11 |
-
|
12 |
# Function to read text from a file
|
13 |
def read_txt(file_path):
|
14 |
with open(file_path, "r") as file:
|
15 |
text = file.read()
|
16 |
return text
|
17 |
|
18 |
-
# Determine the path to the content folder
|
19 |
-
content_folder = os.path.join(os.getcwd(), 'content')
|
20 |
-
|
21 |
# Load text from the specified file
|
22 |
-
|
23 |
-
|
24 |
-
# Check if the file exists before attempting to read it
|
25 |
-
if not os.path.exists(text_file_path):
|
26 |
-
raise FileNotFoundError(f"The file '{text_file_path}' does not exist.")
|
27 |
|
28 |
user_query = read_txt(text_file_path)
|
29 |
|
|
|
6 |
from langchain_openai import OpenAI
|
7 |
import gradio as gr
|
8 |
|
|
|
|
|
|
|
9 |
# Function to read text from a file
|
10 |
def read_txt(file_path):
|
11 |
with open(file_path, "r") as file:
|
12 |
text = file.read()
|
13 |
return text
|
14 |
|
|
|
|
|
|
|
15 |
# Load text from the specified file
|
16 |
+
file_path = 'lawsofpower.txt'
|
17 |
+
text_file_path = 'lawsofpower.txt'
|
|
|
|
|
|
|
18 |
|
19 |
user_query = read_txt(text_file_path)
|
20 |
|