Created
January 26, 2025 19:09
-
-
Save zzstoatzz/aef78ea17f9696ae50b43c79889d8069 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from typing import Annotated | |
from pydantic import Field | |
from pydantic_ai import Agent | |
# the Field description is respected by the LLM as it produces a list[HistoricEvent] | |
HistoricEvent = Annotated[str, Field(description="what, where, when, how, why - very concise")] | |
historic_event_brainstormer = Agent[None, list[HistoricEvent]]( | |
"openai:gpt-4o", | |
system_prompt="think of events from the last 300 years", | |
result_type=list[HistoricEvent] | |
) | |
result = historic_event_brainstormer.run_sync("wars between the US and Europe") | |
print(result.data) | |
""" | |
['1775-1783: American Revolutionary War: The thirteen American colonies fought against British rule to gain independence.', '1812-1815: War of 1812: The United States declared war on the United Kingdom over maritime rights and territorial expansion.', '1917-1918: World War I: The US joined the Allied Powers to fight against the Central Powers, including Germany, primarily in Europe.', '1941-1945: World War II: The US fought as part of the Allied Powers against the Axis Powers, including Nazi Germany, primarily in Europe.', '1999: Kosovo War: The US, within NATO, conducted a bombing campaign against Yugoslavia to halt human rights abuses in Kosovo.'] | |
""" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment