fast-agent-mcp 0.2.35__py3-none-any.whl → 0.2.37__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of fast-agent-mcp might be problematic. Click here for more details.
- {fast_agent_mcp-0.2.35.dist-info → fast_agent_mcp-0.2.37.dist-info}/METADATA +15 -12
- {fast_agent_mcp-0.2.35.dist-info → fast_agent_mcp-0.2.37.dist-info}/RECORD +55 -56
- {fast_agent_mcp-0.2.35.dist-info → fast_agent_mcp-0.2.37.dist-info}/licenses/LICENSE +1 -1
- mcp_agent/agents/base_agent.py +2 -2
- mcp_agent/agents/workflow/router_agent.py +1 -1
- mcp_agent/cli/commands/quickstart.py +59 -5
- mcp_agent/config.py +10 -0
- mcp_agent/context.py +1 -4
- mcp_agent/core/agent_types.py +7 -6
- mcp_agent/core/direct_decorators.py +14 -0
- mcp_agent/core/direct_factory.py +1 -0
- mcp_agent/core/enhanced_prompt.py +73 -13
- mcp_agent/core/fastagent.py +23 -2
- mcp_agent/core/interactive_prompt.py +118 -8
- mcp_agent/human_input/elicitation_form.py +723 -0
- mcp_agent/human_input/elicitation_forms.py +59 -0
- mcp_agent/human_input/elicitation_handler.py +88 -0
- mcp_agent/human_input/elicitation_state.py +34 -0
- mcp_agent/llm/augmented_llm.py +31 -0
- mcp_agent/llm/providers/augmented_llm_anthropic.py +11 -23
- mcp_agent/llm/providers/augmented_llm_azure.py +4 -4
- mcp_agent/llm/providers/augmented_llm_google_native.py +4 -2
- mcp_agent/llm/providers/augmented_llm_openai.py +195 -12
- mcp_agent/llm/providers/multipart_converter_openai.py +4 -3
- mcp_agent/mcp/elicitation_factory.py +84 -0
- mcp_agent/mcp/elicitation_handlers.py +155 -0
- mcp_agent/mcp/helpers/content_helpers.py +27 -0
- mcp_agent/mcp/helpers/server_config_helpers.py +10 -8
- mcp_agent/mcp/interfaces.py +1 -1
- mcp_agent/mcp/mcp_agent_client_session.py +44 -1
- mcp_agent/mcp/mcp_aggregator.py +56 -11
- mcp_agent/mcp/mcp_connection_manager.py +30 -18
- mcp_agent/mcp_server/agent_server.py +2 -0
- mcp_agent/mcp_server_registry.py +16 -8
- mcp_agent/resources/examples/data-analysis/analysis.py +1 -2
- mcp_agent/resources/examples/mcp/elicitations/README.md +157 -0
- mcp_agent/resources/examples/mcp/elicitations/elicitation_account_server.py +88 -0
- mcp_agent/resources/examples/mcp/elicitations/elicitation_forms_server.py +232 -0
- mcp_agent/resources/examples/mcp/elicitations/elicitation_game_server.py +164 -0
- mcp_agent/resources/examples/mcp/elicitations/fastagent.config.yaml +35 -0
- mcp_agent/resources/examples/mcp/elicitations/fastagent.secrets.yaml.example +17 -0
- mcp_agent/resources/examples/mcp/elicitations/forms_demo.py +111 -0
- mcp_agent/resources/examples/mcp/elicitations/game_character.py +65 -0
- mcp_agent/resources/examples/mcp/elicitations/game_character_handler.py +256 -0
- mcp_agent/resources/examples/{prompting/agent.py → mcp/elicitations/tool_call.py} +4 -5
- mcp_agent/resources/examples/mcp/state-transfer/agent_two.py +1 -1
- mcp_agent/resources/examples/mcp/state-transfer/fastagent.config.yaml +1 -1
- mcp_agent/resources/examples/mcp/state-transfer/fastagent.secrets.yaml.example +1 -0
- mcp_agent/resources/examples/workflows/evaluator.py +1 -1
- mcp_agent/resources/examples/workflows/graded_report.md +89 -0
- mcp_agent/resources/examples/workflows/orchestrator.py +7 -9
- mcp_agent/resources/examples/workflows/parallel.py +0 -2
- mcp_agent/resources/examples/workflows/short_story.md +13 -0
- mcp_agent/resources/examples/in_dev/agent_build.py +0 -84
- mcp_agent/resources/examples/in_dev/css-LICENSE.txt +0 -21
- mcp_agent/resources/examples/in_dev/slides.py +0 -110
- mcp_agent/resources/examples/internal/agent.py +0 -20
- mcp_agent/resources/examples/internal/fastagent.config.yaml +0 -66
- mcp_agent/resources/examples/internal/history_transfer.py +0 -35
- mcp_agent/resources/examples/internal/job.py +0 -84
- mcp_agent/resources/examples/internal/prompt_category.py +0 -21
- mcp_agent/resources/examples/internal/prompt_sizing.py +0 -51
- mcp_agent/resources/examples/internal/simple.txt +0 -2
- mcp_agent/resources/examples/internal/sizer.py +0 -20
- mcp_agent/resources/examples/internal/social.py +0 -67
- mcp_agent/resources/examples/prompting/__init__.py +0 -3
- mcp_agent/resources/examples/prompting/delimited_prompt.txt +0 -14
- mcp_agent/resources/examples/prompting/fastagent.config.yaml +0 -43
- mcp_agent/resources/examples/prompting/image_server.py +0 -52
- mcp_agent/resources/examples/prompting/prompt1.txt +0 -6
- mcp_agent/resources/examples/prompting/work_with_image.py +0 -19
- {fast_agent_mcp-0.2.35.dist-info → fast_agent_mcp-0.2.37.dist-info}/WHEEL +0 -0
- {fast_agent_mcp-0.2.35.dist-info → fast_agent_mcp-0.2.37.dist-info}/entry_points.txt +0 -0
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Secrets configuration for elicitation examples
|
|
2
|
+
#
|
|
3
|
+
# Rename this file to fastagent.secrets.yaml and add your API keys
|
|
4
|
+
# to use the account_creation.py example with real LLMs
|
|
5
|
+
|
|
6
|
+
# OpenAI
|
|
7
|
+
openai_api_key: "sk-..."
|
|
8
|
+
|
|
9
|
+
# Anthropic
|
|
10
|
+
anthropic_api_key: "sk-ant-..."
|
|
11
|
+
|
|
12
|
+
# Google (Gemini)
|
|
13
|
+
google_api_key: "..."
|
|
14
|
+
|
|
15
|
+
# Other providers - see documentation for full list
|
|
16
|
+
# groq_api_key: "..."
|
|
17
|
+
# mistral_api_key: "..."
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Quick Start: Elicitation Forms Demo
|
|
3
|
+
|
|
4
|
+
This example demonstrates the elicitation forms feature of fast-agent.
|
|
5
|
+
|
|
6
|
+
When Read Resource requests are sent to the MCP Server, it generates an Elicitation
|
|
7
|
+
which creates a form for the user to fill out.
|
|
8
|
+
The results are returned to the demo program which prints out the results in a rich format.
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
import asyncio
|
|
12
|
+
|
|
13
|
+
from rich.console import Console
|
|
14
|
+
from rich.panel import Panel
|
|
15
|
+
|
|
16
|
+
from mcp_agent.core.fastagent import FastAgent
|
|
17
|
+
from mcp_agent.mcp.helpers.content_helpers import get_resource_text
|
|
18
|
+
|
|
19
|
+
fast = FastAgent("Elicitation Forms Demo", quiet=True)
|
|
20
|
+
console = Console()
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
@fast.agent(
|
|
24
|
+
"forms-demo",
|
|
25
|
+
servers=[
|
|
26
|
+
"elicitation_forms_server",
|
|
27
|
+
],
|
|
28
|
+
)
|
|
29
|
+
async def main():
|
|
30
|
+
"""Run the improved forms demo showcasing all elicitation features."""
|
|
31
|
+
async with fast.run() as agent:
|
|
32
|
+
console.print("\n[bold cyan]Welcome to the Elicitation Forms Demo![/bold cyan]\n")
|
|
33
|
+
console.print("This demo shows how to collect structured data using MCP Elicitations.")
|
|
34
|
+
console.print("We'll present several forms and display the results collected for each.\n")
|
|
35
|
+
|
|
36
|
+
# Example 1: Event Registration
|
|
37
|
+
console.print("[bold yellow]Example 1: Event Registration Form[/bold yellow]")
|
|
38
|
+
console.print(
|
|
39
|
+
"[dim]Demonstrates: string validation, email format, URL format, date format[/dim]"
|
|
40
|
+
)
|
|
41
|
+
result = await agent.get_resource("elicitation://event-registration")
|
|
42
|
+
|
|
43
|
+
if result_text := get_resource_text(result):
|
|
44
|
+
panel = Panel(
|
|
45
|
+
result_text,
|
|
46
|
+
title="🎫 Registration Confirmation",
|
|
47
|
+
border_style="green",
|
|
48
|
+
expand=False,
|
|
49
|
+
)
|
|
50
|
+
console.print(panel)
|
|
51
|
+
else:
|
|
52
|
+
console.print("[red]No registration data received[/red]")
|
|
53
|
+
|
|
54
|
+
console.print("\n" + "─" * 50 + "\n")
|
|
55
|
+
|
|
56
|
+
# Example 2: Product Review
|
|
57
|
+
console.print("[bold yellow]Example 2: Product Review Form[/bold yellow]")
|
|
58
|
+
console.print(
|
|
59
|
+
"[dim]Demonstrates: number validation (range), radio selection, multiline text[/dim]"
|
|
60
|
+
)
|
|
61
|
+
result = await agent.get_resource("elicitation://product-review")
|
|
62
|
+
|
|
63
|
+
if result_text := get_resource_text(result):
|
|
64
|
+
review_panel = Panel(
|
|
65
|
+
result_text, title="🛍️ Product Review", border_style="cyan", expand=False
|
|
66
|
+
)
|
|
67
|
+
console.print(review_panel)
|
|
68
|
+
|
|
69
|
+
console.print("\n" + "─" * 50 + "\n")
|
|
70
|
+
|
|
71
|
+
# Example 3: Account Settings
|
|
72
|
+
console.print("[bold yellow]Example 3: Account Settings Form[/bold yellow]")
|
|
73
|
+
console.print(
|
|
74
|
+
"[dim]Demonstrates: boolean selections, radio selection, number validation[/dim]"
|
|
75
|
+
)
|
|
76
|
+
result = await agent.get_resource("elicitation://account-settings")
|
|
77
|
+
|
|
78
|
+
if result_text := get_resource_text(result):
|
|
79
|
+
settings_panel = Panel(
|
|
80
|
+
result_text, title="⚙️ Account Settings", border_style="blue", expand=False
|
|
81
|
+
)
|
|
82
|
+
console.print(settings_panel)
|
|
83
|
+
|
|
84
|
+
console.print("\n" + "─" * 50 + "\n")
|
|
85
|
+
|
|
86
|
+
# Example 4: Service Appointment
|
|
87
|
+
console.print("[bold yellow]Example 4: Service Appointment Booking[/bold yellow]")
|
|
88
|
+
console.print(
|
|
89
|
+
"[dim]Demonstrates: string validation, radio selection, boolean, datetime format[/dim]"
|
|
90
|
+
)
|
|
91
|
+
result = await agent.get_resource("elicitation://service-appointment")
|
|
92
|
+
|
|
93
|
+
if result_text := get_resource_text(result):
|
|
94
|
+
appointment_panel = Panel(
|
|
95
|
+
result_text, title="🔧 Appointment Confirmed", border_style="magenta", expand=False
|
|
96
|
+
)
|
|
97
|
+
console.print(appointment_panel)
|
|
98
|
+
|
|
99
|
+
console.print("\n[bold green]✅ Demo Complete![/bold green]")
|
|
100
|
+
console.print("\n[bold cyan]Features Demonstrated:[/bold cyan]")
|
|
101
|
+
console.print("• [green]String validation[/green] (min/max length)")
|
|
102
|
+
console.print("• [green]Number validation[/green] (range constraints)")
|
|
103
|
+
console.print("• [green]Radio selections[/green] (enum dropdowns)")
|
|
104
|
+
console.print("• [green]Boolean selections[/green] (checkboxes)")
|
|
105
|
+
console.print("• [green]Format validation[/green] (email, URL, date, datetime)")
|
|
106
|
+
console.print("• [green]Multiline text[/green] (expandable text areas)")
|
|
107
|
+
console.print("\nThese forms demonstrate natural, user-friendly data collection patterns!")
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
if __name__ == "__main__":
|
|
111
|
+
asyncio.run(main())
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
Demonstration of Custom Elicitation Handler
|
|
4
|
+
|
|
5
|
+
This example demonstrates a custom elicitation handler that creates
|
|
6
|
+
an interactive game character creation experience with dice rolls,
|
|
7
|
+
visual gauges, and fun interactions.
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
import asyncio
|
|
11
|
+
|
|
12
|
+
# Import our custom handler from the separate module
|
|
13
|
+
from game_character_handler import game_character_elicitation_handler
|
|
14
|
+
from rich.console import Console
|
|
15
|
+
from rich.panel import Panel
|
|
16
|
+
|
|
17
|
+
from mcp_agent.core.fastagent import FastAgent
|
|
18
|
+
from mcp_agent.mcp.helpers.content_helpers import get_resource_text
|
|
19
|
+
|
|
20
|
+
fast = FastAgent("Game Character Creator", quiet=True)
|
|
21
|
+
console = Console()
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
@fast.agent(
|
|
25
|
+
"character-creator",
|
|
26
|
+
servers=["elicitation_game_server"],
|
|
27
|
+
# Register our handler from game_character_handler.py
|
|
28
|
+
elicitation_handler=game_character_elicitation_handler,
|
|
29
|
+
)
|
|
30
|
+
async def main():
|
|
31
|
+
"""Run the game character creator with custom elicitation handler."""
|
|
32
|
+
async with fast.run() as agent:
|
|
33
|
+
console.print(
|
|
34
|
+
Panel(
|
|
35
|
+
"[bold cyan]Welcome to the Character Creation Studio![/bold cyan]\n\n"
|
|
36
|
+
"Create your hero with our magical character generator.\n"
|
|
37
|
+
"Watch as the cosmic dice determine your fate!",
|
|
38
|
+
title="🎮 Game Time 🎮",
|
|
39
|
+
border_style="magenta",
|
|
40
|
+
)
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
# Trigger the character creation
|
|
44
|
+
result = await agent.get_resource("elicitation://game-character")
|
|
45
|
+
|
|
46
|
+
if result_text := get_resource_text(result):
|
|
47
|
+
character_panel = Panel(
|
|
48
|
+
result_text, title="📜 Your Character 📜", border_style="green", expand=False
|
|
49
|
+
)
|
|
50
|
+
console.print(character_panel)
|
|
51
|
+
|
|
52
|
+
console.print("\n[italic]Your character is ready for adventure![/italic]")
|
|
53
|
+
console.print("[dim]The tavern door opens, and your journey begins...[/dim]\n")
|
|
54
|
+
|
|
55
|
+
# Fun ending based on character
|
|
56
|
+
if "Powerful character" in result_text:
|
|
57
|
+
console.print("⚔️ [bold]The realm trembles at your might![/bold]")
|
|
58
|
+
elif "Challenging build" in result_text:
|
|
59
|
+
console.print("🎯 [bold]True heroes are forged through adversity![/bold]")
|
|
60
|
+
else:
|
|
61
|
+
console.print("🗡️ [bold]Your legend begins now![/bold]")
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
if __name__ == "__main__":
|
|
65
|
+
asyncio.run(main())
|
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Custom Elicitation Handler for Game Character Creation
|
|
3
|
+
|
|
4
|
+
This module provides a whimsical custom elicitation handler that creates
|
|
5
|
+
an interactive game character creation experience with dice rolls,
|
|
6
|
+
visual gauges, and animated effects.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
import asyncio
|
|
10
|
+
import random
|
|
11
|
+
from typing import TYPE_CHECKING, Any, Dict
|
|
12
|
+
|
|
13
|
+
from mcp.shared.context import RequestContext
|
|
14
|
+
from mcp.types import ElicitRequestParams, ElicitResult
|
|
15
|
+
from rich.console import Console
|
|
16
|
+
from rich.progress import BarColumn, Progress, TextColumn
|
|
17
|
+
from rich.prompt import Confirm
|
|
18
|
+
from rich.table import Table
|
|
19
|
+
|
|
20
|
+
from mcp_agent.logging.logger import get_logger
|
|
21
|
+
|
|
22
|
+
if TYPE_CHECKING:
|
|
23
|
+
from mcp import ClientSession
|
|
24
|
+
|
|
25
|
+
logger = get_logger(__name__)
|
|
26
|
+
console = Console()
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
async def game_character_elicitation_handler(
|
|
30
|
+
context: RequestContext["ClientSession", Any],
|
|
31
|
+
params: ElicitRequestParams,
|
|
32
|
+
) -> ElicitResult:
|
|
33
|
+
"""Custom handler that creates an interactive character creation experience."""
|
|
34
|
+
logger.info(f"Game character elicitation handler called: {params.message}")
|
|
35
|
+
|
|
36
|
+
if params.requestedSchema:
|
|
37
|
+
properties = params.requestedSchema.get("properties", {})
|
|
38
|
+
content: Dict[str, Any] = {}
|
|
39
|
+
|
|
40
|
+
console.print("\n[bold magenta]🎮 Character Creation Studio 🎮[/bold magenta]\n")
|
|
41
|
+
|
|
42
|
+
# Character name with typewriter effect
|
|
43
|
+
if "character_name" in properties:
|
|
44
|
+
console.print("[cyan]✨ Generating your character's name...[/cyan] ", end="")
|
|
45
|
+
name_prefixes = ["Hero", "Legend", "Epic", "Mighty", "Brave", "Noble"]
|
|
46
|
+
name_suffixes = ["blade", "heart", "storm", "fire", "shadow", "star"]
|
|
47
|
+
|
|
48
|
+
name = f"{random.choice(name_prefixes)}{random.choice(name_suffixes)}{random.randint(1, 999)}"
|
|
49
|
+
|
|
50
|
+
for char in name:
|
|
51
|
+
console.print(char, end="", style="bold green")
|
|
52
|
+
await asyncio.sleep(0.03)
|
|
53
|
+
console.print("\n")
|
|
54
|
+
content["character_name"] = name
|
|
55
|
+
|
|
56
|
+
# Class selection with visual menu and fate dice
|
|
57
|
+
if "character_class" in properties:
|
|
58
|
+
class_enum = properties["character_class"].get("enum", [])
|
|
59
|
+
class_names = properties["character_class"].get("enumNames", class_enum)
|
|
60
|
+
|
|
61
|
+
table = Table(title="🎯 Choose Your Destiny", show_header=False, box=None)
|
|
62
|
+
table.add_column("Option", style="cyan", width=8)
|
|
63
|
+
table.add_column("Class", style="yellow", width=20)
|
|
64
|
+
table.add_column("Description", style="dim", width=30)
|
|
65
|
+
|
|
66
|
+
descriptions = [
|
|
67
|
+
"Master of sword and shield",
|
|
68
|
+
"Wielder of arcane mysteries",
|
|
69
|
+
"Silent shadow striker",
|
|
70
|
+
"Nature's deadly archer",
|
|
71
|
+
"Holy warrior of light",
|
|
72
|
+
"Inspiring magical performer",
|
|
73
|
+
]
|
|
74
|
+
|
|
75
|
+
for i, (cls, name, desc) in enumerate(zip(class_enum, class_names, descriptions)):
|
|
76
|
+
table.add_row(f"[{i + 1}]", name, desc)
|
|
77
|
+
|
|
78
|
+
console.print(table)
|
|
79
|
+
|
|
80
|
+
# Dramatic fate dice roll
|
|
81
|
+
console.print("\n[bold yellow]🎲 The Fates decide your path...[/bold yellow]")
|
|
82
|
+
for _ in range(8):
|
|
83
|
+
dice_face = random.choice(["⚀", "⚁", "⚂", "⚃", "⚄", "⚅"])
|
|
84
|
+
console.print(f"\r Rolling... {dice_face}", end="")
|
|
85
|
+
await asyncio.sleep(0.2)
|
|
86
|
+
|
|
87
|
+
fate_roll = random.randint(1, 6)
|
|
88
|
+
selected_idx = (fate_roll - 1) % len(class_enum)
|
|
89
|
+
console.print(f"\n 🎲 Fate dice: [bold red]{fate_roll}[/bold red]!")
|
|
90
|
+
console.print(
|
|
91
|
+
f"✨ Destiny has chosen: [bold yellow]{class_names[selected_idx]}[/bold yellow]!\n"
|
|
92
|
+
)
|
|
93
|
+
content["character_class"] = class_enum[selected_idx]
|
|
94
|
+
|
|
95
|
+
# Stats rolling with animated progress bars and cosmic effects
|
|
96
|
+
stat_names = ["strength", "intelligence", "dexterity", "charisma"]
|
|
97
|
+
stats_info = {
|
|
98
|
+
"strength": {"emoji": "💪", "desc": "Physical power"},
|
|
99
|
+
"intelligence": {"emoji": "🧠", "desc": "Mental acuity"},
|
|
100
|
+
"dexterity": {"emoji": "🏃", "desc": "Agility & speed"},
|
|
101
|
+
"charisma": {"emoji": "✨", "desc": "Personal magnetism"},
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
console.print("[bold]🌟 Rolling cosmic dice for your abilities...[/bold]\n")
|
|
105
|
+
|
|
106
|
+
with Progress(
|
|
107
|
+
TextColumn("[progress.description]{task.description}"),
|
|
108
|
+
BarColumn(bar_width=25, style="cyan", complete_style="green"),
|
|
109
|
+
TextColumn("[progress.percentage]{task.percentage:>3.0f}%"),
|
|
110
|
+
console=console,
|
|
111
|
+
) as progress:
|
|
112
|
+
for stat in stat_names:
|
|
113
|
+
if stat in properties:
|
|
114
|
+
# Roll 3d6 for classic D&D feel with bonus potential
|
|
115
|
+
rolls = [random.randint(1, 6) for _ in range(3)]
|
|
116
|
+
total = sum(rolls)
|
|
117
|
+
|
|
118
|
+
# Add cosmic bonus chance
|
|
119
|
+
if random.random() < 0.15: # 15% chance for cosmic boost
|
|
120
|
+
cosmic_bonus = random.randint(1, 3)
|
|
121
|
+
total = min(18, total + cosmic_bonus)
|
|
122
|
+
cosmic_text = f" ✨+{cosmic_bonus} COSMIC✨"
|
|
123
|
+
else:
|
|
124
|
+
cosmic_text = ""
|
|
125
|
+
|
|
126
|
+
stat_info = stats_info.get(stat, {"emoji": "📊", "desc": stat.title()})
|
|
127
|
+
task = progress.add_task(
|
|
128
|
+
f"{stat_info['emoji']} {stat.capitalize()}: {stat_info['desc']}", total=18
|
|
129
|
+
)
|
|
130
|
+
|
|
131
|
+
# Animate the progress bar with suspense
|
|
132
|
+
for i in range(total + 1):
|
|
133
|
+
progress.update(task, completed=i)
|
|
134
|
+
await asyncio.sleep(0.04)
|
|
135
|
+
|
|
136
|
+
content[stat] = total
|
|
137
|
+
console.print(
|
|
138
|
+
f" 🎲 Rolled: {rolls} = [bold green]{total}[/bold green]{cosmic_text}"
|
|
139
|
+
)
|
|
140
|
+
|
|
141
|
+
# Lucky dice legendary challenge
|
|
142
|
+
if "lucky_dice" in properties:
|
|
143
|
+
console.print("\n" + "=" * 60)
|
|
144
|
+
console.print("[bold yellow]🎰 LEGENDARY CHALLENGE: Lucky Dice! 🎰[/bold yellow]")
|
|
145
|
+
console.print("The ancient dice of fortune whisper your name...")
|
|
146
|
+
console.print("Do you dare tempt fate for legendary power?")
|
|
147
|
+
console.print("=" * 60)
|
|
148
|
+
|
|
149
|
+
# Epic dice rolling sequence
|
|
150
|
+
console.print("\n[cyan]🌟 Rolling the Dice of Destiny...[/cyan]")
|
|
151
|
+
|
|
152
|
+
for i in range(15):
|
|
153
|
+
dice_faces = ["⚀", "⚁", "⚂", "⚃", "⚄", "⚅"]
|
|
154
|
+
d20_faces = ["🎲"] * 19 + ["💎"] # Special diamond for 20
|
|
155
|
+
|
|
156
|
+
if i < 10:
|
|
157
|
+
face = random.choice(dice_faces)
|
|
158
|
+
else:
|
|
159
|
+
face = random.choice(d20_faces)
|
|
160
|
+
|
|
161
|
+
console.print(f"\r [bold]{face}[/bold] Rolling...", end="")
|
|
162
|
+
await asyncio.sleep(0.15)
|
|
163
|
+
|
|
164
|
+
final_roll = random.randint(1, 20)
|
|
165
|
+
|
|
166
|
+
if final_roll == 20:
|
|
167
|
+
console.print("\r [bold red]💎 NATURAL 20! 💎[/bold red]")
|
|
168
|
+
console.print(" [bold green]🌟 LEGENDARY SUCCESS! 🌟[/bold green]")
|
|
169
|
+
console.print(" [gold1]You have been blessed by the gods themselves![/gold1]")
|
|
170
|
+
bonus_text = "🏆 Divine Champion status unlocked!"
|
|
171
|
+
elif final_roll >= 18:
|
|
172
|
+
console.print(f"\r [bold yellow]⭐ {final_roll} - EPIC ROLL! ⭐[/bold yellow]")
|
|
173
|
+
bonus_text = "🎁 Epic treasure discovered!"
|
|
174
|
+
elif final_roll >= 15:
|
|
175
|
+
console.print(f"\r [green]🎲 {final_roll} - Great success![/green]")
|
|
176
|
+
bonus_text = "🌟 Rare magical item found!"
|
|
177
|
+
elif final_roll >= 10:
|
|
178
|
+
console.print(f"\r [yellow]🎲 {final_roll} - Good fortune.[/yellow]")
|
|
179
|
+
bonus_text = "🗡️ Modest blessing received."
|
|
180
|
+
elif final_roll == 1:
|
|
181
|
+
console.print("\r [bold red]💀 CRITICAL FUMBLE! 💀[/bold red]")
|
|
182
|
+
bonus_text = "😅 Learning experience gained... try again!"
|
|
183
|
+
else:
|
|
184
|
+
console.print(f"\r [dim]🎲 {final_roll} - The dice are silent.[/dim]")
|
|
185
|
+
bonus_text = "🎯 Your destiny remains unwritten."
|
|
186
|
+
|
|
187
|
+
console.print(f" [italic]{bonus_text}[/italic]")
|
|
188
|
+
content["lucky_dice"] = final_roll >= 10
|
|
189
|
+
|
|
190
|
+
# Epic character summary with theatrical flair
|
|
191
|
+
console.print("\n" + "=" * 70)
|
|
192
|
+
console.print("[bold cyan]📜 Your Character Has Been Rolled! 📜[/bold cyan]")
|
|
193
|
+
console.print("=" * 70)
|
|
194
|
+
|
|
195
|
+
# Show character summary
|
|
196
|
+
total_stats = sum(content.get(stat, 10) for stat in stat_names if stat in content)
|
|
197
|
+
|
|
198
|
+
# Create a simple table
|
|
199
|
+
stats_table = Table(show_header=False, box=None)
|
|
200
|
+
stats_table.add_column("Label", style="cyan", width=15)
|
|
201
|
+
stats_table.add_column("Value", style="bold white")
|
|
202
|
+
|
|
203
|
+
if "character_name" in content:
|
|
204
|
+
stats_table.add_row("Name:", content["character_name"])
|
|
205
|
+
if "character_class" in content:
|
|
206
|
+
class_idx = class_enum.index(content["character_class"])
|
|
207
|
+
stats_table.add_row("Class:", class_names[class_idx])
|
|
208
|
+
|
|
209
|
+
stats_table.add_row("", "") # Empty row for spacing
|
|
210
|
+
|
|
211
|
+
# Add stats
|
|
212
|
+
for stat in stat_names:
|
|
213
|
+
if stat in content:
|
|
214
|
+
stat_label = f"{stat.capitalize()}:"
|
|
215
|
+
stats_table.add_row(stat_label, str(content[stat]))
|
|
216
|
+
|
|
217
|
+
stats_table.add_row("", "")
|
|
218
|
+
stats_table.add_row("Total Power:", str(total_stats))
|
|
219
|
+
|
|
220
|
+
console.print(stats_table)
|
|
221
|
+
|
|
222
|
+
# Power message
|
|
223
|
+
if total_stats > 60:
|
|
224
|
+
console.print("✨ [bold gold1]The realm trembles before your might![/bold gold1] ✨")
|
|
225
|
+
elif total_stats > 50:
|
|
226
|
+
console.print("⚔️ [bold green]A formidable hero rises![/bold green] ⚔️")
|
|
227
|
+
elif total_stats < 35:
|
|
228
|
+
console.print("🎯 [bold blue]The underdog's tale begins![/bold blue] 🎯")
|
|
229
|
+
else:
|
|
230
|
+
console.print("🗡️ [bold white]Adventure awaits the worthy![/bold white] 🗡️")
|
|
231
|
+
|
|
232
|
+
# Ask for confirmation
|
|
233
|
+
console.print("\n[bold yellow]Do you accept this character?[/bold yellow]")
|
|
234
|
+
console.print("[dim]Press Enter to accept, 'n' to decline, or Ctrl+C to cancel[/dim]\n")
|
|
235
|
+
|
|
236
|
+
try:
|
|
237
|
+
accepted = Confirm.ask("Accept character?", default=True)
|
|
238
|
+
|
|
239
|
+
if accepted:
|
|
240
|
+
console.print(
|
|
241
|
+
"\n[bold green]✅ Character accepted! Your adventure begins![/bold green]"
|
|
242
|
+
)
|
|
243
|
+
return ElicitResult(action="accept", content=content)
|
|
244
|
+
else:
|
|
245
|
+
console.print(
|
|
246
|
+
"\n[yellow]❌ Character declined. The fates will roll again...[/yellow]"
|
|
247
|
+
)
|
|
248
|
+
return ElicitResult(action="decline")
|
|
249
|
+
except KeyboardInterrupt:
|
|
250
|
+
console.print("\n[red]❌ Character creation cancelled![/red]")
|
|
251
|
+
return ElicitResult(action="cancel")
|
|
252
|
+
|
|
253
|
+
else:
|
|
254
|
+
# No schema, return a fun message
|
|
255
|
+
content = {"response": "⚔️ Ready for adventure! ⚔️"}
|
|
256
|
+
return ElicitResult(action="accept", content=content)
|
|
@@ -3,19 +3,18 @@ import asyncio
|
|
|
3
3
|
from mcp_agent.core.fastagent import FastAgent
|
|
4
4
|
|
|
5
5
|
# Create the application
|
|
6
|
-
fast = FastAgent("
|
|
6
|
+
fast = FastAgent("fast-agent example")
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
# Define the agent
|
|
10
10
|
@fast.agent(
|
|
11
|
-
"agent",
|
|
12
11
|
instruction="You are a helpful AI Agent",
|
|
13
|
-
servers=["
|
|
12
|
+
servers=["elicitation_account_server"],
|
|
14
13
|
)
|
|
15
|
-
async def main()
|
|
14
|
+
async def main():
|
|
16
15
|
# use the --model command line switch or agent arguments to change model
|
|
17
16
|
async with fast.run() as agent:
|
|
18
|
-
await agent()
|
|
17
|
+
await agent.send('***CALL_TOOL create_user_account {"service_name": "fast-agent"}')
|
|
19
18
|
|
|
20
19
|
|
|
21
20
|
if __name__ == "__main__":
|
|
@@ -40,7 +40,7 @@ fast = FastAgent("Evaluator-Optimizer")
|
|
|
40
40
|
Summarize your evaluation as a structured response with:
|
|
41
41
|
- Overall quality rating.
|
|
42
42
|
- Specific feedback and areas for improvement.""",
|
|
43
|
-
model="gpt-
|
|
43
|
+
model="gpt-4.1",
|
|
44
44
|
)
|
|
45
45
|
# Define the evaluator-optimizer workflow
|
|
46
46
|
@fast.evaluator_optimizer(
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
# Graded Report: "The Kittens Castle Adventure"
|
|
2
|
+
|
|
3
|
+
## Proofreading Feedback
|
|
4
|
+
|
|
5
|
+
### Spelling Errors
|
|
6
|
+
1. "Adventuer" → "Adventure"
|
|
7
|
+
2. "lil" → "little"
|
|
8
|
+
3. "name" → "named"
|
|
9
|
+
4. "threw" → "through"
|
|
10
|
+
5. "mystirus" → "mysterious"
|
|
11
|
+
6. "forrest" → "forest"
|
|
12
|
+
7. "was" → "were"
|
|
13
|
+
8. "an" → "and"
|
|
14
|
+
9. "Suddenlee" → "Suddenly"
|
|
15
|
+
10. "sawd" → "saw"
|
|
16
|
+
11. "somthing" → "something"
|
|
17
|
+
12. "chese" → "cheese"
|
|
18
|
+
13. "windos" → "windows"
|
|
19
|
+
14. "turrits" → "turrets"
|
|
20
|
+
15. "tuch" → "touch"
|
|
21
|
+
16. "clowds" → "clouds"
|
|
22
|
+
17. "doars" → "doors"
|
|
23
|
+
18. "enuff" → "enough"
|
|
24
|
+
19. "elefant" → "elephant"
|
|
25
|
+
20. "sed" → "said"
|
|
26
|
+
21. "tale" → "tail"
|
|
27
|
+
22. "poofy" → "puffy"
|
|
28
|
+
23. "fowned" → "found"
|
|
29
|
+
24. "meowed" → added missing period
|
|
30
|
+
25. "smallist" → "smallest"
|
|
31
|
+
26. "rond" → "round"
|
|
32
|
+
27. "climed" → "climbed"
|
|
33
|
+
28. "slip-slidin" → "slip-sliding"
|
|
34
|
+
29. "smoth" → "smooth"
|
|
35
|
+
30. "surfase" → "surface"
|
|
36
|
+
31. "ful" → "full"
|
|
37
|
+
32. "dangling" → added missing period
|
|
38
|
+
33. "JINGEL" → "jingle"
|
|
39
|
+
34. "paradyse" → "paradise"
|
|
40
|
+
35. "figur" → "figure"
|
|
41
|
+
36. "gaurd" → "guard"
|
|
42
|
+
37. "sumthing" → "something"
|
|
43
|
+
38. "mor" → "more"
|
|
44
|
+
39. "hudeld" → "huddled"
|
|
45
|
+
40. "togethar" → "together"
|
|
46
|
+
41. "there" → "their"
|
|
47
|
+
42. "happan" → "happen"
|
|
48
|
+
43. "amazeing" → "amazing"
|
|
49
|
+
|
|
50
|
+
### Grammar and Syntax Errors
|
|
51
|
+
1. Inconsistent verb tenses throughout the story
|
|
52
|
+
2. Improper use of articles (a/an)
|
|
53
|
+
3. Missing punctuation
|
|
54
|
+
4. Lack of subject-verb agreement
|
|
55
|
+
5. Incorrect capitalization
|
|
56
|
+
|
|
57
|
+
### Style and Formatting Recommendations
|
|
58
|
+
1. Use standard capitalization for proper nouns
|
|
59
|
+
2. Maintain consistent verb tense (past tense recommended)
|
|
60
|
+
3. Use proper punctuation
|
|
61
|
+
4. Avoid excessive use of exclamation points
|
|
62
|
+
5. Use standard spelling for all words
|
|
63
|
+
|
|
64
|
+
## Factuality and Logical Consistency
|
|
65
|
+
- The story is a fictional narrative about three kittens, so traditional factual constraints do not strictly apply
|
|
66
|
+
- The narrative maintains internal logical consistency
|
|
67
|
+
- The cliffhanger ending leaves room for imagination
|
|
68
|
+
|
|
69
|
+
## Style Adherence
|
|
70
|
+
### APA Formatting Guidelines
|
|
71
|
+
- Title should be centered and in title case
|
|
72
|
+
- Use 12-point Times New Roman font (not applicable in markdown)
|
|
73
|
+
- Double-spacing recommended (not applicable in markdown)
|
|
74
|
+
- 1-inch margins (not applicable in markdown)
|
|
75
|
+
|
|
76
|
+
### Recommendations for Improvement
|
|
77
|
+
1. Proofread and correct all spelling errors
|
|
78
|
+
2. Maintain consistent grammar and syntax
|
|
79
|
+
3. Use standard English spelling
|
|
80
|
+
4. Add more descriptive language
|
|
81
|
+
5. Develop a more structured narrative arc
|
|
82
|
+
|
|
83
|
+
## Overall Assessment
|
|
84
|
+
**Writing Quality**: Needs Significant Improvement
|
|
85
|
+
**Creativity**: Excellent
|
|
86
|
+
**Potential**: High
|
|
87
|
+
|
|
88
|
+
### Suggested Revision
|
|
89
|
+
Revise the text to correct spelling, grammar, and syntax while preserving the original creative narrative and imaginative elements.
|
|
@@ -13,7 +13,7 @@ fast = FastAgent("Orchestrator-Workers")
|
|
|
13
13
|
@fast.agent(
|
|
14
14
|
"author",
|
|
15
15
|
instruction="""You are to role play a poorly skilled writer,
|
|
16
|
-
who makes frequent grammar,
|
|
16
|
+
who makes frequent grammar, punctuation and spelling errors. You enjoy
|
|
17
17
|
writing short stories, but the narrative doesn't always make sense""",
|
|
18
18
|
servers=["filesystem"],
|
|
19
19
|
)
|
|
@@ -25,7 +25,7 @@ fast = FastAgent("Orchestrator-Workers")
|
|
|
25
25
|
the closest match to a user's request, make the appropriate tool calls,
|
|
26
26
|
and return the URI and CONTENTS of the closest match.""",
|
|
27
27
|
servers=["fetch", "filesystem"],
|
|
28
|
-
model="gpt-
|
|
28
|
+
model="gpt-4.1",
|
|
29
29
|
)
|
|
30
30
|
@fast.agent(
|
|
31
31
|
name="writer",
|
|
@@ -40,19 +40,17 @@ fast = FastAgent("Orchestrator-Workers")
|
|
|
40
40
|
Identify any awkward phrasing or structural issues that could improve clarity.
|
|
41
41
|
Provide detailed feedback on corrections.""",
|
|
42
42
|
servers=["fetch"],
|
|
43
|
-
model="gpt-
|
|
43
|
+
model="gpt-4.1",
|
|
44
44
|
)
|
|
45
45
|
# Define the orchestrator to coordinate the other agents
|
|
46
46
|
@fast.orchestrator(
|
|
47
|
-
name="orchestrate",
|
|
48
|
-
agents=["finder", "writer", "proofreader"],
|
|
49
|
-
plan_type="full",
|
|
47
|
+
name="orchestrate", agents=["finder", "writer", "proofreader"], plan_type="full", model="sonnet"
|
|
50
48
|
)
|
|
51
49
|
async def main() -> None:
|
|
52
50
|
async with fast.run() as agent:
|
|
53
|
-
await agent.author(
|
|
54
|
-
|
|
55
|
-
)
|
|
51
|
+
# await agent.author(
|
|
52
|
+
# "write a 250 word short story about kittens discovering a castle, and save it to short_story.md"
|
|
53
|
+
# )
|
|
56
54
|
|
|
57
55
|
# The orchestrator can be used just like any other agent
|
|
58
56
|
task = """Load the student's short story from short_story.md,
|
|
@@ -25,7 +25,6 @@ fast = FastAgent(
|
|
|
25
25
|
instruction="""Verify the factual consistency within the story. Identify any contradictions,
|
|
26
26
|
logical inconsistencies, or inaccuracies in the plot, character actions, or setting.
|
|
27
27
|
Highlight potential issues with reasoning or coherence.""",
|
|
28
|
-
model="gpt-4.1-mini",
|
|
29
28
|
)
|
|
30
29
|
@fast.agent(
|
|
31
30
|
name="style_enforcer",
|
|
@@ -40,7 +39,6 @@ fast = FastAgent(
|
|
|
40
39
|
into a structured report. Summarize key issues and categorize them by type.
|
|
41
40
|
Provide actionable recommendations for improving the story,
|
|
42
41
|
and give an overall grade based on the feedback.""",
|
|
43
|
-
model="o3-mini.low",
|
|
44
42
|
)
|
|
45
43
|
@fast.parallel(
|
|
46
44
|
fan_out=["proofreader", "fact_checker", "style_enforcer"],
|