-
Notifications
You must be signed in to change notification settings - Fork 202
Advice | Program
Avdhesh edited this page Jun 24, 2025
·
1 revision
The Advice Program in Jarvis fetches and displays random motivational or humorous advice using a public API. It’s a fun and thoughtful feature that adds personality to the AI assistant.
We're using the free Advice Slip JSON API — a lightweight service that delivers quick, random advice in JSON format.
⚡ Fast & simple: Perfect for interactive interfaces like Streamlit.

This api consists of different end-points with explanations. You can explore it here.
| Endpoint | Response Preview | Description |
|---|---|---|
/advice |
{ "slip": { "id": 17, "advice": "Sometimes it's best to ignore other people's advice." }}
|
Returns a random advice slip as a slip object. |
A new random advice is returned on every request — perfect for dynamic experiences like Jarvis.
You can quickly fetch an advice using this minimal code
import requests
res = requests.get("https://api.adviceslip.com/advice").json()
advice_text = res['slip']['advice']
print(advice_text)The following code shows how the Advice Program is implemented in Jarvis using Streamlit
import streamlit as st
import requests
def advice():
res = requests.get("https://api.adviceslip.com/advice").json()
advice_text = res['slip']['advice']
st.markdown(f"#### 💡 **{advice_text}**")
if st.button("🔄 Reload Advice"):
st.session_state['reload_advice'] = not st.session_state.get('reload_advice', False)
-
st.markdown(...): Displays the advice text with an emoji and markdown styling. -
st.button(...): Adds a "Reload Advice" button to refresh the quote. -
st.session_state: A lightweight trick to force Streamlit to re-run the function and pull a new quote without refreshing the entire app.