> ## Documentation Index
> Fetch the complete documentation index at: https://ikun.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# 为您的 Agent 提供精美的 UI

> 用于与 AI Agent 交互的精美、开源界面

<Frame>
  <img height="200" src="https://mintcdn.com/ikun/QKpfPChraOG28GfC/images/agent-ui.png?fit=max&auto=format&n=QKpfPChraOG28GfC&q=85&s=43ee516ad4ce832715d99726cc9d66f6" style={{ borderRadius: '8px' }} data-path="images/agent-ui.png" />
</Frame>

Agno 提供了一个精美的 UI，用于与您的 Agent 进行交互，完全开源，可免费使用和扩展。这是一个简单的界面，允许您与 Agent 聊天、查看它们的记忆、知识等。

<Note>
  任何数据都不会发送到 [agno.com](https://app.agno.com)，所有 Agent 数据都存储在您本地的 sqlite 数据库中。
</Note>

开源 Agent UI 是使用 Next.js 和 TypeScript 构建的。在 [Agent Playground](/introduction/playground) 取得成功后，社区要求提供一个自托管的替代方案，我们做到了！

# 开始使用 Agent UI

要克隆 Agent UI，请在终端中运行以下命令：

```bash theme={null}
npx create-agent-ui@latest
```

输入 `y` 创建一个新项目，安装依赖项，然后运行 agent-ui：

```bash theme={null}
cd agent-ui && npm run dev
```

打开 [http://localhost:3000](http://localhost:3000) 查看 Agent UI，请记住连接到您的本地 Agent。

<Frame>
  <img height="200" src="https://mintcdn.com/ikun/QKpfPChraOG28GfC/images/agent-ui-homepage.png?fit=max&auto=format&n=QKpfPChraOG28GfC&q=85&s=40c2f681407762bad080df8725e27b46" style={{ borderRadius: '8px' }} data-path="images/agent-ui-homepage.png" />
</Frame>

<br />

<Accordion title="手动克隆仓库" icon="github">
  您也可以手动克隆仓库

  ```bash theme={null}
  git clone https://github.com/agno-agi/agent-ui.git
  ```

  并运行 agent-ui

  ```bash theme={null}
  cd agent-ui && pnpm install && pnpm dev
  ```
</Accordion>

## 连接到本地 Agent

Agent UI 需要连接到一个 playground 服务器，您可以在本地或任何云提供商上运行它。

让我们从本地 playground 服务器开始。创建一个文件 `playground.py`

```python playground.py theme={null}
from agno.agent import Agent
from agno.models.openai import OpenAIChat
from agno.playground import Playground
from agno.storage.sqlite import SqliteStorage
from agno.tools.duckduckgo import DuckDuckGoTools
from agno.tools.yfinance import YFinanceTools

agent_storage: str = "tmp/agents.db"

web_agent = Agent(
    name="Web Agent",
    model=OpenAIChat(id="gpt-4o"),
    tools=[DuckDuckGoTools()],
    instructions=["Always include sources"],
    # Store the agent sessions in a sqlite database
    storage=SqliteStorage(table_name="web_agent", db_file=agent_storage),
    # Adds the current date and time to the instructions
    add_datetime_to_instructions=True,
    # Adds the history of the conversation to the messages
    add_history_to_messages=True,
    # Number of history responses to add to the messages
    num_history_responses=5,
    # Adds markdown formatting to the messages
    markdown=True,
)

finance_agent = Agent(
    name="Finance Agent",
    model=OpenAIChat(id="gpt-4o"),
    tools=[YFinanceTools(stock_price=True, analyst_recommendations=True, company_info=True, company_news=True)],
    instructions=["Always use tables to display data"],
    storage=SqliteStorage(table_name="finance_agent", db_file=agent_storage),
    add_datetime_to_instructions=True,
    add_history_to_messages=True,
    num_history_responses=5,
    markdown=True,
)

playground = Playground(agents=[web_agent, finance_agent])
app = playground.get_app()

if __name__ == "__main__":
    playground.serve("playground:app", reload=True)
```

在另一个终端中，运行 playground 服务器：

<Steps>
  <Step title="设置您的虚拟环境">
    <CodeGroup>
      ```bash Mac theme={null}
      python3 -m venv .venv
      source .venv/bin/activate
      ```

      ```bash Windows theme={null}
      python3 -m venv aienv
      aienv/scripts/activate
      ```
    </CodeGroup>
  </Step>

  <Step title="安装依赖项">
    <CodeGroup>
      ```bash Mac theme={null}
      pip install -U openai duckduckgo-search yfinance sqlalchemy 'fastapi[standard]' agno
      ```

      ```bash Windows theme={null}
      pip install -U openai duckduckgo-search yfinance sqlalchemy 'fastapi[standard]' agno
      ```
    </CodeGroup>
  </Step>

  <Step title="导出您的 OpenAI 密钥">
    <CodeGroup>
      ```bash Mac theme={null}
      export OPENAI_API_KEY=sk-***
      ```

      ```bash Windows theme={null}
      setx OPENAI_API_KEY sk-***
      ```
    </CodeGroup>
  </Step>

  <Step title="运行 Playground">
    ```shell theme={null}
    python playground.py
    ```
  </Step>
</Steps>

<Tip>确保 `serve_playground_app()` 指向包含您的 `Playground` 应用程序的文件。</Tip>

## 查看 playground

* 打开 [http://localhost:3000](http://localhost:3000) 查看 Agent UI
* 选择 `localhost:7777` 端点，开始与您的 Agent 聊天！

<video autoPlay muted controls className="w-full aspect-video" src="https://mintcdn.com/ikun/fXmeJ7wKTC-4Xav-/videos/agent-ui-demo.mp4?fit=max&auto=format&n=fXmeJ7wKTC-4Xav-&q=85&s=8b085a705217a12211b3357513096173" data-path="videos/agent-ui-demo.mp4" />
