from dotenv import load_dotenv
from langchain.vectorstores import Chroma
import os
load_dotenv('environment.env')
openai_api_key = os.getenv("OPENAI_API_KEY")
from RAG_strategy import taide_llm, multi_query, naive_rag
from langchain.vectorstores import FAISS
from langchain.embeddings import OpenAIEmbeddings
from langchain.document_loaders import TextLoader
from langchain.text_splitter import CharacterTextSplitter



# Load and prepare a sample document
loader = TextLoader("test_data.txt")
documents = loader.load()
text_splitter = CharacterTextSplitter(chunk_size=1000, chunk_overlap=0)
docs = text_splitter.split_documents(documents)

# Create a vector store
embeddings = OpenAIEmbeddings()
vectorstore = Chroma.from_documents(docs, embeddings)
retriever = vectorstore.as_retriever()

# Test multi_query
print("\nTesting multi_query:")
question = "什麼是碳排放獎勵辦法？"
answer, docs = multi_query(question, retriever, [])
print(f"Question: {question}")
print(f"Answer: {answer}")