angelesteban00 commited on
Commit
37cc9ce
1 Parent(s): bd3d055

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -10
app.py CHANGED
@@ -1,12 +1,12 @@
1
  from pymongo import MongoClient
2
- # error since Jan 2024, from langchain.embeddings.openai import OpenAIEmbeddings
3
- from langchain_community.embeddings.openai import OpenAIEmbeddings
4
- # error since Jan 2024, from langchain.vectorstores import MongoDBAtlasVectorSearch
5
- from langchain_community.vectorstores import MongoDBAtlasVectorSearch
6
- # error since Jan 2024, from langchain.document_loaders import DirectoryLoader
7
- from langchain_community.document_loaders import DirectoryLoader
8
- # error since Jan 2024, from langchain.llms import OpenAI
9
- from langchain_community.llms import OpenAI
10
  from langchain.chains import RetrievalQA
11
  import gradio as gr
12
  from gradio.themes.base import Base
@@ -41,7 +41,7 @@ def query_data(query,openai_api_key,mongo_uri):
41
  # If it's not specified (for example like in the code below),
42
  # then the default OpenAI model used in LangChain is OpenAI GPT-3.5-turbo, as of August 30, 2023
43
 
44
- llm = OpenAI(openai_api_key=openai_api_key, temperature=0, model_name='gpt-4-1106-preview')
45
 
46
 
47
  # Get VectorStoreRetriever: Specifically, Retriever for MongoDB VectorStore.
@@ -51,7 +51,7 @@ def query_data(query,openai_api_key,mongo_uri):
51
  # Load "stuff" documents chain. Stuff documents chain takes a list of documents,
52
  # inserts them all into a prompt and passes that prompt to an LLM.
53
 
54
- qa = RetrievalQA.from_chain_type(llm, chain_type="stuff", retriever=retriever, model_name='gpt-4-1106-preview')
55
 
56
  # Execute the chain
57
 
 
1
  from pymongo import MongoClient
2
+ from langchain.embeddings import OpenAIEmbeddings
3
+ #from langchain_community.embeddings.openai import OpenAIEmbeddings
4
+ from langchain.vectorstores import MongoDBAtlasVectorSearch
5
+ #from langchain_community.vectorstores import MongoDBAtlasVectorSearch
6
+ from langchain.document_loaders import DirectoryLoader
7
+ #from langchain_community.document_loaders import DirectoryLoader
8
+ from langchain.llms import OpenAI
9
+ #from langchain_community.llms import OpenAI
10
  from langchain.chains import RetrievalQA
11
  import gradio as gr
12
  from gradio.themes.base import Base
 
41
  # If it's not specified (for example like in the code below),
42
  # then the default OpenAI model used in LangChain is OpenAI GPT-3.5-turbo, as of August 30, 2023
43
 
44
+ llm = OpenAI(openai_api_key=openai_api_key, temperature=0)
45
 
46
 
47
  # Get VectorStoreRetriever: Specifically, Retriever for MongoDB VectorStore.
 
51
  # Load "stuff" documents chain. Stuff documents chain takes a list of documents,
52
  # inserts them all into a prompt and passes that prompt to an LLM.
53
 
54
+ qa = RetrievalQA.from_chain_type(llm, chain_type="stuff", retriever=retriever)
55
 
56
  # Execute the chain
57