Spaces:
Sleeping
Sleeping
jet-taekyo
commited on
Commit
•
bc0a1d6
1
Parent(s):
86aaf41
modify load_env() for main branch
Browse files
app.py
CHANGED
@@ -73,21 +73,6 @@ def process_text_file(file: AskFileResponse)-> List[Document]:
|
|
73 |
document_loader = base_loader(temp_file_path)
|
74 |
|
75 |
|
76 |
-
|
77 |
-
|
78 |
-
# if file.name.endswith('.pdf'):
|
79 |
-
# with tempfile.NamedTemporaryFile(mode="w", delete=False, suffix=".pdf") as temp_file:
|
80 |
-
# temp_file_path = temp_file.name
|
81 |
-
# with open(temp_file_path, "wb") as f:
|
82 |
-
# f.write(file.content)
|
83 |
-
# document_loader = PyPDFLoader(temp_file_path)
|
84 |
-
# elif file.name.endswith('.txt'):
|
85 |
-
# with tempfile.NamedTemporaryFile(mode="w", delete=False, suffix=".txt") as temp_file:
|
86 |
-
# temp_file_path = temp_file.name
|
87 |
-
# with open(temp_file_path, "wb") as f:
|
88 |
-
# f.write(file.content)
|
89 |
-
# document_loader = TextLoader(temp_file_path, autodetect_encoding=True)
|
90 |
-
|
91 |
documents = document_loader.load()
|
92 |
text_splitter = RecursiveCharacterTextSplitter()
|
93 |
splitted_documents = [x.page_content for x in text_splitter.transform_documents(documents)]
|
|
|
73 |
document_loader = base_loader(temp_file_path)
|
74 |
|
75 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
76 |
documents = document_loader.load()
|
77 |
text_splitter = RecursiveCharacterTextSplitter()
|
78 |
splitted_documents = [x.page_content for x in text_splitter.transform_documents(documents)]
|
langchain_wrappers/langchain_chat_models.py
CHANGED
@@ -4,10 +4,7 @@ from typing import Optional
|
|
4 |
from langchain_openai import ChatOpenAI
|
5 |
|
6 |
|
7 |
-
|
8 |
-
load_dotenv(os.path.join(os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe()))) , '.env'))
|
9 |
-
|
10 |
-
# load_dotenv()
|
11 |
class MyChatOpenAI:
|
12 |
@classmethod
|
13 |
def from_model(
|
|
|
4 |
from langchain_openai import ChatOpenAI
|
5 |
|
6 |
|
7 |
+
load_dotenv()
|
|
|
|
|
|
|
8 |
class MyChatOpenAI:
|
9 |
@classmethod
|
10 |
def from_model(
|
langchain_wrappers/langchain_embedding_models.py
CHANGED
@@ -3,10 +3,8 @@ from dotenv import load_dotenv
|
|
3 |
from typing import Optional
|
4 |
from langchain_openai.embeddings import OpenAIEmbeddings
|
5 |
|
6 |
-
import inspect
|
7 |
-
load_dotenv(os.path.join(os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe()))) , '.env'))
|
8 |
|
9 |
-
|
10 |
class MyOpenAIEmbeddings:
|
11 |
@classmethod
|
12 |
def from_model(
|
|
|
3 |
from typing import Optional
|
4 |
from langchain_openai.embeddings import OpenAIEmbeddings
|
5 |
|
|
|
|
|
6 |
|
7 |
+
load_dotenv()
|
8 |
class MyOpenAIEmbeddings:
|
9 |
@classmethod
|
10 |
def from_model(
|