Co-authored-by: Kim-Adeline Miguel <51720070+kimadeline@users.noreply.github.com> Co-authored-by: Mathias Gesbert <mathias.gesbert@mistral.ai> Co-authored-by: Maxime Dolores <maxime.dolores@ext.mistral.ai> Co-authored-by: Nelson PROIA <144663685+Nelson-PROIA@users.noreply.github.com> Co-authored-by: Paul VEZIA <166131032+le-codeur-rapide@users.noreply.github.com> Co-authored-by: Pierre Rossinès <pierre.rossines@mistral.ai> Co-authored-by: Quentin <quentin.torroba@mistral.ai> Co-authored-by: Val <102326092+vdeva@users.noreply.github.com> Co-authored-by: Vincent G <10739306+VinceOPS@users.noreply.github.com> Co-authored-by: Mistral Vibe <vibe@mistral.ai>
35 lines
939 B
Python
35 lines
939 B
Python
from __future__ import annotations
|
|
|
|
from collections.abc import AsyncGenerator
|
|
|
|
from pydantic import BaseModel
|
|
|
|
from vibe.core.tools.base import BaseTool, BaseToolConfig, BaseToolState, InvokeContext
|
|
from vibe.core.types import ToolStreamEvent
|
|
|
|
|
|
class FakeToolArgs(BaseModel):
|
|
text: str = ""
|
|
|
|
|
|
class FakeToolResult(BaseModel):
|
|
message: str = "fake tool executed"
|
|
|
|
|
|
class FakeToolState(BaseToolState):
|
|
pass
|
|
|
|
|
|
class FakeTool(BaseTool[FakeToolArgs, FakeToolResult, BaseToolConfig, FakeToolState]):
|
|
_exception_to_raise: BaseException | None = None
|
|
|
|
@classmethod
|
|
def get_name(cls) -> str:
|
|
return "stub_tool"
|
|
|
|
async def run(
|
|
self, args: FakeToolArgs, ctx: InvokeContext | None = None
|
|
) -> AsyncGenerator[ToolStreamEvent | FakeToolResult, None]:
|
|
if self._exception_to_raise:
|
|
raise self._exception_to_raise
|
|
yield FakeToolResult(message=args.text or "fake tool executed")
|