angelesteban00 commited on
Commit
8b0f111
1 Parent(s): 37cc9ce
Files changed (4) hide show
  1. .gitignore +11 -0
  2. README.md +4 -0
  3. app.py +10 -10
  4. requirements.txt +1 -0
.gitignore ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+
4
+ # Environments
5
+ .env
6
+ .venv
7
+ env/
8
+ venv/
9
+ ENV/
10
+ env.bak/
11
+ venv.bak/
README.md CHANGED
@@ -8,5 +8,9 @@ sdk_version: 4.9.1
8
  app_file: app.py
9
  pinned: false
10
  ---
 
 
 
 
11
 
12
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
8
  app_file: app.py
9
  pinned: false
10
  ---
11
+ python3 -m venv venv
12
+ source venv/bin/activate
13
+ pip3 install -r requirements.txt
14
+ ---
15
 
16
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
app.py CHANGED
@@ -1,12 +1,12 @@
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,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)
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)
55
 
56
  # Execute the chain
57
 
 
1
  from pymongo import MongoClient
2
+ # error since Jan 2024, from langchain.embeddings.openai import OpenAIEmbeddings
3
+ from langchain_community.embeddings 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
  # 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
  # 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
 
requirements.txt CHANGED
@@ -1,4 +1,5 @@
1
  langchain
 
2
  pymongo[srv]==4.1.1
3
  bs4
4
  openai
 
1
  langchain
2
+ langchain-community
3
  pymongo[srv]==4.1.1
4
  bs4
5
  openai