Tonic commited on
Commit
cd8cf8a
·
1 Parent(s): 368b82e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -3
app.py CHANGED
@@ -17,15 +17,20 @@ cohere_api_key = os.getenv('COHERE')
17
  weaviate_api_key = os.getenv('WEAVIATE')
18
  weaviate_url = os.getenv('WEAVIATE_URL')
19
 
 
20
  # Weaviate connection
21
  auth_config = weaviate.auth.AuthApiKey(api_key=weaviate_api_key)
22
- client = weaviate.Client(url=weaviate_url, auth_client_secret=auth_config, additional_headers={"X-Cohere-Api-Key": cohere_api_key})
23
-
24
  # Initialize vectorstore
25
- vectorstore = weaviate(client, index_name="Articles", text_key="text")
26
  vectorstore._query_attrs = ["text", "title", "url", "views", "lang", "_additional {distance}"]
27
  vectorstore.embedding = CohereEmbeddings(model="embed-multilingual-v2.0", cohere_api_key=cohere_api_key)
28
 
 
 
 
 
29
  def embed_pdf(file, collection_name):
30
  # Save the uploaded file
31
  filename = file.name
 
17
  weaviate_api_key = os.getenv('WEAVIATE')
18
  weaviate_url = os.getenv('WEAVIATE_URL')
19
 
20
+
21
  # Weaviate connection
22
  auth_config = weaviate.auth.AuthApiKey(api_key=weaviate_api_key)
23
+ client = weaviate.client(url=weaviate_url, auth_client_secret=auth_config,
24
+ additional_headers={"X-Cohere-Api-Key": cohere_api_key})
25
  # Initialize vectorstore
26
+ vectorstore = Weaviate(client, index_name="Articles", text_key="text")
27
  vectorstore._query_attrs = ["text", "title", "url", "views", "lang", "_additional {distance}"]
28
  vectorstore.embedding = CohereEmbeddings(model="embed-multilingual-v2.0", cohere_api_key=cohere_api_key)
29
 
30
+ # Initialize OpenAI and RetrievalQA
31
+ llm = OpenAI(temperature=0, openai_api_key=openai_api_key)
32
+ qa = RetrievalQA.from_chain_type(llm, retriever=vectorstore.as_retriever())
33
+
34
  def embed_pdf(file, collection_name):
35
  # Save the uploaded file
36
  filename = file.name