Skip to content

Commit

Permalink
support multiple output formats
Browse files Browse the repository at this point in the history
  • Loading branch information
ks6088ts committed Aug 18, 2024
1 parent 7a6291f commit fe9393f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions apps/9_streamlit_azure_document_intelligence/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,17 @@
key="AZURE_DOCUMENT_INTELLIGENCE_API_KEY",
type="password",
)
output_content_format = st.selectbox(
label="output_content_format",
key="output_content_format",
options=[
ContentFormat.MARKDOWN,
ContentFormat.TEXT,
],
index=0,
format_func=lambda x: x.value,
)

"[Azure Portal](https://portal.azure.com/)"
"[Azure OpenAI Studio](https://oai.azure.com/resource/overview)"
"[View the source code](https://github.com/ks6088ts-labs/workshop-azure-openai/blob/main/apps/9_streamlit_azure_document_intelligence/main.py)"
Expand Down Expand Up @@ -88,7 +99,7 @@ def get_client():
model_id="prebuilt-layout",
analyze_request=bytes_data,
content_type="application/octet-stream",
output_content_format=ContentFormat.TEXT,
output_content_format=output_content_format,
)
result: AnalyzeResult = poller.result()
output_encoded = base64.b64encode(
Expand All @@ -100,7 +111,7 @@ def get_client():
# Generate a link to download the result
st.markdown(
f'<a href="data:file/txt;base64,{output_encoded}" \
download="{uploaded_file.name}.json">Download Result</a>',
download="{uploaded_file.name}.{output_content_format}.json">Download Result</a>',
unsafe_allow_html=True,
)
st.write(result.as_dict())
Expand Down
Binary file modified docs/images/9_streamlit_azure_document_intelligence.main.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit fe9393f

Please sign in to comment.