|
14 | 14 | from ratelimiter_ext import RateLimitingExtension, TokenBucketLimiter |
15 | 15 |
|
16 | 16 |
|
17 | | -if __name__ == "__main__": |
| 17 | +if __name__ == '__main__': |
18 | 18 | # Initialize rate limiter for enforcement (always active) |
19 | 19 | # Token bucket allows burst traffic up to 20 requests (10 * 2.0 multiplier) |
20 | 20 | # then maintains steady 10 requests per minute |
|
25 | 25 | rate_limit_extension = RateLimitingExtension() |
26 | 26 | # --8<-- [start:AgentSkill] |
27 | 27 | skill = AgentSkill( |
28 | | - id="hello_world", |
29 | | - name="Returns hello world", |
30 | | - description="just returns hello world", |
31 | | - tags=["hello world"], |
32 | | - examples=["hi", "hello world"], |
| 28 | + id='hello_world', |
| 29 | + name='Returns hello world', |
| 30 | + description='just returns hello world', |
| 31 | + tags=['hello world'], |
| 32 | + examples=['hi', 'hello world'], |
33 | 33 | ) |
34 | 34 | # --8<-- [end:AgentSkill] |
35 | 35 |
|
36 | 36 | extended_skill = AgentSkill( |
37 | | - id="super_hello_world", |
38 | | - name="Returns a SUPER Hello World", |
39 | | - description="A more enthusiastic greeting, only for authenticated users.", |
40 | | - tags=["hello world", "super", "extended"], |
41 | | - examples=["super hi", "give me a super hello"], |
| 37 | + id='super_hello_world', |
| 38 | + name='Returns a SUPER Hello World', |
| 39 | + description='A more enthusiastic greeting, only for authenticated users.', |
| 40 | + tags=['hello world', 'super', 'extended'], |
| 41 | + examples=['super hi', 'give me a super hello'], |
42 | 42 | ) |
43 | 43 |
|
44 | 44 | # --8<-- [start:AgentCard] |
45 | 45 | # This will be the public-facing agent card |
46 | 46 | public_agent_card = AgentCard( |
47 | | - name="Hello World Agent with Rate Limiting", |
48 | | - description="Hello world agent demonstrating A2A rate limiting extension", |
49 | | - url="http://localhost:9999/", |
50 | | - version="1.0.0", |
51 | | - default_input_modes=["text"], |
52 | | - default_output_modes=["text"], |
| 47 | + name='Hello World Agent with Rate Limiting', |
| 48 | + description='Hello world agent demonstrating A2A rate limiting extension', |
| 49 | + url='http://localhost:9999/', |
| 50 | + version='1.0.0', |
| 51 | + default_input_modes=['text'], |
| 52 | + default_output_modes=['text'], |
53 | 53 | capabilities=AgentCapabilities(streaming=True), |
54 | 54 | skills=[skill], # Only the basic skill for the public card |
55 | 55 | supports_authenticated_extended_card=True, |
|
60 | 60 | # It includes the additional 'extended_skill' |
61 | 61 | specific_extended_agent_card = public_agent_card.model_copy( |
62 | 62 | update={ |
63 | | - "name": "Hello World Agent with Rate Limiting - Extended Edition", # Different name for clarity |
64 | | - "description": "The full-featured rate-limited hello world agent for authenticated users.", |
65 | | - "version": "1.0.1", # Could even be a different version |
| 63 | + 'name': 'Hello World Agent with Rate Limiting - Extended Edition', # Different name for clarity |
| 64 | + 'description': 'The full-featured rate-limited hello world agent for authenticated users.', |
| 65 | + 'version': '1.0.1', # Could even be a different version |
66 | 66 | # Capabilities and other fields like url, default_input_modes, |
67 | 67 | # default_output_modes, supports_authenticated_extended_card |
68 | 68 | # are inherited from public_agent_card unless specified here. |
69 | | - "skills": [ |
| 69 | + 'skills': [ |
70 | 70 | skill, |
71 | 71 | extended_skill, |
72 | 72 | ], # Both skills for the extended card |
|
98 | 98 | ) |
99 | 99 |
|
100 | 100 | # Bind to 0.0.0.0 to allow external connections in containerized environment |
101 | | - uvicorn.run(server.build(), host="0.0.0.0", port=9999) # noqa: S104 |
| 101 | + uvicorn.run(server.build(), host='0.0.0.0', port=9999) # noqa: S104 |
0 commit comments