Spaces:
Runtime error
Runtime error
import os | |
import sys | |
import openai | |
from langchain_community.chains import ConversationalRetrievalChain, RetrievalQA | |
from langchain_community.chat_models import ChatOpenAI | |
from langchain_community.document_loaders import DirectoryLoader, TextLoader | |
from langchain_community.embeddings import OpenAIEmbeddings | |
from langchain_community.indexes import VectorstoreIndexCreator | |
from langchain_community.indexes.vectorstore import VectorStoreIndexWrapper | |
from langchain_community.llms import OpenAI | |
from langchain_community.vectorstores import Chroma | |
os.environ["OPENAI_API_KEY"] = "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" | |
if len(sys.argv) > 1: | |
query = sys.argv[1] | |
#loader = TextLoader("data/data.txt") # Use this line if you only need data.txt | |
loader = DirectoryLoader(".",glob="*.txt") | |
index = VectorstoreIndexCreator().from_loaders([loader]) | |
llm=ChatOpenAI(model="gpt-3.5-turbo-16k") | |
print(index.query(query,llm)) |