Skip to content

Commit 58eb0b9

Browse files
Update old diff blocks
1 parent d43d2fe commit 58eb0b9

6 files changed

Lines changed: 65 additions & 65 deletions

File tree

content/deploy/community-cloud/get-started/quickstart.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ You will sign in to your GitHub account during this process. Community Cloud wil
8181

8282
1. Go to the app's entrypoint file (`streamlit_app.py`) in the left pane, and change line 3 by adding "Streamlit" inside `st.title`.
8383

84-
```diff
84+
```diff-python
8585
-st.title("🎈 My new app")
8686
+st.title("🎈 My new Streamlit app")
8787
```

content/develop/tutorials/authentication/google.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -207,10 +207,10 @@ To create an app with user authentication, you'll need to configure your secrets
207207

208208
<Note>
209209
If you don't want to use a callback, you can replace the last line with an equivalent `if` statement:
210-
```diff
211-
- st.button("Log in with Google", on_click=st.login)
212-
+ if st.button("Log in with Google"):
213-
+ st.login()
210+
```diff-python
211+
- st.button("Log in with Google", on_click=st.login)
212+
+ if st.button("Log in with Google"):
213+
+ st.login()
214214
```
215215
</Note>
216216
@@ -233,10 +233,10 @@ To create an app with user authentication, you'll need to configure your secrets
233233

234234
1. Replace `st.user` with a personalized greeting:
235235

236-
```diff
237-
else:
238-
- st.user
239-
+ st.header(f"Welcome, {st.user.name}!")
236+
```diff-python
237+
=else:
238+
- st.user
239+
+ st.header(f"Welcome, {st.user.name}!")
240240
```
241241

242242
1. Add a logout button:

content/develop/tutorials/authentication/microsoft.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -193,10 +193,10 @@ To create an app with user authentication, you'll need to configure your secrets
193193

194194
<Note>
195195
If you don't want to use a callback, you can replace the last line with an equivalent `if` statement:
196-
```diff
197-
- st.button("Log in with Microsoft", on_click=st.login)
198-
+ if st.button("Log in with Microsoft"):
199-
+ st.login()
196+
```diff-python
197+
- st.button("Log in with Microsoft", on_click=st.login)
198+
+ if st.button("Log in with Microsoft"):
199+
+ st.login()
200200
```
201201
</Note>
202202
@@ -219,10 +219,10 @@ To create an app with user authentication, you'll need to configure your secrets
219219

220220
1. Replace `st.user` with a personalized greeting:
221221

222-
```diff
223-
else:
224-
- st.user
225-
+ st.header(f"Welcome, {st.user.name}!")
222+
```diff-python
223+
=else:
224+
- st.user
225+
+ st.header(f"Welcome, {st.user.name}!")
226226
```
227227

228228
1. Add a logout button:

content/develop/tutorials/llms/chat-response-feedback.md

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -216,14 +216,14 @@ To make your chat app stateful, you'll save the conversation history into Sessio
216216

217217
1. Add the callback and index argument to your `st.feedback` widget:
218218

219-
```diff
220-
st.feedback(
221-
"thumbs",
222-
key=f"feedback_{i}",
223-
disabled=feedback is not None,
224-
+ on_change=save_feedback,
225-
+ args=[i],
226-
)
219+
```diff-python
220+
= st.feedback(
221+
= "thumbs",
222+
= key=f"feedback_{i}",
223+
= disabled=feedback is not None,
224+
+ on_change=save_feedback,
225+
+ args=[i],
226+
= )
227227
```
228228

229229
When a user interacts with the feedback widget, the callback will update the chat history before the app reruns.
@@ -277,36 +277,36 @@ Your app currently allows users to rate any response once. They can submit their
277277

278278
If you want users to rate only the _most recent_ response, you can remove the widgets from the chat history:
279279

