What's Changed
- Improve tools support in OpenaiTemplate and GeminiPro by @hlohaus in #2734
- Update models in DDG, PerplexityLabs, Gemini
- Fix issues with curl_cffi in new versions
- Show only free providers by default
- Add mixtral_small_24b model from DDG
PydanticAI Integration with G4F Client
Quick Setup
- Patch G4F to Use PydanticAI Models
In order to use PydanticAI models with G4F, you need to apply the necessary patch to the client. This can be done by importing apply_patch from g4f.tools.pydantic_ai.
from g4f.tools.pydantic_ai import apply_patch
apply_patch()
- Create a Simple Agent
Now you are ready to create a simple agent that can interact with the LLM. The agent is initialized with a model, and you can also define a system prompt. Here's an example where a basic agent is created with the model g4f:Gemini:Gemini and a simple system prompt:
from pydantic_ai import Agent
# Define the agent
agent = Agent(
'g4f:Gemini:Gemini', # g4f:provider:model_name or g4f:model_name
system_prompt='Be concise, reply with one sentence.',
)
Read More: PydanticAI Integration with G4F Client
Full Changelog: 0.4.6.2...0.4.7.0