tianyajum commited on
Commit
854a4a5
·
verified ·
1 Parent(s): a183cb3

【xxx】修改文件标题 符合huggingface格式,指定启动文件main.py

Browse files
Files changed (1) hide show
  1. README.md +109 -98
README.md CHANGED
@@ -1,98 +1,109 @@
1
- # Python Agent
2
-
3
- A modular Python-based AI agent service built with FastAPI, integrating **Nacos** for service discovery and **Model Context Protocol (MCP)** for extensible tool usage. This agent uses **LangGraph** to orchestrate agentic workflows.
4
-
5
- ## Features
6
-
7
- - **FastAPI Framework**: High-performance, easy-to-learn web framework.
8
- - **Service Discovery**: Seamless integration with Nacos for service registration and discovery.
9
- - **LangGraph**: Stateful, multi-actor applications with cycles (agentic orchestration).
10
- - **Model Context Protocol (MCP)**:
11
- - **Stdio Client**: Connects to local CLI tools (e.g., Brave Search via Node.js).
12
- - **SSE Client**: Connects to remote services (e.g., Java backend) via Server-Sent Events.
13
-
14
- ## Prerequisites
15
-
16
- - **Python 3.10+**
17
- - **Node.js**: Required for running the Brave Search MCP server (`npx`).
18
- - **Nacos Server 2.x**: A running Nacos instance is required for the application to start.
19
-
20
- ## Installation
21
-
22
- 1. Clone the repository:
23
- ```bash
24
- git clone <repository_url>
25
- cd python-agent
26
- ```
27
-
28
- 2. Create and activate a virtual environment:
29
- ```bash
30
- python -m venv .venv
31
- # Windows
32
- .venv\Scripts\activate
33
- # Linux/Mac
34
- source .venv/bin/activate
35
- ```
36
-
37
- 3. Install dependencies:
38
- ```bash
39
- pip install -r requirements.txt
40
- ```
41
-
42
- ## Configuration
43
-
44
- The application is configured via environment variables. You can create a `.env` file in the root directory (see `.env.example`).
45
-
46
- | Variable | Default | Description |
47
- |----------|---------|-------------|
48
- | `APP_ENV` | `development` | Application environment (`development` or `production`). |
49
- | `HOST` | `0.0.0.0` | Host to bind the server to. |
50
- | `PORT` | `8181` | Port to listen on. |
51
- | `NACOS_SERVER_ADDR` | `pei.12277.xyz:18848` | Address of the Nacos server. |
52
- | `NACOS_NAMESPACE` | `public` | Nacos namespace ID. |
53
- | `NACOS_USERNAME` | `nacos` | Nacos username. |
54
- | `NACOS_PASSWORD` | `nacos` | Nacos password. |
55
- | `SERVICE_NAME` | `python-agent` | Name of this service in Nacos. |
56
- | `MCP_BRAVE_PATH` | (Auto-detected) | Optional override for `npx` path. |
57
- | `NACOS_GATEWAY_SERVICE_NAME` | `gateway` | Name of the Java/Gateway service to discover. |
58
-
59
- ## Usage
60
-
61
- ### Running the Application
62
-
63
- Using `python`:
64
- ```bash
65
- python main.py
66
- ```
67
-
68
- Using `uvicorn` (with hot reload):
69
- ```bash
70
- uvicorn main:app --reload --port 8181
71
- ```
72
-
73
- > **Note**: The application will fail to start if it cannot connect to the configured Nacos server.
74
-
75
- ### API Endpoints
76
-
77
- - **Health Check**: `GET /health`
78
- - **Chat**: `POST /chat`
79
- ```json
80
- {
81
- "message": "Search for the latest news on AI."
82
- }
83
- ```
84
-
85
- ## Project Structure
86
-
87
- The project follows a modular package structure:
88
-
89
- ```text
90
- python-agent/
91
- ├── app/
92
- │ ├── core/ # Core configuration & infrastructure (Nacos, Config)
93
- │ ├── services/ # External service clients (MCP)
94
- │ ├── agent/ # LangGraph logic (State, Graph, Nodes)
95
- │ └── setup.py # Startup setup scripts
96
- ├── main.py # Entry point
97
- └── ...
98
- ```
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: Python-Agent
3
+ emoji: 🤖
4
+ colorFrom: blue
5
+ colorTo: green
6
+ sdk: gradio
7
+ app_file: main.py # <--- 添加这一行,指定启动文件
8
+ pinned: false
9
+ ---
10
+
11
+
12
+ # Python Agent
13
+
14
+ A modular Python-based AI agent service built with FastAPI, integrating **Nacos** for service discovery and **Model Context Protocol (MCP)** for extensible tool usage. This agent uses **LangGraph** to orchestrate agentic workflows.
15
+
16
+ ## Features
17
+
18
+ - **FastAPI Framework**: High-performance, easy-to-learn web framework.
19
+ - **Service Discovery**: Seamless integration with Nacos for service registration and discovery.
20
+ - **LangGraph**: Stateful, multi-actor applications with cycles (agentic orchestration).
21
+ - **Model Context Protocol (MCP)**:
22
+ - **Stdio Client**: Connects to local CLI tools (e.g., Brave Search via Node.js).
23
+ - **SSE Client**: Connects to remote services (e.g., Java backend) via Server-Sent Events.
24
+
25
+ ## Prerequisites
26
+
27
+ - **Python 3.10+**
28
+ - **Node.js**: Required for running the Brave Search MCP server (`npx`).
29
+ - **Nacos Server 2.x**: A running Nacos instance is required for the application to start.
30
+
31
+ ## Installation
32
+
33
+ 1. Clone the repository:
34
+ ```bash
35
+ git clone <repository_url>
36
+ cd python-agent
37
+ ```
38
+
39
+ 2. Create and activate a virtual environment:
40
+ ```bash
41
+ python -m venv .venv
42
+ # Windows
43
+ .venv\Scripts\activate
44
+ # Linux/Mac
45
+ source .venv/bin/activate
46
+ ```
47
+
48
+ 3. Install dependencies:
49
+ ```bash
50
+ pip install -r requirements.txt
51
+ ```
52
+
53
+ ## Configuration
54
+
55
+ The application is configured via environment variables. You can create a `.env` file in the root directory (see `.env.example`).
56
+
57
+ | Variable | Default | Description |
58
+ |----------|---------|-------------|
59
+ | `APP_ENV` | `development` | Application environment (`development` or `production`). |
60
+ | `HOST` | `0.0.0.0` | Host to bind the server to. |
61
+ | `PORT` | `8181` | Port to listen on. |
62
+ | `NACOS_SERVER_ADDR` | `` | Address of the Nacos server. |
63
+ | `NACOS_NAMESPACE` | `public` | Nacos namespace ID. |
64
+ | `NACOS_USERNAME` | `` | Nacos username. |
65
+ | `NACOS_PASSWORD` | `` | Nacos password. |
66
+ | `SERVICE_NAME` | `python-agent` | Name of this service in Nacos. |
67
+ | `MCP_BRAVE_PATH` | (Auto-detected) | Optional override for `npx` path. |
68
+ | `NACOS_GATEWAY_SERVICE_NAME` | `gateway` | Name of the Java/Gateway service to discover. |
69
+
70
+ ## Usage
71
+
72
+ ### Running the Application
73
+
74
+ Using `python`:
75
+ ```bash
76
+ python main.py
77
+ ```
78
+
79
+ Using `uvicorn` (with hot reload):
80
+ ```bash
81
+ uvicorn main:app --reload --port 8181
82
+ ```
83
+
84
+ > **Note**: The application will fail to start if it cannot connect to the configured Nacos server.
85
+
86
+ ### API Endpoints
87
+
88
+ - **Health Check**: `GET /health`
89
+ - **Chat**: `POST /chat`
90
+ ```json
91
+ {
92
+ "message": "Search for the latest news on AI."
93
+ }
94
+ ```
95
+
96
+ ## Project Structure
97
+
98
+ The project follows a modular package structure:
99
+
100
+ ```text
101
+ python-agent/
102
+ ├── app/
103
+ │ ├── core/ # Core configuration & infrastructure (Nacos, Config)
104
+ │ ├── services/ # External service clients (MCP)
105
+ │ ├── agent/ # LangGraph logic (State, Graph, Nodes)
106
+ │ └── setup.py # Startup setup scripts
107
+ ├── main.py # Entry point
108
+ └── ...
109
+ ```