DigitalBank / query.py
joao-vectara's picture
Update query.py
b270ee7 verified
import requests
import json
def query_vectara(question, customer_id, api_key, corpus_key):
"""Queries the uploaded documents in Vectara API v2 using the correct query format."""
url = f"https://api.vectara.io/v2/corpora/{corpus_key}/query?query={question}"
headers = {
"x-api-key": api_key,
"Accept": "application/json"
}
response = requests.get(url, headers=headers)
return response.json()
def process_queries(customer_id, api_key, corpus_key):
"""Runs all predefined queries on the uploaded documents."""
questions = [
"Based on uploaded documents, what are the top four challenges of the Fintech sector in Saudi Arabia? list them in bullet points.",
"Based on uploaded documents, who are the top five leading companies in the Fintech sector in Saudi Arabia? list them in bullet points with brief information on each company.",
"Based on uploaded documents, summarize Saudi Arabia's Fintech Strategy in five key points.",
"Based on uploaded documents, describe STC Pay, its position in the market, and partners.",
"Based on uploaded documents, what are the key differences between Fintech in Saudi vs UAE?",
"Based on uploaded documents, summarize the Payment Services Provider Regulations (PSPR) in five bullet points."
]
results = {}
for question in questions:
response = query_vectara(question, customer_id, api_key, corpus_key)
results[question] = response
return results