Spaces:
Runtime error
Runtime error
File size: 1,482 Bytes
859e525 dddba03 859e525 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
import os
import streamlit as st
import requests
import qdrant_client
client = qdrant_client.QdrantClient(host="localhost", port=6333, grpc_port=6334, 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)
# st.error(response.text)
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=10,
)
#results
context = "Hotel Name: " + "\n".join(r.document for r in results )
#context
metaprompt = f"""
Based on the context provided, provide information about the Question. You can give multiple points based on the question asked or 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) |