Update app.py
Browse files
app.py
CHANGED
|
@@ -24,10 +24,10 @@ def main():
|
|
| 24 |
# Configuration du client
|
| 25 |
client = genai.Client(
|
| 26 |
api_key=api_key,
|
| 27 |
-
http_options={'api_version':'v1alpha'}
|
| 28 |
)
|
| 29 |
|
| 30 |
-
# Configuration pour les thoughts
|
| 31 |
config = GenerateContentConfig(
|
| 32 |
thinking_config=ThinkingConfig(include_thoughts=True)
|
| 33 |
)
|
|
@@ -38,13 +38,15 @@ def main():
|
|
| 38 |
model="gemini-2.0-flash-thinking-exp-01-21",
|
| 39 |
contents=prompt,
|
| 40 |
config=config,
|
| 41 |
-
|
| 42 |
)
|
| 43 |
|
| 44 |
-
# Affichage des résultats dans des sections distinctes
|
| 45 |
st.subheader("Résultats")
|
|
|
|
| 46 |
print(response)
|
|
|
|
|
|
|
| 47 |
for part in response.candidates[0].content.parts:
|
|
|
|
| 48 |
if part.thought:
|
| 49 |
with st.expander("💭 Thoughts", expanded=True):
|
| 50 |
st.write(part.text)
|
|
@@ -56,10 +58,10 @@ def main():
|
|
| 56 |
st.error(f"Une erreur s'est produite: {str(e)}")
|
| 57 |
|
| 58 |
if __name__ == "__main__":
|
| 59 |
-
# Configuration de la page
|
| 60 |
st.set_page_config(
|
| 61 |
page_title="Interface Gemini API",
|
| 62 |
page_icon="🤖",
|
| 63 |
layout="wide"
|
| 64 |
)
|
| 65 |
-
main()
|
|
|
|
| 24 |
# Configuration du client
|
| 25 |
client = genai.Client(
|
| 26 |
api_key=api_key,
|
| 27 |
+
http_options={'api_version': 'v1alpha'}
|
| 28 |
)
|
| 29 |
|
| 30 |
+
# Configuration pour inclure les chain-of-thoughts
|
| 31 |
config = GenerateContentConfig(
|
| 32 |
thinking_config=ThinkingConfig(include_thoughts=True)
|
| 33 |
)
|
|
|
|
| 38 |
model="gemini-2.0-flash-thinking-exp-01-21",
|
| 39 |
contents=prompt,
|
| 40 |
config=config,
|
|
|
|
| 41 |
)
|
| 42 |
|
|
|
|
| 43 |
st.subheader("Résultats")
|
| 44 |
+
# Affichage dans la console pour debug
|
| 45 |
print(response)
|
| 46 |
+
|
| 47 |
+
# Parcourir les parties de la réponse
|
| 48 |
for part in response.candidates[0].content.parts:
|
| 49 |
+
# Si le modèle retourne un champ 'thought', on l'affiche dans un expander dédié
|
| 50 |
if part.thought:
|
| 51 |
with st.expander("💭 Thoughts", expanded=True):
|
| 52 |
st.write(part.text)
|
|
|
|
| 58 |
st.error(f"Une erreur s'est produite: {str(e)}")
|
| 59 |
|
| 60 |
if __name__ == "__main__":
|
| 61 |
+
# Configuration de la page Streamlit
|
| 62 |
st.set_page_config(
|
| 63 |
page_title="Interface Gemini API",
|
| 64 |
page_icon="🤖",
|
| 65 |
layout="wide"
|
| 66 |
)
|
| 67 |
+
main()
|