Skip to content

Commit fe9393f

Browse files
committed
support multiple output formats
1 parent 7a6291f commit fe9393f

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

apps/9_streamlit_azure_document_intelligence/main.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,17 @@
2828
key="AZURE_DOCUMENT_INTELLIGENCE_API_KEY",
2929
type="password",
3030
)
31+
output_content_format = st.selectbox(
32+
label="output_content_format",
33+
key="output_content_format",
34+
options=[
35+
ContentFormat.MARKDOWN,
36+
ContentFormat.TEXT,
37+
],
38+
index=0,
39+
format_func=lambda x: x.value,
40+
)
41+
3142
"[Azure Portal](https://portal.azure.com/)"
3243
"[Azure OpenAI Studio](https://oai.azure.com/resource/overview)"
3344
"[View the source code](https://github.com/ks6088ts-labs/workshop-azure-openai/blob/main/apps/9_streamlit_azure_document_intelligence/main.py)"
@@ -88,7 +99,7 @@ def get_client():
8899
model_id="prebuilt-layout",
89100
analyze_request=bytes_data,
90101
content_type="application/octet-stream",
91-
output_content_format=ContentFormat.TEXT,
102+
output_content_format=output_content_format,
92103
)
93104
result: AnalyzeResult = poller.result()
94105
output_encoded = base64.b64encode(
@@ -100,7 +111,7 @@ def get_client():
100111
# Generate a link to download the result
101112
st.markdown(
102113
f'<a href="data:file/txt;base64,{output_encoded}" \
103-
download="{uploaded_file.name}.json">Download Result</a>',
114+
download="{uploaded_file.name}.{output_content_format}.json">Download Result</a>',
104115
unsafe_allow_html=True,
105116
)
106117
st.write(result.as_dict())
43.1 KB
Loading

0 commit comments

Comments
 (0)