-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
32 lines (24 loc) · 845 Bytes
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import os
import textwrap
import chromadb
import langchain
import openai
from langchain.chains import RetrievalQA
from langchain.chat_models import ChatOpenAI
from langchain.document_loaders import TextLoader, UnstructuredPDFLoader, YoutubeLoader
from langchain.embeddings import HuggingFaceEmbeddings, OpenAIEmbeddings
from langchain.indexes import VectorstoreIndexCreator
from langchain.llms import OpenAI
from langchain.text_splitter import RecursiveCharacterTextSplitter
from langchain.vectorstores import Chroma
import re
os.environ['OPENAI_API_KEY'] = ""
def run_query(query, mode):
model = OpenAI(temperature=0)
result = model(query)
clean_result = re.sub(r"\n", "", result)
return clean_result
if __name__ == '__main__':
query = input("enter your query")
ans = run_query(query, 'accurate')
print(ans)