goose-py 0.11.1__py3-none-any.whl → 0.11.3__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.
- goose/_internal/agent.py +12 -4
- goose/_internal/state.py +7 -5
- goose/_internal/types/telemetry.py +8 -3
- {goose_py-0.11.1.dist-info → goose_py-0.11.3.dist-info}/METADATA +2 -2
- {goose_py-0.11.1.dist-info → goose_py-0.11.3.dist-info}/RECORD +6 -6
- {goose_py-0.11.1.dist-info → goose_py-0.11.3.dist-info}/WHEEL +0 -0
goose/_internal/agent.py
CHANGED
@@ -6,6 +6,7 @@ from aikernel import (
|
|
6
6
|
LLMAssistantMessage,
|
7
7
|
LLMModel,
|
8
8
|
LLMSystemMessage,
|
9
|
+
LLMToolMessage,
|
9
10
|
LLMUserMessage,
|
10
11
|
llm_structured,
|
11
12
|
llm_unstructured,
|
@@ -16,6 +17,8 @@ from goose._internal.result import FindReplaceResponse, Result, TextResult
|
|
16
17
|
from goose._internal.types.telemetry import AgentResponse
|
17
18
|
from goose.errors import Honk
|
18
19
|
|
20
|
+
ExpectedMessage = LLMUserMessage | LLMAssistantMessage | LLMSystemMessage | LLMToolMessage
|
21
|
+
|
19
22
|
|
20
23
|
class IAgentLogger(Protocol):
|
21
24
|
async def __call__(self, *, response: AgentResponse[Any]) -> None: ...
|
@@ -42,12 +45,13 @@ class Agent:
|
|
42
45
|
response_model: type[R] = TextResult,
|
43
46
|
) -> R:
|
44
47
|
start_time = datetime.now()
|
48
|
+
typed_messages: list[ExpectedMessage] = [*messages]
|
45
49
|
|
46
50
|
if response_model is TextResult:
|
47
|
-
response = await llm_unstructured(model=model, messages=
|
51
|
+
response = await llm_unstructured(model=model, messages=typed_messages)
|
48
52
|
parsed_response = response_model.model_validate({"text": response.text})
|
49
53
|
else:
|
50
|
-
response = await llm_structured(model=model, messages=
|
54
|
+
response = await llm_structured(model=model, messages=typed_messages, response_model=response_model)
|
51
55
|
parsed_response = response.structured_response
|
52
56
|
|
53
57
|
end_time = datetime.now()
|
@@ -88,7 +92,8 @@ class Agent:
|
|
88
92
|
task_name: str,
|
89
93
|
) -> str:
|
90
94
|
start_time = datetime.now()
|
91
|
-
|
95
|
+
typed_messages: list[ExpectedMessage] = [*messages]
|
96
|
+
response = await llm_unstructured(model=model, messages=typed_messages)
|
92
97
|
end_time = datetime.now()
|
93
98
|
|
94
99
|
if isinstance(messages[0], LLMSystemMessage):
|
@@ -128,7 +133,10 @@ class Agent:
|
|
128
133
|
response_model: type[R],
|
129
134
|
) -> R:
|
130
135
|
start_time = datetime.now()
|
131
|
-
|
136
|
+
typed_messages: list[ExpectedMessage] = [*messages]
|
137
|
+
find_replace_response = await llm_structured(
|
138
|
+
model=model, messages=typed_messages, response_model=FindReplaceResponse
|
139
|
+
)
|
132
140
|
parsed_find_replace_response = find_replace_response.structured_response
|
133
141
|
end_time = datetime.now()
|
134
142
|
|
goose/_internal/state.py
CHANGED
@@ -2,7 +2,7 @@ import json
|
|
2
2
|
from contextvars import ContextVar
|
3
3
|
from typing import TYPE_CHECKING, Any, NewType, Self
|
4
4
|
|
5
|
-
from aikernel import LLMAssistantMessage, LLMSystemMessage, LLMUserMessage
|
5
|
+
from aikernel import LLMAssistantMessage, LLMMessagePart, LLMSystemMessage, LLMUserMessage
|
6
6
|
from pydantic import BaseModel, ConfigDict
|
7
7
|
|
8
8
|
from goose._internal.agent import Agent, IAgentLogger
|
@@ -46,15 +46,15 @@ class NodeState(BaseModel):
|
|
46
46
|
overwrite: bool = False,
|
47
47
|
) -> Self:
|
48
48
|
if overwrite and len(self.conversation.assistant_messages) > 0:
|
49
|
-
self.conversation.assistant_messages[-1] = LLMAssistantMessage
|
49
|
+
self.conversation.assistant_messages[-1] = LLMAssistantMessage(parts=[LLMMessagePart(content=result)])
|
50
50
|
else:
|
51
|
-
self.conversation.assistant_messages.append(LLMAssistantMessage
|
51
|
+
self.conversation.assistant_messages.append(LLMAssistantMessage(parts=[LLMMessagePart(content=result)]))
|
52
52
|
if new_hash is not None:
|
53
53
|
self.last_hash = new_hash
|
54
54
|
return self
|
55
55
|
|
56
56
|
def add_answer(self, *, answer: str) -> Self:
|
57
|
-
self.conversation.assistant_messages.append(LLMAssistantMessage
|
57
|
+
self.conversation.assistant_messages.append(LLMAssistantMessage(parts=[LLMMessagePart(content=answer)]))
|
58
58
|
return self
|
59
59
|
|
60
60
|
def add_user_message(self, *, message: LLMUserMessage) -> Self:
|
@@ -68,7 +68,9 @@ class NodeState(BaseModel):
|
|
68
68
|
for message_index, message in enumerate(reversed(self.conversation.assistant_messages)):
|
69
69
|
if self.__message_is_result(message):
|
70
70
|
index = len(self.conversation.assistant_messages) - message_index - 1
|
71
|
-
self.conversation.assistant_messages[index] = LLMAssistantMessage
|
71
|
+
self.conversation.assistant_messages[index] = LLMAssistantMessage(
|
72
|
+
parts=[LLMMessagePart(content=result)]
|
73
|
+
)
|
72
74
|
return self
|
73
75
|
|
74
76
|
raise Honk("Node awaiting response, has no result")
|
@@ -5,6 +5,8 @@ from typing import ClassVar, TypedDict
|
|
5
5
|
from aikernel import LiteLLMMessage, LLMModel
|
6
6
|
from pydantic import BaseModel, computed_field
|
7
7
|
|
8
|
+
from goose.errors import Honk
|
9
|
+
|
8
10
|
|
9
11
|
class AgentResponseDump(TypedDict):
|
10
12
|
run_id: str
|
@@ -77,15 +79,18 @@ class AgentResponse[R: BaseModel | str](BaseModel):
|
|
77
79
|
def minimized_dump(self) -> AgentResponseDump:
|
78
80
|
if self.system is None:
|
79
81
|
minimized_system_message = ""
|
82
|
+
elif self.system["role"] == "tool" or not isinstance(self.system["content"], list):
|
83
|
+
raise Honk("System message cannot use tools")
|
80
84
|
else:
|
81
|
-
|
82
|
-
for part in minimized_system_message["content"]:
|
85
|
+
for part in self.system["content"]:
|
83
86
|
if part["type"] == "image_url":
|
84
87
|
part["image_url"] = "__MEDIA__"
|
85
|
-
minimized_system_message = json.dumps(
|
88
|
+
minimized_system_message = json.dumps(self.system)
|
86
89
|
|
87
90
|
minimized_input_messages = [message for message in self.input_messages]
|
88
91
|
for message in minimized_input_messages:
|
92
|
+
if message["role"] == "tool" or not isinstance(message["content"], list):
|
93
|
+
raise Honk("Input messages cannot use tools")
|
89
94
|
for part in message["content"]:
|
90
95
|
if part["type"] == "image_url":
|
91
96
|
part["image_url"] = "__MEDIA__"
|
@@ -1,10 +1,10 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: goose-py
|
3
|
-
Version: 0.11.
|
3
|
+
Version: 0.11.3
|
4
4
|
Summary: A tool for AI workflows based on human-computer collaboration and structured output.
|
5
5
|
Author-email: Nash Taylor <nash@chelle.ai>, Joshua Cook <joshua@chelle.ai>, Michael Sankur <michael@chelle.ai>
|
6
6
|
Requires-Python: >=3.12
|
7
|
-
Requires-Dist: aikernel>=0.1.
|
7
|
+
Requires-Dist: aikernel>=0.1.23
|
8
8
|
Requires-Dist: jsonpath-ng>=1.7.0
|
9
9
|
Requires-Dist: pydantic>=2.8.2
|
10
10
|
Description-Content-Type: text/markdown
|
@@ -4,15 +4,15 @@ goose/flow.py,sha256=YsZLBa5I1W27_P6LYGWbtFX8ZYx9vJG3KtENYChHm5E,111
|
|
4
4
|
goose/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
5
5
|
goose/runs.py,sha256=ub-r_gzbUbaIzWXX-jc-dncNxEh6zTfzIkmnDfCSbRI,160
|
6
6
|
goose/task.py,sha256=95rspdxETJoY12IHBl3KjnVIdqQnf1jDKlnGWNWOTvQ,53
|
7
|
-
goose/_internal/agent.py,sha256=
|
7
|
+
goose/_internal/agent.py,sha256=qDPPsOuvTkUpaKXV5aVTIn_yWUs_XZyHDPJaIq49YAI,8704
|
8
8
|
goose/_internal/conversation.py,sha256=vhJwe1pHk2lV60DaB9Tz9KbpzQo7_thRYInPjbIoUTE,1437
|
9
9
|
goose/_internal/flow.py,sha256=8MJxlhHYSAzUHZefpF_sRJc37o532OF0X7l3KRopDmc,4115
|
10
10
|
goose/_internal/result.py,sha256=vtJMfBxb9skfl8st2tn4hBmEq6qmXiJTme_B5QTgu2M,538
|
11
|
-
goose/_internal/state.py,sha256=
|
11
|
+
goose/_internal/state.py,sha256=kA116MpsetsQz6nYodsXOqE3uYz37OTgjC9Vcy_3Qvg,8065
|
12
12
|
goose/_internal/store.py,sha256=tWmKfa1-yq1jU6lT3l6kSOmVt2m3H7I1xLMTrxnUDI8,889
|
13
13
|
goose/_internal/task.py,sha256=X_eRZxZlf6SwyvF1nIyjoneyqD_TISXqESyxluk63mE,6416
|
14
14
|
goose/_internal/types/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
15
|
-
goose/_internal/types/telemetry.py,sha256=
|
16
|
-
goose_py-0.11.
|
17
|
-
goose_py-0.11.
|
18
|
-
goose_py-0.11.
|
15
|
+
goose/_internal/types/telemetry.py,sha256=xTJCJo-TW9Pd5QK983HMw9CqJ7vw-BLUkYkbantIP30,4075
|
16
|
+
goose_py-0.11.3.dist-info/METADATA,sha256=zY9vHIH5hF1f1TbG3hOrRxSAacd-174unVgzkOQDWiA,443
|
17
|
+
goose_py-0.11.3.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
18
|
+
goose_py-0.11.3.dist-info/RECORD,,
|
File without changes
|