File size: 602 Bytes
3817a68
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import os 
import sys


from langchain_community.document_loaders import TextLoader, DirectoryLoader
from langchain.indexes import VectorstoreIndexCreator 
from langchain.llms import OpenAI
from langchain_community.llms import OpenAI
from langchain_community.chat_models import ChatOpenAI
# from langchain_openai import OpenAIEmbedding

import constants

from dotenv import load_dotenv
import os

os.environ['OPENAI_API_KEY'] = constants.OPENAI_API_KEY

query = sys.argv[1]

loader = DirectoryLoader('.', glob="*.txt")
index = VectorstoreIndexCreator().from_loaders([loader])

print(index.query(query))