2.0.0
Co-Authored-By: Quentin Torroba <quentin.torroba@mistral.ai> Co-Authored-By: Michel Thomazo <michel.thomazo@mistral.ai> Co-Authored-By: Clément Drouin <clement.drouin@mistral.ai> Co-Authored-By: Vincent Guilloux <vincent.guilloux@mistral.ai> Co-Authored-By: Clément Siriex <clement.sirieix@mistral.ai> Co-Authored-By: Kim-Adeline Miguel <kimadeline.miguel@mistral.ai> Co-Authored-By: Thaddee Tyl <thaddee.tyl@gmail.com> Co-Authored-By: David Brochart <david.brochart@gmail.com> Co-Authored-By: Joseph Guhlin <joseph.guhlin@gmail.com> Co-Authored-By: Thomas Kenbeek <thomaskenbeek@gmail.com> Co-Authored-By: Remenby31 <baptiste.cruvellier31@gmail.com>
This commit is contained in:
parent
79f215d91c
commit
d33db9fff8
217 changed files with 16911 additions and 4305 deletions
|
|
@ -2,9 +2,9 @@ from __future__ import annotations
|
|||
|
||||
import asyncio
|
||||
|
||||
from vibe.core.agent import Agent
|
||||
from vibe.core.agent_loop import AgentLoop
|
||||
from vibe.core.agents.models import BuiltinAgentName
|
||||
from vibe.core.config import VibeConfig
|
||||
from vibe.core.modes import AgentMode
|
||||
from vibe.core.output_formatters import create_formatter
|
||||
from vibe.core.types import AssistantEvent, LLMMessage, OutputFormat, Role
|
||||
from vibe.core.utils import ConversationLimitException, logger
|
||||
|
|
@ -17,27 +17,13 @@ def run_programmatic(
|
|||
max_price: float | None = None,
|
||||
output_format: OutputFormat = OutputFormat.TEXT,
|
||||
previous_messages: list[LLMMessage] | None = None,
|
||||
mode: AgentMode = AgentMode.AUTO_APPROVE,
|
||||
agent_name: str = BuiltinAgentName.AUTO_APPROVE,
|
||||
) -> str | None:
|
||||
"""Run in programmatic mode: execute prompt and return the assistant response.
|
||||
|
||||
Args:
|
||||
config: Configuration for the Vibe agent
|
||||
prompt: The user prompt to process
|
||||
max_turns: Maximum number of assistant turns (LLM calls) to allow
|
||||
max_price: Maximum cost in dollars before stopping
|
||||
output_format: Format for the output
|
||||
previous_messages: Optional messages from a previous session to continue
|
||||
mode: Operational mode (defaults to AUTO_APPROVE for programmatic use)
|
||||
|
||||
Returns:
|
||||
The final assistant response text, or None if no response
|
||||
"""
|
||||
formatter = create_formatter(output_format)
|
||||
|
||||
agent = Agent(
|
||||
agent_loop = AgentLoop(
|
||||
config,
|
||||
mode=mode,
|
||||
agent_name=agent_name,
|
||||
message_observer=formatter.on_message_added,
|
||||
max_turns=max_turns,
|
||||
max_price=max_price,
|
||||
|
|
@ -50,12 +36,12 @@ def run_programmatic(
|
|||
non_system_messages = [
|
||||
msg for msg in previous_messages if not (msg.role == Role.system)
|
||||
]
|
||||
agent.messages.extend(non_system_messages)
|
||||
agent_loop.messages.extend(non_system_messages)
|
||||
logger.info(
|
||||
"Loaded %d messages from previous session", len(non_system_messages)
|
||||
)
|
||||
|
||||
async for event in agent.act(prompt):
|
||||
async for event in agent_loop.act(prompt):
|
||||
formatter.on_event(event)
|
||||
if isinstance(event, AssistantEvent) and event.stopped_by_middleware:
|
||||
raise ConversationLimitException(event.content)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue