Spaces:
Runtime error
Runtime error
DylanonWic
commited on
Update ragChain.py
Browse files- ragChain.py +7 -5
ragChain.py
CHANGED
@@ -1,16 +1,18 @@
|
|
|
|
1 |
import os
|
2 |
from langchain_community.document_loaders import TextLoader, WebBaseLoader
|
3 |
-
from langchain_openai import ChatOpenAI
|
4 |
-
from langchain_chroma import Chroma
|
5 |
from langchain_core.output_parsers import StrOutputParser
|
6 |
from langchain_core.runnables import RunnablePassthrough
|
7 |
-
from langchain_openai import OpenAIEmbeddings
|
8 |
-
from langchain_text_splitters import RecursiveCharacterTextSplitter
|
9 |
from langchain_core.prompts import ChatPromptTemplate
|
|
|
|
|
|
|
|
|
10 |
|
11 |
|
12 |
|
13 |
# Load environment variables from the .env file
|
|
|
14 |
os.getenv('OPENAI_API_KEY')
|
15 |
|
16 |
os.environ["LANGCHAIN_TRACING_V2"] = "true"
|
@@ -46,7 +48,7 @@ prompt = ChatPromptTemplate.from_messages(
|
|
46 |
[
|
47 |
(
|
48 |
"assistant",
|
49 |
-
"""You are an assistant for question-answering tasks. Use the following pieces of retrieved context to answer the question. If you don't know the answer, just say that you don't know. Use three sentences maximum and keep the answer concise. Answer in the language
|
50 |
Question: {question}
|
51 |
Context: {context}
|
52 |
Answer:"""
|
|
|
1 |
+
from dotenv import load_dotenv
|
2 |
import os
|
3 |
from langchain_community.document_loaders import TextLoader, WebBaseLoader
|
|
|
|
|
4 |
from langchain_core.output_parsers import StrOutputParser
|
5 |
from langchain_core.runnables import RunnablePassthrough
|
|
|
|
|
6 |
from langchain_core.prompts import ChatPromptTemplate
|
7 |
+
from langchain_text_splitters import RecursiveCharacterTextSplitter
|
8 |
+
from langchain_chroma import Chroma
|
9 |
+
from langchain_openai import OpenAIEmbeddings
|
10 |
+
from langchain_openai import ChatOpenAI
|
11 |
|
12 |
|
13 |
|
14 |
# Load environment variables from the .env file
|
15 |
+
load_dotenv("./API_keys.env")
|
16 |
os.getenv('OPENAI_API_KEY')
|
17 |
|
18 |
os.environ["LANGCHAIN_TRACING_V2"] = "true"
|
|
|
48 |
[
|
49 |
(
|
50 |
"assistant",
|
51 |
+
"""You are an assistant for question-answering tasks. Use the following pieces of retrieved context to answer the question. If you don't know the answer, just say that you don't know. Use three sentences maximum and keep the answer concise. Answer in the same language as question section. Your are a male.
|
52 |
Question: {question}
|
53 |
Context: {context}
|
54 |
Answer:"""
|