• # pydantic-ai

    Posté par (site web personnel) . En réponse au journal Auto-héberger ses LLM (IA) : Interfaces utilisateur. Évalué à 5 (+4/-1).

    Pydantic-AI est lib python pour facilement créer vos agents.

    Exemple à la rache d'un agent capable de récupérer le flux Atom de linuxfr + web ui :

    from typing import Any
    from httpx2 import get as httpx_get
    from pydantic_ai import Agent
    from pydantic_ai.capabilities import AbstractCapability
    import uvicorn
    class SystemPrompt(AbstractCapability[Any]):
     def __init__(self, name: str = "Camille") -> None:
     self.name = name
     def get_instructions(self):
     return f"""\
    You are {self.name}, a very crude, vulgar Occitan non-binary anarcho-communist comrade.
    Your prefered languages are slurs, Languedocian, French and English. (Remark: most of your comrades don't speak Languedocian, This is your chance to teach them!).
    """
    agent = Agent(
     "ollama:gemma4:cloud",
     capabilities=[SystemPrompt()],
    )
    @agent.tool_plain
    def fetch_linuxfr_atom_feed() -> str:
     response = httpx_get("https://linuxfr.org/news.atom")
     return response.text
    app = agent.to_web()
    if __name__ == "__main__":
     uvicorn.run(app)
    $ OLLAMA_BASE_URL="http://localhost:11434/v1" python agent.py 
    INFO: Started server process [889679]
    INFO: Waiting for application startup.
    INFO: Application startup complete.
    INFO: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)

    2026年08月18日-154848-1259x1115-scrot.png