-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
42 lines (37 loc) · 1.54 KB
/
app.py
File metadata and controls
42 lines (37 loc) · 1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import streamlit as st
import asyncio
from agents import Agent, Runner
from agents.extensions.models.litellm_model import LitellmModel
# Use Ollama (local open-source model) — no API key needed
# Requires: Ollama running (brew services start ollama) + model pulled (ollama pull llama3.2:3b)
task_generator = Agent(
name="Task Generator",
model=LitellmModel(model="ollama_chat/llama3.2:3b"),
instructions="""You help users break down their specific goal into
small, achievable tasks.
For any goal, analyze it and create a structured plan with specific
actionable steps.
Each task should be concrete, time-bound when possible, and manageable.
Organize tasks in a logical sequence with dependencies clearly marked.
Never answer anything unrelated to AI Agents.""",
)
# Async wrapper for running the agent
async def generate_tasks(goal):
result = await Runner.run(task_generator, goal)
return result.final_output
# Streamlit UI
st.set_page_config(page_title="AI Task Generator", layout="centered")
st.title("🧠 Task Generator Agent")
st.write("Break any goal into a set of actionable tasks.")
user_goal = st.text_area(
"Enter your goal",
placeholder="e.g. Start a small online business selling custom coffee mugs",
)
if st.button("Generate Tasks"):
if user_goal.strip() == "":
st.warning("Please enter a goal.")
else:
with st.spinner("Generating your task plan..."):
tasks = asyncio.run(generate_tasks(user_goal))
st.success("Here are your tasks:")
st.markdown(f"```text\n{tasks}\n```")