-
Self Checks
1. Is this request related to a challenge you're experiencing? Tell me about your story.How to obtain access links to the images returned by knowledge base retrieval, as shown in! image 2. Additional context or commentsRetrieve only results from the knowledge base! [image] (/files/04e66676-fee-4925-b761-506a6680a0a87/file preview, signature not obtained, how to calculate on your own? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
|
The image URLs from knowledge base retrieval use HMAC-SHA256 signatures. Here's how to calculate them: Signature Format: Python Example: import os, time, hmac, hashlib, base64, urllib.parse
def get_signed_image_url(upload_file_id, secret_key, files_url):
timestamp = str(int(time.time()))
nonce = os.urandom(16).hex()
msg = f"image-preview|{upload_file_id}|{timestamp}|{nonce}"
sign = hmac.new(secret_key.encode(), msg.encode(), hashlib.sha256).digest()
encoded_sign = base64.urlsafe_b64encode(sign).decode()
query = {"timestamp": timestamp, "nonce": nonce, "sign": encoded_sign}
return f"{files_url}/files/{upload_file_id}/image-preview?{urllib.parse.urlencode(query)}"Important Notes:
If you're seeing unsigned URLs returned from the Knowledge Base Retrieval API, this may be a known issue in some versions where you'll need to generate signatures manually using the code above. To reply, just mention @dosu. How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other |
Beta Was this translation helpful? Give feedback.
ok thanks, I find the retrieve have sign_content field