28
28
key = "AZURE_DOCUMENT_INTELLIGENCE_API_KEY" ,
29
29
type = "password" ,
30
30
)
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
+
31
42
"[Azure Portal](https://portal.azure.com/)"
32
43
"[Azure OpenAI Studio](https://oai.azure.com/resource/overview)"
33
44
"[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():
88
99
model_id = "prebuilt-layout" ,
89
100
analyze_request = bytes_data ,
90
101
content_type = "application/octet-stream" ,
91
- output_content_format = ContentFormat . TEXT ,
102
+ output_content_format = output_content_format ,
92
103
)
93
104
result : AnalyzeResult = poller .result ()
94
105
output_encoded = base64 .b64encode (
@@ -100,7 +111,7 @@ def get_client():
100
111
# Generate a link to download the result
101
112
st .markdown (
102
113
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>' ,
104
115
unsafe_allow_html = True ,
105
116
)
106
117
st .write (result .as_dict ())
0 commit comments