File tree Expand file tree Collapse file tree 5 files changed +28
-15
lines changed
5_streamlit_query_chat_history
8_streamlit_azure_openai_batch Expand file tree Collapse file tree 5 files changed +28
-15
lines changed Original file line number Diff line number Diff line change @@ -38,9 +38,6 @@ def store_chat_history(container: ContainerProxy):
38
38
pprint (response )
39
39
40
40
41
- # To reuse the session for Cosmos DB, just define the container globally
42
- container = get_container_client ()
43
-
44
41
with st .sidebar :
45
42
azure_openai_endpoint = st .text_input (
46
43
label = "AZURE_OPENAI_ENDPOINT" ,
@@ -116,5 +113,7 @@ def store_chat_history(container: ContainerProxy):
116
113
}
117
114
)
118
115
# !! Here's the only difference from apps/2_streamlit_chat/main.py
119
- store_chat_history (container )
116
+ store_chat_history (
117
+ container = get_container_client (),
118
+ )
120
119
st .chat_message ("assistant" ).write (msg )
Original file line number Diff line number Diff line change @@ -21,8 +21,6 @@ def get_container_client() -> ContainerProxy:
21
21
)
22
22
23
23
24
- container = get_container_client ()
25
-
26
24
with st .sidebar :
27
25
"[Azure Portal](https://portal.azure.com/)"
28
26
"[Azure OpenAI Studio](https://oai.azure.com/resource/overview)"
@@ -57,7 +55,7 @@ def convert_to_epoch(d: datetime.date) -> int:
57
55
]
58
56
59
57
with st .spinner ("Retrieving chat history. Please wait." ):
60
- items = container .query_items (
58
+ items = get_container_client () .query_items (
61
59
query = query ,
62
60
parameters = parameters ,
63
61
enable_cross_partition_query = True ,
Original file line number Diff line number Diff line change 36
36
"[Azure OpenAI Studio](https://oai.azure.com/resource/overview)"
37
37
"[View the source code](https://github.com/ks6088ts-labs/workshop-azure-openai/blob/main/apps/8_streamlit_azure_openai_batch/main.py)"
38
38
39
- client = AzureOpenAI (
40
- api_key = azure_openai_api_key ,
41
- api_version = azure_openai_api_version ,
42
- azure_endpoint = azure_openai_endpoint ,
43
- )
44
-
45
39
st .title ("8_streamlit_azure_openai_batch" )
46
40
47
41
if not azure_openai_api_key or not azure_openai_endpoint or not azure_openai_api_version or not azure_openai_gpt_model :
53
47
# ---------------
54
48
st .header ("Upload batch file" )
55
49
st .info ("Upload a file in JSON lines format (.jsonl)" )
50
+ client = AzureOpenAI (
51
+ api_key = azure_openai_api_key ,
52
+ api_version = azure_openai_api_version ,
53
+ azure_endpoint = azure_openai_endpoint ,
54
+ )
56
55
uploaded_file = st .file_uploader ("Upload an input file in JSON lines format" , type = ("jsonl" ))
57
56
if uploaded_file :
58
57
bytes_data = uploaded_file .read ()
Load Diff This file was deleted.
Original file line number Diff line number Diff line change
1
+ from streamlit .testing .v1 import AppTest
2
+
3
+
4
+ def test_smoke ():
5
+ paths = [
6
+ "apps/2_streamlit_chat/main.py" ,
7
+ "apps/4_streamlit_chat_history/main.py" ,
8
+ "apps/5_streamlit_query_chat_history/main.py" ,
9
+ # "apps/7_streamlit_chat_rag/main.py",
10
+ "apps/8_streamlit_azure_openai_batch/main.py" ,
11
+ "apps/99_streamlit_examples/main.py" ,
12
+ ]
13
+ for path in paths :
14
+ at = AppTest (
15
+ script_path = path ,
16
+ default_timeout = 60 ,
17
+ )
18
+ at .run ()
19
+ assert not at .exception
You can’t perform that action at this time.
0 commit comments