Skip to main content

Reasoning model integration for pydantic-ai's agent

Project description

pydantic-ai-deepagent

pydantic-ai's model to implement deepclaude-style-agent. Making models such as claude can use deepseek r1's thinking as a reference for tool use. Check the example.

⚠️ This is not a official project of PydanticAI, And PydanticAI is in early beta, the API is still subject to change and there's a lot more to do. Feedback is very welcome!

WIP

  • Implement StreamResponse
  • Add tests

Install

pip install pydantic_ai_deepagent

Usage

import os

from pydantic import BaseModel
from pydantic_ai import Agent, capture_run_messages
from pydantic_ai_bedrock.bedrock import BedrockModel

from pydantic_ai_deepagent.deepagent import DeepAgentModel
from pydantic_ai_deepagent.reasoning import DeepseekReasoningModel

DEEPSEEK_R1_MODEL_NAME = os.getenv("DEEPSEEK_R1_MODEL_NAME")
DEEPSEEK_R1_API_KEY = os.getenv("DEEPSEEK_R1_API_KEY")
DEEPSEEK_R1_BASE_URL = os.getenv("DEEPSEEK_R1_BASE_URL")

model = DeepAgentModel(
    reasoning_model=DeepseekReasoningModel(
        model_name=DEEPSEEK_R1_MODEL_NAME,
        api_key=DEEPSEEK_R1_API_KEY,
        base_url=DEEPSEEK_R1_BASE_URL,
    ),  # Any model's Textpart is reasoning content
    execution_model=BedrockModel(
        model_name="us.amazon.nova-micro-v1:0"
    ),  # Any other model can use tool call, e.g. OpenAI
)

agent = Agent(model)

More examples can be found in examples

Develop

Install pre-commit before commit

pip install pre-commit
pre-commit install

Install package locally

pip install -e .[test]

Run unit-test before PR, ensure that new features are covered by unit tests

pytest -v

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pydantic_ai_deepagent-0.0.3.tar.gz (22.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pydantic_ai_deepagent-0.0.3-py3-none-any.whl (11.7 kB view details)

Uploaded Python 3

File details

Details for the file pydantic_ai_deepagent-0.0.3.tar.gz.

File metadata

  • Download URL: pydantic_ai_deepagent-0.0.3.tar.gz
  • Upload date:
  • Size: 22.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for pydantic_ai_deepagent-0.0.3.tar.gz
Algorithm Hash digest
SHA256 99b4e0c2dcc58542cacaf54c555775e9f975be04183e47452f4c02eb5fed4e62
MD5 008af138a4d20232faea063bec289b68
BLAKE2b-256 f9f9dde9b0f501905beaf25c77897762a4b4ffa126b95fe44fda876e602a7838

See more details on using hashes here.

File details

Details for the file pydantic_ai_deepagent-0.0.3-py3-none-any.whl.

File metadata

File hashes

Hashes for pydantic_ai_deepagent-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 240b7846ce79cbbb618e3ba64b6287158097f7ecc0c9b57bb20020327646ff7b
MD5 f0c737e2a43b5630668a48626b717303
BLAKE2b-256 3ab61b48f7f7ac5036504081837d0bacbcf925845668f1ef575827dcada54b9f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page