Skip to content

100+ AI Agents, Agent Skills and RAG Apps - Free and Open Source.

New project with gemini thinking1

Madhu5f5bebfc9fdb
diff --git a/ai_agent_tutorials/ai_gemini_thinking_agent/main.py b/ai_agent_tutorials/ai_gemini_thinking_agent/main.py
index 35995c9e..661642c4 100644
--- a/ai_agent_tutorials/ai_gemini_thinking_agent/main.py
+++ b/ai_agent_tutorials/ai_gemini_thinking_agent/main.py
@@ -1,20 +1,58 @@
+import streamlit as st
from agno.agent import Agent
-from agno.models.openai import OpenAIChat
from agno.models.google import Gemini
from agno.tools.duckduckgo import DuckDuckGoTools
from agno.tools.yfinance import YFinanceTools
import os
-from dotenv import load_dotenv
-load_dotenv()
-thinking_agent = Agent(
- name="Thinking Agent",
- role="Think about the problem",
- model=Gemini(id="gemini-2.0-flash-thinking-exp-1219", api_key=os.getenv("GOOGLE_API_KEY")),
- instructions="Given the problem, think about it and provide a detailed explanation",
- show_tool_calls=True,
- markdown=True,
-)
+# Streamlit App Title
+st.title("AI Agent with Agno and Gemini Thinking")
+# Sidebar for API Key Input
+st.sidebar.header("Configuration")
+api_key = st.sidebar.text_input("Enter your Google API Key", type="password")
+if api_key:
+ os.environ["GOOGLE_API_KEY"] = api_key
-thinking_agent.print_response("Explain Deep Q Networks from first principles", stream=True)
\ No newline at end of file
+# File/URL Upload Section
+st.sidebar.header("Upload Data")
+uploaded_file = st.sidebar.file_uploader("Upload a document", type=["txt", "pdf", "jpg", "png"])
+web_url = st.sidebar.text_input("Enter a web URL")
+
+# Initialize the Agent
+if api_key:
+ thinking_agent = Agent(
+ name="Thinking Agent",
+ role="Think about the problem",
+ model=Gemini(id="gemini-2.0-flash-exp", api_key=api_key),
+ instructions="Given the problem, think about it and provide a detailed explanation",
+ show_tool_calls=True,
+ markdown=True,
+ )
+
+ # Chat Interface
+ st.header("Chat with the Agent")
+ user_input = st.text_input("Ask a question or describe the problem:")
+
+ if user_input:
+ # Process the user's input
+ if uploaded_file:
+ # Handle file upload
+ file_content = uploaded_file.read()
+ st.write("File content:", file_content)
+ # Add logic to process the file content with the agent
+ response = thinking_agent.run(f"Given this file content: {file_content}, answer: {user_input}")
+ elif web_url:
+ # Handle web URL
+ st.write("Web URL:", web_url)
+ # Add logic to process the web URL with the agent
+ response = thinking_agent.run(f"Given this web URL: {web_url}, answer: {user_input}")
+ else:
+ # Handle normal chat
+ response = thinking_agent.run(user_input)
+
+ # Display the response
+ st.write("Agent's Response:")
+ st.write(response.content)
+else:
+ st.warning("Please enter your Google API Key in the sidebar to proceed.")
\ No newline at end of file
diff --git a/ai_agent_tutorials/ai_gemini_thinking_agent/test.py b/ai_agent_tutorials/ai_gemini_thinking_agent/test.py
index 9149e46c..c6b2d488 100644
--- a/ai_agent_tutorials/ai_gemini_thinking_agent/test.py
+++ b/ai_agent_tutorials/ai_gemini_thinking_agent/test.py
@@ -11,10 +11,10 @@ config = {'thinking_config': {'include_thoughts': True}}
async def main():
chat = client.aio.chats.create(
- model='gemini-2.0-flash-thinking-exp',
+ model='gemini-2.0-flash-thinking-exp-01-21',
config=config
)
- response = await chat.send_message('What is your name?')
+ response = await chat.send_message('Explain Deep Q Networks from first principles')
print(response.text)
response = await chat.send_message('What did you just say before this?')
print(response.text)
diff --git a/ai_agent_tutorials/ai_gemini_thinking_agent/test2.py b/ai_agent_tutorials/ai_gemini_thinking_agent/test2.py
new file mode 100644
index 00000000..0a049596
--- /dev/null
+++ b/ai_agent_tutorials/ai_gemini_thinking_agent/test2.py
@@ -0,0 +1,21 @@
+from google import genai
+import os
+from dotenv import load_dotenv
+load_dotenv()
+
+from google import genai
+
+client = genai.Client(api_key=os.getenv("GOOGLE_API_KEY"), http_options={'api_version':'v1alpha'})
+
+config = {'thinking_config': {'include_thoughts': True}}
+response = client.models.generate_content(
+ model='gemini-2.0-flash-thinking-exp-01-21',
+ contents='Explain how RLHF works in simple terms.',
+ config=config
+)
+
+for part in response.candidates[0].content.parts:
+ if part.thought:
+ print(f"Model Thought:\n{part.text}\n")
+ else:
+ print(f"\nModel Response:\n{part.text}\n")
\ No newline at end of file