add: main.py

This commit is contained in:
2026-06-30 16:04:43 +00:00
commit 28da77ce4a
+46
View File
@@ -0,0 +1,46 @@
import os
import asyncio
from langchain_openai import ChatOpenAI
from langchain_core.messages import HumanMessage
from deepagents import create_deep_agent
from deepagents.backends import FilesystemBackend, LocalShellBackend, CompositeBackend
# Configure the LLM using OpenRouter
llm = ChatOpenAI(
model="openai/gpt-oss-20b:free",
base_url="https://openrouter.ai/api/v1",
api_key=os.getenv("OPENAI_API_KEY"),
temperature=0.2,
)
# Set up a composite backend for file and shell interactions (required by deepagents)
backend = CompositeBackend([
LocalShellBackend(workspace_dir="./workspace"),
FilesystemBackend(),
])
# Create the deep agent with a clear system prompt that guides the generation of a 12week AI fluency plan
agent = create_deep_agent(
model=llm,
tools=[],
backend=backend,
system_prompt=(
"You are an experienced AI tutor. Your task is to craft a detailed 12week personal AI fluency plan "
"for a learner who has completed the Ai Fluency course. The plan should include: 1) a weekly objective, "
"2) recommended resources (books, articles, videos, exercises), and 3) an assessment method for each week. "
"Present the plan in a clear, numbered format."
),
)
async def main():
# Invoke the agent to generate the plan
result = await agent.ainvoke(
{"messages": [HumanMessage(content="Generate my personal AI fluency plan.")]},
{"configurable": {"thread_id": "ai-fluency-plan"}},
)
plan = result["messages"][-1].content
print("\n=== Personal AI Fluency Plan ===\n")
print(plan)
if __name__ == "__main__":
asyncio.run(main())