Skip to content

Commit

Permalink
further simplify intervention mode
Browse files Browse the repository at this point in the history
  • Loading branch information
jjallaire committed Oct 6, 2024
1 parent e342779 commit e324cbe
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 20 deletions.
14 changes: 4 additions & 10 deletions examples/intervention/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ def intervention():
solver=[
system_prompt(),
user_prompt(),
agent_loop([bash(), python()]),
use_tools([bash(), python()]),
agent_loop(),
],
sandbox="docker",
)
Expand All @@ -51,14 +52,11 @@ First, we ask the user to enter a prompt for the model:
@solver
def user_prompt() -> Solver:
async def solve(state: TaskState, generate: Generate) -> TaskState:

with input_screen("User Prompt") as console:
user_prompt = Prompt.ask(
state.user_prompt.content = Prompt.ask(
"Please enter your initial prompt for the model:\n\n", console=console
)

state.user_prompt.content = user_prompt

return state

return solve
Expand All @@ -72,12 +70,8 @@ The agent loop is [just a plain Inspect solver.](https://inspect.ai-safety-insti

``` python
@solver
def agent_loop(tools: list[Tool]) -> Solver:
def agent_loop() -> Solver:
async def solve(state: TaskState, generate: Generate) -> TaskState:
# set tools
state.tools = tools

# main loop
while not state.completed:
# generate w/ tool calls, approvals, etc.
state = await generate(state)
Expand Down
16 changes: 6 additions & 10 deletions examples/intervention/intervention.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@
TaskState,
solver,
system_message,
use_tools,
)
from inspect_ai.tool import Tool, bash, python
from inspect_ai.tool import bash, python
from inspect_ai.util import input_screen


Expand All @@ -21,7 +22,8 @@ def intervention():
solver=[
system_prompt(),
user_prompt(),
agent_loop([bash(), python()]),
use_tools([bash(), python()]),
agent_loop(),
],
sandbox="docker",
)
Expand Down Expand Up @@ -51,24 +53,18 @@ def system_prompt():
def user_prompt() -> Solver:
async def solve(state: TaskState, generate: Generate) -> TaskState:
with input_screen("User Prompt") as console:
user_prompt = Prompt.ask(
state.user_prompt.content = Prompt.ask(
"Please enter your initial prompt for the model:\n\n", console=console
)

state.user_prompt.content = user_prompt

return state

return solve


@solver
def agent_loop(tools: list[Tool]) -> Solver:
def agent_loop() -> Solver:
async def solve(state: TaskState, generate: Generate) -> TaskState:
# set tools
state.tools = tools

# main loop
while not state.completed:
# generate w/ tool calls, approvals, etc.
state = await generate(state)
Expand Down

0 comments on commit e324cbe

Please sign in to comment.