cua-agent 0.4.26__py3-none-any.whl → 0.4.27__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of cua-agent might be problematic. Click here for more details.
- agent/callbacks/prompt_instructions.py +47 -0
- {cua_agent-0.4.26.dist-info → cua_agent-0.4.27.dist-info}/METADATA +1 -1
- {cua_agent-0.4.26.dist-info → cua_agent-0.4.27.dist-info}/RECORD +5 -4
- {cua_agent-0.4.26.dist-info → cua_agent-0.4.27.dist-info}/WHEEL +0 -0
- {cua_agent-0.4.26.dist-info → cua_agent-0.4.27.dist-info}/entry_points.txt +0 -0
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Prompt instructions callback.
|
|
3
|
+
|
|
4
|
+
This callback allows simple prompt engineering by pre-pending a user
|
|
5
|
+
instructions message to the start of the conversation before each LLM call.
|
|
6
|
+
|
|
7
|
+
Usage:
|
|
8
|
+
|
|
9
|
+
from agent.callbacks import PromptInstructionsCallback
|
|
10
|
+
agent = ComputerAgent(
|
|
11
|
+
model="openai/computer-use-preview",
|
|
12
|
+
callbacks=[PromptInstructionsCallback("Follow these rules...")]
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
from typing import Any, Dict, List, Optional
|
|
18
|
+
|
|
19
|
+
from .base import AsyncCallbackHandler
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class PromptInstructionsCallback(AsyncCallbackHandler):
|
|
23
|
+
"""
|
|
24
|
+
Prepend a user instructions message to the message list.
|
|
25
|
+
|
|
26
|
+
This is a minimal, non-invasive way to guide the agent's behavior without
|
|
27
|
+
modifying agent loops or tools. It works with any provider/loop since it
|
|
28
|
+
only alters the messages array before sending to the model.
|
|
29
|
+
"""
|
|
30
|
+
|
|
31
|
+
def __init__(self, instructions: Optional[str]) -> None:
|
|
32
|
+
self.instructions = instructions
|
|
33
|
+
|
|
34
|
+
async def on_llm_start(self, messages: List[Dict[str, Any]]) -> List[Dict[str, Any]]:
|
|
35
|
+
# Pre-pend instructions message
|
|
36
|
+
if not self.instructions:
|
|
37
|
+
return messages
|
|
38
|
+
|
|
39
|
+
# Ensure we don't duplicate if already present at the front
|
|
40
|
+
if messages and isinstance(messages[0], dict):
|
|
41
|
+
first = messages[0]
|
|
42
|
+
if first.get("role") == "user" and first.get("content") == self.instructions:
|
|
43
|
+
return messages
|
|
44
|
+
|
|
45
|
+
return [
|
|
46
|
+
{"role": "user", "content": self.instructions},
|
|
47
|
+
] + messages
|
|
@@ -12,6 +12,7 @@ agent/callbacks/image_retention.py,sha256=8MeLo5-Y7cACpsNk2p_bvnZIYKpW6XgyukmdYG
|
|
|
12
12
|
agent/callbacks/logging.py,sha256=OOxU97EzrxlnUAtiEnvy9FB7SwCUK90-rdpDFA2Ae4E,10921
|
|
13
13
|
agent/callbacks/operator_validator.py,sha256=T5tp62pkShkcdHu2rgREUGdk8fryL_ziJsItXsfgYUQ,6494
|
|
14
14
|
agent/callbacks/pii_anonymization.py,sha256=NEkUTUjQBi82nqus7kT-1E4RaeQ2hQrY7YCnKndLhP8,3272
|
|
15
|
+
agent/callbacks/prompt_instructions.py,sha256=RUqsJhiNiXqaOM_P2AfyBinWUDdgDku46BExLMUJHn4,1517
|
|
15
16
|
agent/callbacks/telemetry.py,sha256=RbUDhE41mTi8g9hNre0EpltK_NUZkLj8buJLWBzs0Ek,7363
|
|
16
17
|
agent/callbacks/trajectory_saver.py,sha256=rslgg4Ak7JHSNmmJgANRQ5TsUYWGuUJDZ6amureaz_o,15963
|
|
17
18
|
agent/cli.py,sha256=AgaXwywHd3nGQWuqMRj6SbPyFaCPjfo5980Y1ApQOTQ,12413
|
|
@@ -45,7 +46,7 @@ agent/ui/__main__.py,sha256=vudWXYvGM0aNT5aZ94HPtGW8YXOZ4cLXepHyhUM_k1g,73
|
|
|
45
46
|
agent/ui/gradio/__init__.py,sha256=yv4Mrfo-Sj2U5sVn_UJHAuwYCezo-5O4ItR2C9jzNko,145
|
|
46
47
|
agent/ui/gradio/app.py,sha256=Ol97YEbwREZZQ9_PMjVHlfOcu9BGsawxgAGAm79hT80,9117
|
|
47
48
|
agent/ui/gradio/ui_components.py,sha256=dJUvKDmc1oSejtoR_gU_oWWYwxaOOQyPloSYRGMrUCQ,36068
|
|
48
|
-
cua_agent-0.4.
|
|
49
|
-
cua_agent-0.4.
|
|
50
|
-
cua_agent-0.4.
|
|
51
|
-
cua_agent-0.4.
|
|
49
|
+
cua_agent-0.4.27.dist-info/METADATA,sha256=L8bBLfo4X9vIz1q4wRc2ikHAZgsZ9obQM05WXSmUEcE,5624
|
|
50
|
+
cua_agent-0.4.27.dist-info/WHEEL,sha256=9P2ygRxDrTJz3gsagc0Z96ukrxjr-LFBGOgv3AuKlCA,90
|
|
51
|
+
cua_agent-0.4.27.dist-info/entry_points.txt,sha256=6OYgBcLyFCUgeqLgnvMyOJxPCWzgy7se4rLPKtNonMs,34
|
|
52
|
+
cua_agent-0.4.27.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|