mirror of
https://github.com/Pythagora-io/gpt-pilot.git
synced 2026-01-10 13:37:55 -05:00
This is a complete rewrite of the GPT Pilot core, from the ground up, making the agentic architecture front and center, and also fixing some long-standing problems with the database architecture that weren't feasible to solve without breaking compatibility. As the database structure and config file syntax have changed, we have automatic imports for projects and current configs, see the README.md file for details. This also relicenses the project to FSL-1.1-MIT license.
44 lines
1.2 KiB
Python
44 lines
1.2 KiB
Python
from unittest.mock import MagicMock
|
|
|
|
from pydantic import BaseModel, Field
|
|
|
|
from core.agents.convo import AgentConvo
|
|
|
|
|
|
def test_init():
|
|
"""Test that init stores the agent instance and adds a system message."""
|
|
agent = MagicMock(agent_type="spec-writer", current_state=None)
|
|
convo = AgentConvo(agent)
|
|
|
|
assert convo.agent_instance == agent
|
|
assert len(convo.messages) == 1
|
|
assert convo.messages[0]["role"] == "system"
|
|
|
|
|
|
def test_fork():
|
|
"""Test that fork() creates a new AgentConvo instance, not base Convo."""
|
|
agent = MagicMock(agent_type="spec-writer", current_state=None)
|
|
convo = AgentConvo(agent)
|
|
|
|
child = convo.fork()
|
|
assert child.agent_instance == agent
|
|
|
|
child.template("ask_questions")
|
|
|
|
assert len(convo.messages) == 1
|
|
assert len(child.messages) == 2
|
|
|
|
|
|
def test_require_schema():
|
|
"""Test that require_schema() adds a message with the schema description."""
|
|
|
|
class MyModel(BaseModel):
|
|
name: str = Field(description="User name")
|
|
age: int
|
|
|
|
agent = MagicMock(agent_type="spec-writer", current_state=None)
|
|
convo = AgentConvo(agent).require_schema(MyModel)
|
|
|
|
assert len(convo.messages) == 2
|
|
assert '"description": "User name"' in convo.messages[1]["content"]
|