Skip to content

Commit 3f32f9f

Browse files
committed
updating reference
1 parent 83dbe9a commit 3f32f9f

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

articles/ai-services/openai/references/on-your-data.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ description: Learn how to use Azure OpenAI On Your Data Python & REST API.
55
manager: nitinme
66
ms.service: azure-ai-openai
77
ms.topic: conceptual
8-
ms.date: 06/13/2024
8+
ms.date: 07/18/2024
99
author: mrbullwinkle
1010
ms.author: mbullwin
1111
recommendations: false
@@ -174,6 +174,20 @@ completion = client.chat.completions.create(
174174

175175
print(completion.model_dump_json(indent=2))
176176

177+
# render the citations
178+
179+
content = completion.choices[0].message.content
180+
context = completion.choices[0].message.context
181+
for citation_index, citation in enumerate(context["citations"]):
182+
citation_reference = f"[doc{citation_index + 1}]"
183+
url = "https://example.com/?redirect=" + citation["url"] # replace with actual host and encode the URL
184+
filepath = citation["filepath"]
185+
title = citation["title"]
186+
snippet = citation["content"]
187+
chunk_id = citation["chunk_id"]
188+
replaced_html = f"<a href='{url}' title='{title}\n{snippet}''>(See from file {filepath}, Part {chunk_id})</a>"
189+
content = content.replace(citation_reference, replaced_html)
190+
print(content)
177191
```
178192

179193
# [REST](#tab/rest)

0 commit comments

Comments
 (0)