Skip to content

Commit 4edd6ce

Browse files
authored
Update computer prompt (#15)
1 parent 3f0ddeb commit 4edd6ce

1 file changed

Lines changed: 11 additions & 5 deletions

File tree

internal/prompt/prompt.go

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,11 @@ import (
2424
const (
2525
model = openai.ChatModelGPT5_4
2626

27-
waitDuration = 1 * time.Second
27+
computerInstructions = "You are controlling a desktop over VNC. " +
28+
"Use the screenshot as the source of truth. Before typing, pressing Enter, " +
29+
"or using keyboard shortcuts, make sure the intended element or window is focused."
30+
31+
waitDuration = 5 * time.Second
2832
)
2933

3034
func Prompt(ctx context.Context, desktop desktoppkg.Desktop, text string) error {
@@ -47,7 +51,8 @@ func Prompt(ctx context.Context, desktop desktoppkg.Desktop, text string) error
4751
slog.DebugContext(ctx, "calling LLM", "model", model)
4852

4953
params := responses.ResponseNewParams{
50-
Model: model,
54+
Instructions: openai.String(computerInstructions),
55+
Model: model,
5156
Input: responses.ResponseNewParamsInputUnion{
5257
OfInputItemList: input,
5358
},
@@ -124,7 +129,7 @@ func handleAction(
124129
) error {
125130
switch typedAction := action.AsAny().(type) {
126131
case responses.ComputerActionClick:
127-
slog.DebugContext(ctx, "clicking", "button", typedAction.Button,
132+
slog.InfoContext(ctx, "clicking", "button", typedAction.Button,
128133
"x", typedAction.X, "y", typedAction.Y)
129134

130135
return click(ctx, desktop, typedAction.Button, typedAction.X, typedAction.Y)
@@ -151,7 +156,8 @@ func handleAction(
151156
return mouse(ctx, desktop, 0, typedAction.X, typedAction.Y)
152157
case responses.ComputerActionScreenshot:
153158
// We unconditionally attach the screenshot after processing each computer call
154-
slog.InfoContext(ctx, "delaying screenshot action")
159+
// so let's just acknowledge the screenshot request
160+
slog.InfoContext(ctx, "taking screenshot")
155161

156162
return nil
157163
case responses.ComputerActionScroll:
@@ -164,7 +170,7 @@ func handleAction(
164170

165171
return desktoppkg.TypeText(ctx, desktop, typedAction.Text)
166172
case responses.ComputerActionWait:
167-
slog.InfoContext(ctx, "waiting", "duration", waitDuration)
173+
slog.DebugContext(ctx, "waiting", "duration", waitDuration)
168174

169175
select {
170176
case <-time.After(waitDuration):

0 commit comments

Comments
 (0)