+32
-3
update-lights
+32
-3
update-lights
···
1
1
#!/usr/bin/env -S uv run --script --quiet
2
2
# /// script
3
3
# requires-python = ">=3.12"
4
-
# dependencies = ["marvin@git+https://github.com/prefecthq/marvin.git"]
4
+
# dependencies = ["marvin>=3.1.0"]
5
5
# ///
6
6
"""
7
7
Make some change to my phillips hue network of lights via agent + MCP server.
···
25
25
from pydantic import Field
26
26
from pydantic_ai.mcp import MCPServerStdio
27
27
from pydantic_ai.models import KnownModelName
28
+
from rich.console import Console
29
+
from rich.panel import Panel
30
+
from rich.prompt import Prompt
28
31
29
32
30
33
class Settings(BaseSettings):
···
33
36
hue_bridge_ip: str = Field(default=...)
34
37
hue_bridge_username: str = Field(default=...)
35
38
36
-
ai_model: KnownModelName = Field(default="gpt-4o")
39
+
ai_model: KnownModelName = Field(default="gpt-4.1-mini")
37
40
38
41
39
42
settings = Settings()
43
+
console = Console()
40
44
41
45
hub_mcp = MCPServerStdio(
42
46
command="uvx",
···
65
69
model=settings.ai_model,
66
70
mcp_servers=[hub_mcp],
67
71
)
68
-
agent.run(str(args.message))
72
+
73
+
console.print(
74
+
Panel.fit(
75
+
f"[bold cyan]🏠 lights agent[/bold cyan]\n"
76
+
f"[dim]model: {settings.ai_model}[/dim]",
77
+
border_style="blue",
78
+
)
79
+
)
80
+
81
+
with marvin.Thread():
82
+
first = True
83
+
while True:
84
+
if first:
85
+
console.print(f"\n[bold yellow]→[/bold yellow] {args.message}")
86
+
agent.run(str(args.message))
87
+
first = False
88
+
else:
89
+
try:
90
+
user_input = Prompt.ask(
91
+
"\n[bold green]enter a message[/bold green]"
92
+
)
93
+
console.print(f"[bold yellow]→[/bold yellow] {user_input}")
94
+
agent.run(str(user_input))
95
+
except KeyboardInterrupt:
96
+
console.print("\n[dim red]exiting...[/dim red]")
97
+
break