forked from PrefectHQ/marvin
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_agent.py
More file actions
30 lines (22 loc) · 723 Bytes
/
Copy pathrun_agent.py
File metadata and controls
30 lines (22 loc) · 723 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import os
from pathlib import Path
from pydantic_ai.models.openai import OpenAIModel
import marvin
from marvin.providers.aimlapi import AIMLAPIProvider
def write_file(path: str, content: str) -> None:
"""Write content to a file."""
Path(path).write_text(content)
writer = marvin.Agent(
model=OpenAIModel(
"gpt-4o-mini",
provider=AIMLAPIProvider(api_key=os.getenv("AIML_API_KEY")),
),
name="AI/ML Writer",
instructions="Write concise, engaging content for developers",
tools=[write_file],
)
async def main():
result = await marvin.run("how to use pydantic? write haiku to docs.md", agents=[writer])
print(result)
if __name__ == "__main__":
asyncio.run(main())