Skip to content

Commit 75a12d1

Browse files
committed
add example
1 parent 24c2b54 commit 75a12d1

File tree

3 files changed

+40
-10
lines changed

3 files changed

+40
-10
lines changed

README.md

+9-6
Original file line numberDiff line numberDiff line change
@@ -250,23 +250,26 @@ Tasks are:
250250
Agents are portable LLM configurations that can be assigned to tasks. They encapsulate everything an AI needs to work effectively:
251251

252252
```python
253+
import os
253254
from pathlib import Path
255+
from pydantic_ai.models.anthropic import AnthropicModel
254256
import marvin
255257

256258
def write_file(path: str, content: str):
257259
"""Write content to a file"""
258-
path = Path(path)
259-
path.write_text(content)
260+
_path = Path(path)
261+
_path.write_text(content)
260262

261-
# Create a specialized agent
262263
writer = marvin.Agent(
264+
model=AnthropicModel(
265+
"anthropic/claude-3-5-sonnet@latest", api_key=os.getenv("ANTHROPIC_API_KEY")
266+
),
263267
name="Technical Writer",
264-
instructions="Write clear, engaging content for developers",
265-
tools=[write_file]
268+
instructions="Write concise, engaging content for developers",
269+
tools=[write_file],
266270
)
267271

268272
result = marvin.run("how to use pydantic? write to docs.md", agents=[writer])
269-
270273
print(result)
271274
```
272275
<details>

examples/hello_agent.py

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import os
2+
from pathlib import Path
3+
4+
from pydantic_ai.models.anthropic import AnthropicModel
5+
6+
import marvin
7+
8+
9+
def write_file(path: str, content: str):
10+
"""Write content to a file"""
11+
_path = Path(path)
12+
_path.write_text(content)
13+
14+
15+
# Create a specialized agent
16+
writer = marvin.Agent(
17+
model=AnthropicModel(
18+
"anthropic/claude-3-5-sonnet@latest", api_key=os.getenv("ANTHROPIC_API_KEY")
19+
),
20+
name="Technical Writer",
21+
instructions="Write concise, engaging content for developers",
22+
tools=[write_file],
23+
)
24+
25+
result = marvin.run("how to use pydantic? write to docs.md", agents=[writer])
26+
27+
print(result)

uv.lock

+4-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)