280-
```diff
281-
for i, message in enumerate(st.session_state.history):
282-
with st.chat_message(message["role"]):
283-
st.write(message["content"])
284-
- if message["role"] == "assistant":
285-
- feedback = message.get("feedback", None)
286-
- st.session_state[f"feedback_{i}"] = feedback
287-
- st.feedback(
288-
- "thumbs",
289-
- key=f"feedback_{i}",
290-
- disabled=feedback is not None,
291-
- on_change=save_feedback,
292-
- args=[i],
293-
- )
280+
```diff-python
281+
= for i, message in enumerate(st.session_state.history):
282+
= with st.chat_message(message["role"]):
283+
= st.write(message["content"])
284+
- if message["role"] == "assistant":
285+
- feedback = message.get("feedback", None)
286+
- st.session_state[f"feedback_{i}"] = feedback
287+
- st.feedback(
288+
- "thumbs",
289+
- key=f"feedback_{i}",
290+
- disabled=feedback is not None,
291+
- on_change=save_feedback,
292+
- args=[i],
293+
- )
294294
```
295295

296296
Or, if you want to allow users to change their responses, you can just remove the `disabled` parameter:
297297

298-
```diff
299-
for i, message in enumerate(st.session_state.history):
300-
with st.chat_message(message["role"]):
301-
st.write(message["content"])
302-
if message["role"] == "assistant":
303-
feedback = message.get("feedback", None)
304-
st.session_state[f"feedback_{i}"] = feedback
305-
st.feedback(
306-
"thumbs",
307-
key=f"feedback_{i}",
308-
- disabled=feedback is not None,
309-
on_change=save_feedback,
310-
args=[i],
311-
)
298+
```diff-python
299+
= for i, message in enumerate(st.session_state.history):
300+
= with st.chat_message(message["role"]):
301+
= st.write(message["content"])
302+
= if message["role"] == "assistant":
303+
= feedback = message.get("feedback", None)
304+
= st.session_state[f"feedback_{i}"] = feedback
305+
= st.feedback(
306+
= "thumbs",
307+
= key=f"feedback_{i}",
308+
- disabled=feedback is not None,
309+
= on_change=save_feedback,
310+
= args=[i],
311+
= )
312312
```

content/develop/tutorials/llms/chat-response-revision.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -762,17 +762,17 @@ To see another edge case, try this in the running example:
762762

763763
When you click a button with an unsubmitted value in another widget, Streamlit will update that widget's value and the button's value in succession before triggering the rerun. Because there isn't a rerun between updating the text area and updating the button, the "**Update**" button doesn't get disabled as expected. To correct this, you can add an extra check for an empty text area within the `"rewrite"` stage:
764764

765-
```diff
766-
- if st.button(
767-
- "Update", type="primary", disabled=new is None or new.strip(". ") == ""
768-
- ):
769-
+ is_empty = new is None or new.strip(". ") == ""
770-
+ if st.button("Update", type="primary", disabled=is_empty) and not is_empty:
771-
st.session_state.history.append({"role": "assistant", "content": new})
772-
st.session_state.pending = None
773-
st.session_state.validation = {}
774-
st.session_state.stage = "user"
775-
st.rerun()
765+
```diff-python
766+
- if st.button(
767+
- "Update", type="primary", disabled=new is None or new.strip(". ") == ""
768+
- ):
769+
+ is_empty = new is None or new.strip(". ") == ""
770+
+ if st.button("Update", type="primary", disabled=is_empty) and not is_empty:
771+
= st.session_state.history.append({"role": "assistant", "content": new})
772+
= st.session_state.pending = None
773+
= st.session_state.validation = {}
774+
= st.session_state.stage = "user"
775+
= st.rerun()
776776
```
777777

778778
Now, if you repeat the listed steps, when the app reruns, the conditional block won't be executed even though the button triggered the rerun. The button will be disabled and the user can proceed as if they had just clicked or tabbed out of the text area.

content/get-started/installation/cloud-quickstart.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ If you already created a Community Cloud account and connected GitHub, jump ahea
8181

8282
1. Go to the app's entrypoint file (`streamlit_app.py`) in the left pane, and change line 3 by adding "Streamlit" inside `st.title`.
8383

84-
```diff
84+
```diff-python
8585
-st.title("🎈 My new app")
8686
+st.title("🎈 My new Streamlit app")
8787
```

0 commit comments

Comments
 (0)