Adding the migration for the knowledge base field

pull/1160/head
Zvonimir Sabljic 2 years ago
parent 1e0f871982
commit 344a6c19b4

@ -0,0 +1,34 @@
"""Adding knowledge_base field to ProjectState
Revision ID: f708791b9270
Revises: c8905d4ce784
Create Date: 2024-12-22 12:13:14.979169
"""
from typing import Sequence, Union
import sqlalchemy as sa
from alembic import op
# revision identifiers, used by Alembic.
revision: str = "f708791b9270"
down_revision: Union[str, None] = "c8905d4ce784"
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None
def upgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table("project_states", schema=None) as batch_op:
batch_op.add_column(sa.Column("knowledge_base", sa.JSON(), server_default="{}", nullable=False))
# ### end Alembic commands ###
def downgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table("project_states", schema=None) as batch_op:
batch_op.drop_column("knowledge_base")
# ### end Alembic commands ###

@ -1,44 +0,0 @@
import pytest
from core.agents.mixins import TestSteps
from core.agents.troubleshooter import RouteFilePaths, Troubleshooter
from core.db.models import File, FileContent
@pytest.mark.asyncio
async def test_route_files_are_included_in_the_prompt(agentcontext):
sm, _, ui, mock_get_llm = agentcontext
sm.current_state.tasks = [
{
"description": "Some task",
"status": "todo",
"instructions": {
"steps": [
{"title": "1", "action": "test", "result": "Result 1"},
]
},
}
]
files = [
File(path="dir/file1.js", content=FileContent(content="File 1 content")),
File(path="dir/file2.js", content=FileContent(content="File 2 content")),
]
await sm.commit()
sm.current_state.files = files
ts = Troubleshooter(sm, ui)
ts.get_llm = mock_get_llm(
side_effect=[
RouteFilePaths(files=["dir/file1.js"]), # First LLM call, to select files with routes
TestSteps(
steps=[{"title": "1", "action": "test", "result": "Result 1"}]
), # Second LLM call, to generate the actual instructions
]
)
await ts.get_user_instructions()
second_llm_call = ts.get_llm().call_args_list[1]
user_msg_contents = [msg["content"] for msg in second_llm_call[0][0] if msg["role"] == "user"]
assert "File 1 content" in user_msg_contents[1] # Prompt at [1] has the route file contents
assert "File 2 content" not in user_msg_contents[1]
Loading…
Cancel
Save