diff --git a/alembic/versions/2024_08_23_2012-6de11b2be7c8_add_suggested_title_to_task_generations_.py b/alembic/versions/2024_08_23_2012-6de11b2be7c8_add_suggested_title_to_task_generations_.py new file mode 100644 index 00000000..20b720f9 --- /dev/null +++ b/alembic/versions/2024_08_23_2012-6de11b2be7c8_add_suggested_title_to_task_generations_.py @@ -0,0 +1,31 @@ +"""Add suggested_title to task_generations table + +Revision ID: 6de11b2be7c8 +Revises: 8f237f00faeb +Create Date: 2024-08-23 20:12:13.426060+00:00 + +""" + +from typing import Sequence, Union + +import sqlalchemy as sa + +from alembic import op + +# revision identifiers, used by Alembic. +revision: str = "6de11b2be7c8" +down_revision: Union[str, None] = "8f237f00faeb" +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! ### + op.add_column("task_generations", sa.Column("suggested_title", sa.String(), nullable=True)) + # ### end Alembic commands ### + + +def downgrade() -> None: + # ### commands auto generated by Alembic - please adjust! ### + op.drop_column("task_generations", "suggested_title") + # ### end Alembic commands ### diff --git a/skyvern/forge/prompts/skyvern/generate-task.j2 b/skyvern/forge/prompts/skyvern/generate-task.j2 index c6ed7358..a9317874 100644 --- a/skyvern/forge/prompts/skyvern/generate-task.j2 +++ b/skyvern/forge/prompts/skyvern/generate-task.j2 @@ -2,6 +2,8 @@ We are building an AI agent that can automate browser tasks. The task creation s url: str. This is a required field. It is the starting URL for the task. This will be the first page the agent visits in order to achieve the goal. Use HTTPS URLs only. +suggested_title: str. This is a required field. It is the title of the task. It should be a few words long. It should describe what the task is doing. Example: "Find top post on hackernews", "Job search on LinkedIn", "Get Apple stock price". + navigation_goal_reasoning: str. This is a required field. The reason why navigation goal is needed to achieve the goal. Navigation goal is needed when the agent needs to take actions on the website to achieve the goal such as clicking a button, typing in a search bar, or navigating to another URL. is_navigation_goal_required: bool. This is a required field. Based on the navigation_goal_reasoning, whether the navigation goal is required to achieve the task. navigation_goal: str. This is an optional field. If is_navigation_goal_required is true, then this field should be provided. Otherwise, provide the value null. The value should be a string that we can use as an input to a Large Language Modal. It needs to tell the agent what actions need to be taken to achieve the task. It needs to define a single goal. If this field is provided, you must include explicit completion criteria. Provide completion criteria by completing the sentence: "COMPLETE when...". You can define guardrails that could help the agent from taking certain actions or getting derailed. diff --git a/skyvern/forge/sdk/db/client.py b/skyvern/forge/sdk/db/client.py index 53298113..87a80fe1 100644 --- a/skyvern/forge/sdk/db/client.py +++ b/skyvern/forge/sdk/db/client.py @@ -1391,6 +1391,7 @@ class AgentDB: navigation_payload: dict[str, Any] | None = None, data_extraction_goal: str | None = None, extracted_information_schema: dict[str, Any] | None = None, + suggested_title: str | None = None, llm: str | None = None, llm_prompt: str | None = None, llm_response: str | None = None, @@ -1407,6 +1408,7 @@ class AgentDB: llm=llm, llm_prompt=llm_prompt, llm_response=llm_response, + suggested_title=suggested_title, ) session.add(new_task_generation) await session.commit() diff --git a/skyvern/forge/sdk/db/models.py b/skyvern/forge/sdk/db/models.py index ec5f5cf9..7762c0f5 100644 --- a/skyvern/forge/sdk/db/models.py +++ b/skyvern/forge/sdk/db/models.py @@ -380,6 +380,7 @@ class TaskGenerationModel(Base): navigation_payload = Column(JSON) data_extraction_goal = Column(String) extracted_information_schema = Column(JSON) + suggested_title = Column(String) # task title suggested by the language model llm = Column(String) # language model to use llm_prompt = Column(String) # The prompt sent to the language model diff --git a/skyvern/forge/sdk/routes/agent_protocol.py b/skyvern/forge/sdk/routes/agent_protocol.py index f4a1cc46..e45bd001 100644 --- a/skyvern/forge/sdk/routes/agent_protocol.py +++ b/skyvern/forge/sdk/routes/agent_protocol.py @@ -779,6 +779,7 @@ async def generate_task( navigation_payload=parsed_task_generation_obj.navigation_payload, data_extraction_goal=parsed_task_generation_obj.data_extraction_goal, extracted_information_schema=parsed_task_generation_obj.extracted_information_schema, + suggested_title=parsed_task_generation_obj.suggested_title, llm=SettingsManager.get_settings().LLM_KEY, llm_prompt=llm_prompt, llm_response=str(llm_response), diff --git a/skyvern/forge/sdk/schemas/task_generations.py b/skyvern/forge/sdk/schemas/task_generations.py index 141023f1..383724f6 100644 --- a/skyvern/forge/sdk/schemas/task_generations.py +++ b/skyvern/forge/sdk/schemas/task_generations.py @@ -17,6 +17,7 @@ class TaskGenerationBase(BaseModel): llm: str | None = None llm_prompt: str | None = None llm_response: str | None = None + suggested_title: str | None = None class TaskGenerationCreate(TaskGenerationBase):