{"id":29100473,"url":"https://github.com/poneding/agent-demo","last_synced_at":"2025-06-28T18:14:11.708Z","repository":{"id":296138177,"uuid":"992396814","full_name":"poneding/agent-demo","owner":"poneding","description":"AI Agent demo.","archived":false,"fork":false,"pushed_at":"2025-05-29T05:06:25.000Z","size":98,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-05-29T06:21:46.926Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/poneding.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-05-29T05:03:13.000Z","updated_at":"2025-05-29T05:07:14.000Z","dependencies_parsed_at":"2025-05-29T06:33:11.520Z","dependency_job_id":null,"html_url":"https://github.com/poneding/agent-demo","commit_stats":null,"previous_names":["poneding/agent-demo"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/poneding/agent-demo","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/poneding%2Fagent-demo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/poneding%2Fagent-demo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/poneding%2Fagent-demo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/poneding%2Fagent-demo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/poneding","download_url":"https://codeload.github.com/poneding/agent-demo/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/poneding%2Fagent-demo/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262474307,"owners_count":23316915,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-06-28T18:14:11.018Z","updated_at":"2025-06-28T18:14:11.703Z","avatar_url":"https://github.com/poneding.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# agent-demo\n\n1. 初始化一个项目：\n\n    ```bash\n    uv init agent-demo \u0026\u0026 cd agent-demo\n    uv add dotenv pydantic-ai\n    ```\n\n2. 编辑 *main.py*：\n\n    ```python\n    from dotenv import load_dotenv\n    from pydantic_ai.agent import Agent\n    from pydantic_ai.models.gemini import GeminiModel\n    \n    load_dotenv()\n    \n    model = GeminiModel(model_name=\"gemini-2.0-flash\")\n    \n    # Emulate a tool function\n    def say_hello(name: str) -\u003e str:\n        \"\"\"Greet to my good friend.\"\"\"\n        return f\"Hello, my good friend {name}! -- From the agent-demo\"\n    \n    agent = Agent(\n        model=model,\n        system_prompt=\"You are an expert in Python programming.\",\n        tools=[say_hello],  # Add your tools here, generally a list of functions\n    )\n    \n    def main():\n        history_messages = []\n        while True:\n            user_input = input(\"Input: \")\n            if user_input.lower() in [\"exit\", \"quit\"]:\n                print(\"Exiting the agent.\")\n                break\n            response = agent.run_sync(user_input, message_history=history_messages)\n            history_messages = list(response.all_messages())\n            print(response.output)\n    \n    if __name__ == \"__main__\":\n        main()\n    ```\n\n3. 创建 .env 文件并配置 GEMINI_API_KEY 环境变量\n\n4. 运行：\n\n    ```bash\n    uv run mian.py\n    ```\n\n5. 输入 *Greet to my good friend Jay Chou.*\n\n6. 效果如下：\n\n    ![alt text](images/demo.png)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fponeding%2Fagent-demo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fponeding%2Fagent-demo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fponeding%2Fagent-demo/lists"}