diff options
author | Ben Sima <ben@bsima.me> | 2025-05-06 18:01:11 -0400 |
---|---|---|
committer | Ben Sima <ben@bsima.me> | 2025-05-07 22:52:46 -0400 |
commit | b0d3330c67b6874a1eaf23978749b26d99fbdfab (patch) | |
tree | a21acfd5340431c0a07dcc12b515fe6f5f1fad8e /Omni/Bild/Deps/pydantic-ai.nix | |
parent | 3127cefa0d01f18b5c503e797ee1cf87aa61964c (diff) |
Switch Python to unstable and add pydantic-ai
Pydantic-ai is an agent framework that seems simple and good: well-typed with
pydantic, tool usage is just an `@tool` decorator on a function, and so
on. While building these I realized there were some deps they needed that were
already in nixpkgs unstable, so I just switched to that instead of trying to
backport all the versions and stuff.
Diffstat (limited to 'Omni/Bild/Deps/pydantic-ai.nix')
-rw-r--r-- | Omni/Bild/Deps/pydantic-ai.nix | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/Omni/Bild/Deps/pydantic-ai.nix b/Omni/Bild/Deps/pydantic-ai.nix new file mode 100644 index 0000000..399649d --- /dev/null +++ b/Omni/Bild/Deps/pydantic-ai.nix @@ -0,0 +1,75 @@ +{ + lib, + buildPythonPackage, + hatchling, + pydantic-ai-slim, + pythonOlder, + pytest-vcr, + dirty-equals, + sources, + writeTextFile, +}: let + version = sources.pydantic-ai.version; + pyproject_toml = writeTextFile { + name = "pyproject.toml"; + text = '' + [build-system] + requires = ["hatchling"] + build-backend = "hatchling.build" + + [project] + name = "pydantic-ai" + version = "${version}" + description = "Agent Framework / shim to use Pydantic with LLMs" + authors = [ + { name = "Samuel Colvin", email = "samuel@pydantic.dev" }, + { name = "Marcelo Trylesinski", email = "marcelotryle@gmail.com" }, + { name = "David Montague", email = "david@pydantic.dev" }, + { name = "Alex Hall", email = "alex@pydantic.dev" }, + ] + license = "MIT" + readme = "README.md" + requires-python = ">=3.9" + dependencies = [ + "pydantic-ai-slim[openai,vertexai,groq,anthropic,mistral,cohere,bedrock,cli,mcp,evals]==${version}", + ] + + [project.urls] + Homepage = "https://ai.pydantic.dev" + Source = "https://github.com/pydantic/pydantic-ai" + Documentation = "https://ai.pydantic.dev" + Changelog = "https://github.com/pydantic/pydantic-ai/releases" + + [project.scripts] + pai = "pydantic_ai._cli:app" + ''; + }; +in + buildPythonPackage rec { + pname = "pydantic-ai"; + inherit version; + pyproject = true; + disabled = pythonOlder "3.8"; + src = sources.pydantic-ai; + build-system = [hatchling]; + dependencies = [pydantic-ai-slim]; + nativeCheckInputs = [ + pydantic-ai-slim + pytest-vcr + dirty-equals + # pytestCheckHook + ]; + preBuild = '' + cp ${pyproject_toml} ./pyproject.toml + ''; + pythonImportsCheck = [ + "pydantic_ai" + ]; + meta = { + description = "Agent Framework / shim to use Pydantic with LLMs"; + homepage = "https://github.com/pydantic/pydantic-ai"; + changelog = "https://github.com/pydantic/pydantic-ai/releases/tag/v${version}"; + license = lib.licenses.mit; + maintainers = with lib.maintainers; [bsima]; + }; + } |