sanjeevl10 commited on
Commit
2459c07
1 Parent(s): 55e105e

added openai call

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -7,7 +7,7 @@ from langchain_text_splitters import RecursiveCharacterTextSplitter
7
  from langchain.document_loaders import PyMuPDFLoader
8
  from langchain_huggingface import HuggingFaceEndpointEmbeddings
9
  from langchain_core.prompts import PromptTemplate
10
- from langchain_openai.embeddings import OpenAIEmbeddings
11
  from langchain.schema.runnable.config import RunnableConfig
12
  from langchain_community.vectorstores import Qdrant
13
 
@@ -43,13 +43,13 @@ documents = PyMuPDFLoader("data/airbnb-10k.pdf").load()
43
 
44
  ### 2. CREATE TEXT SPLITTER AND SPLIT DOCUMENTS
45
  text_splitter = RecursiveCharacterTextSplitter(
46
- chunk_size=250,
47
  chunk_overlap=0
48
  )
49
  split_documents = text_splitter.split_documents(documents)
50
 
51
  ### 3. LOAD open ai EMBEDDINGS
52
- embeddings = OpenAIEmbeddings(model="text-embedding-ada-002")
53
 
54
  #Initialize the Vector Store
55
  if os.path.exists("./vectorstore"):
@@ -101,7 +101,7 @@ rag_prompt = PromptTemplate.from_template(RAG_PROMPT_TEMPLATE)
101
  ### 1. CREATE HUGGINGFACE ENDPOINT FOR LLM
102
  hf_llm = HuggingFaceEndpoint(
103
  endpoint_url=HF_LLM_ENDPOINT,
104
- max_new_tokens=256,
105
  top_k=10,
106
  top_p=0.95,
107
  typical_p=0.95,
 
7
  from langchain.document_loaders import PyMuPDFLoader
8
  from langchain_huggingface import HuggingFaceEndpointEmbeddings
9
  from langchain_core.prompts import PromptTemplate
10
+ from openai import OpenAI
11
  from langchain.schema.runnable.config import RunnableConfig
12
  from langchain_community.vectorstores import Qdrant
13
 
 
43
 
44
  ### 2. CREATE TEXT SPLITTER AND SPLIT DOCUMENTS
45
  text_splitter = RecursiveCharacterTextSplitter(
46
+ chunk_size=1000,
47
  chunk_overlap=0
48
  )
49
  split_documents = text_splitter.split_documents(documents)
50
 
51
  ### 3. LOAD open ai EMBEDDINGS
52
+ embeddings = OpenAI(model="text-embedding-ada-002")
53
 
54
  #Initialize the Vector Store
55
  if os.path.exists("./vectorstore"):
 
101
  ### 1. CREATE HUGGINGFACE ENDPOINT FOR LLM
102
  hf_llm = HuggingFaceEndpoint(
103
  endpoint_url=HF_LLM_ENDPOINT,
104
+ max_new_tokens=512,
105
  top_k=10,
106
  top_p=0.95,
107
  typical_p=0.95,