Spaces:
No application file
No application file
import os | |
import streamlit as st | |
import requests | |
import qdrant_client | |
client = qdrant_client.QdrantClient("http://localhost:6333", prefer_grpc=True) | |
client.get_collections() | |
url = "https://api-ares.traversaal.ai/live/predict" | |
headers = { | |
"x-api-key": "ares_5e61d51f3abc8feb37710d8784fa49e11426ee25d7ec5236b80362832f306ed2", | |
"content-type": "application/json" | |
} | |
st.title('#@ck-RAG') | |
def inference(query): | |
payload = { "query": [query] } | |
response = requests.post(url, json=payload, headers=headers) | |
# st.error(response) | |
response_text=response.json().get('data').get('response_text') | |
urls=response.json().get('data').get('web_url') | |
return response_text, urls | |
prompt = st.text_input('Enter a query', value='') | |
if prompt: | |
results = client.query( | |
collection_name="knowledge-base", | |
query_text=prompt, | |
limit=1, | |
) | |
#results | |
context = "\n".join(r.document for r in results) | |
context | |
metaprompt = f""" | |
You are a Trip advisor and tour guide who provides information about hotels and restaurants in a city. | |
Answer the following question using the provided context. | |
Question: {prompt.strip()} | |
Context: | |
{context.strip()} | |
Answer: | |
""" | |
response_text,urls = inference(metaprompt) | |
# Look at the full metaprompt | |
# print(metaprompt) | |
st.write('Query Results:') | |
st.write(response_text) | |
st.write('Sources:') | |
st.write(urls) |