Hello,
I am implementing RAG solution as per Databricks cookbook. Review App is working, references are provided as text chunks.
I need to build functionality to open pdf file on a specific page as a reference. Is there a way to change ReviewApp to open pdf file instead of opening text?
Or do I need to build chainlit app with PdfViewer elements to provide this functionality?
How can I call serving point to return source documents?
I am using this code atm and sources are not returned:
import os
import requests
import numpy as np
import pandas as pd
import json
def create_tf_serving_json(data):
return {'inputs': {name: data[name] for name in data.keys()} if isinstance(data, dict) else data}
def score_model(dataset):
url = 'https://XXX/invocations'
headers = {'Authorization': f'Bearer {DATABRICKS_TOKEN}', 'Content-Type': 'application/json'}
ds_dict = {'dataframe_split': dataset.to_dict(orient='split')} if isinstance(dataset, pd.DataFrame) else create_tf_serving_json(dataset)
data_json = json.dumps(ds_dict, allow_nan=True)
print(data_json)
response = requests.request(method='POST', headers=headers, url=url, data=data_json})
if response.status_code != 200:
raise Exception(f'Request failed with status {response.status_code}, {response.text}')
return response.json()
response = score_model({
"messages": [
{
"role": "user",
"content": "What is LLM?"
}
]
})
for item in response.items():
print(item)