このガイドは Agno でエージェントを構築する基本を段階的に説明します。サンプルは違いに連携し、新しいコンセプトと機能を段階的に導入していきます。各サンプルは詳細なコメント、プロンプト例、そして必要な依存関係を含みます。
Agno Examples : Getting Started – イントロダクション / 基本エージェント
作成 : クラスキャット・セールスインフォメーション
作成日時 : 08/05/2025
バージョン : Agno 1.7.7
* 本記事は docs.agno.com の以下のページを独自に翻訳した上で、補足説明を加えてまとめ直しています :
* サンプルコードの動作確認はしておりますが、必要な場合には適宜、追加改変しています。
* ご自由にリンクを張って頂いてかまいませんが、sales-info@classcat.com までご一報いただけると嬉しいです。
クラスキャット 人工知能 研究開発支援サービス ⭐️ リニューアルしました 😉
◆ お問合せ : 下記までお願いします。
- クラスキャット セールス・インフォメーション
- sales-info@classcat.com
- ClassCatJP
Agno Examples : Getting Started – イントロダクション
このガイドは Agno でエージェントを構築する基本を段階的に説明します。
サンプルは違いに連携し、新しいコンセプトと機能を段階的に導入していきます。各サンプルは詳細なコメント、プロンプト例、そして必要な依存関係を含みます。
セットアップ
仮想環境を作成します :
python3 -m venv .venv
source .venv/bin/activate
必要な依存関係をインストールします :
pip install openai duckduckgo-search yfinance lancedb tantivy pypdf requests exa-py newspaper4k lxml_html_clean sqlalchemy agno
OpenAI API キーをエクスポートします :
export OPENAI_API_KEY=your_api_key
Agno Examples : Getting Started – 基本エージェント
このサンプルは明確な個性を持つ基本的な AI エージェントを作成する方法を示します。ニューヨーク気質と創造的なストーリーテリングを併せ持つ楽しいニュースレポーターを作成します。これは個性とスタイルの指示がエージェントの応答をどのように形成できるかを示しています。
試すべきプロンプト例は :
- “What’s the latest scoop from Central Park?”
- “Tell me about a breaking story from Wall Street”
- “What’s happening at the Yankees game right now?”
- “Give me the buzz about a new Broadway show”
basic_agent.py
from textwrap import dedent
from agno.agent import Agent
from agno.models.openai import OpenAIChat
# Create our News Reporter with a fun personality
agent = Agent(
model=OpenAIChat(id="gpt-4o"),
instructions=dedent("""\
You are an enthusiastic news reporter with a flair for storytelling! 🗽
Think of yourself as a mix between a witty comedian and a sharp journalist.
Your style guide:
- Start with an attention-grabbing headline using emoji
- Share news with enthusiasm and NYC attitude
- Keep your responses concise but entertaining
- Throw in local references and NYC slang when appropriate
- End with a catchy sign-off like 'Back to you in the studio!' or 'Reporting live from the Big Apple!'
Remember to verify all facts while keeping that NYC energy high!\
"""),
markdown=True,
)
# Example usage
agent.print_response(
"Tell me about a breaking news story happening in Times Square.", stream=True
)
# More example prompts to try:
"""
Try these fun scenarios:
1. "What's the latest food trend taking over Brooklyn?"
2. "Tell me about a peculiar incident on the subway today"
3. "What's the scoop on the newest rooftop garden in Manhattan?"
4. "Report on an unusual traffic jam caused by escaped zoo animals"
5. "Cover a flash mob wedding proposal at Grand Central"
"""
以上