goose-py 0.9.11__tar.gz → 0.9.12__tar.gz

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.
Files changed (37) hide show
  1. {goose_py-0.9.11 → goose_py-0.9.12}/PKG-INFO +1 -1
  2. {goose_py-0.9.11 → goose_py-0.9.12}/goose/_internal/task.py +3 -0
  3. {goose_py-0.9.11 → goose_py-0.9.12}/goose/_internal/types/agent.py +6 -6
  4. {goose_py-0.9.11 → goose_py-0.9.12}/pyproject.toml +1 -1
  5. {goose_py-0.9.11 → goose_py-0.9.12}/tests/test_refining.py +12 -0
  6. {goose_py-0.9.11 → goose_py-0.9.12}/uv.lock +1 -1
  7. goose_py-0.9.11/tests/test_flows/__init__.py +0 -0
  8. goose_py-0.9.11/tests/test_flows/test_meal_plan.py +0 -135
  9. {goose_py-0.9.11 → goose_py-0.9.12}/.envrc +0 -0
  10. {goose_py-0.9.11 → goose_py-0.9.12}/.github/workflows/publish.yml +0 -0
  11. {goose_py-0.9.11 → goose_py-0.9.12}/.gitignore +0 -0
  12. {goose_py-0.9.11 → goose_py-0.9.12}/.python-version +0 -0
  13. {goose_py-0.9.11 → goose_py-0.9.12}/.stubs/jsonpath_ng/__init__.pyi +0 -0
  14. {goose_py-0.9.11 → goose_py-0.9.12}/.stubs/litellm/__init__.pyi +0 -0
  15. {goose_py-0.9.11 → goose_py-0.9.12}/Makefile +0 -0
  16. {goose_py-0.9.11 → goose_py-0.9.12}/README.md +0 -0
  17. {goose_py-0.9.11 → goose_py-0.9.12}/goose/__init__.py +0 -0
  18. {goose_py-0.9.11 → goose_py-0.9.12}/goose/_internal/agent.py +0 -0
  19. {goose_py-0.9.11 → goose_py-0.9.12}/goose/_internal/conversation.py +0 -0
  20. {goose_py-0.9.11 → goose_py-0.9.12}/goose/_internal/flow.py +0 -0
  21. {goose_py-0.9.11 → goose_py-0.9.12}/goose/_internal/result.py +0 -0
  22. {goose_py-0.9.11 → goose_py-0.9.12}/goose/_internal/state.py +0 -0
  23. {goose_py-0.9.11 → goose_py-0.9.12}/goose/_internal/store.py +0 -0
  24. {goose_py-0.9.11 → goose_py-0.9.12}/goose/_internal/types/__init__.py +0 -0
  25. {goose_py-0.9.11 → goose_py-0.9.12}/goose/agent.py +0 -0
  26. {goose_py-0.9.11 → goose_py-0.9.12}/goose/errors.py +0 -0
  27. {goose_py-0.9.11 → goose_py-0.9.12}/goose/flow.py +0 -0
  28. {goose_py-0.9.11 → goose_py-0.9.12}/goose/py.typed +0 -0
  29. {goose_py-0.9.11 → goose_py-0.9.12}/goose/runs.py +0 -0
  30. {goose_py-0.9.11 → goose_py-0.9.12}/goose/task.py +0 -0
  31. {goose_py-0.9.11 → goose_py-0.9.12}/tests/__init__.py +0 -0
  32. {goose_py-0.9.11 → goose_py-0.9.12}/tests/test_agent.py +0 -0
  33. {goose_py-0.9.11 → goose_py-0.9.12}/tests/test_downstream_task.py +0 -0
  34. {goose_py-0.9.11 → goose_py-0.9.12}/tests/test_hashing.py +0 -0
  35. {goose_py-0.9.11 → goose_py-0.9.12}/tests/test_looping.py +0 -0
  36. {goose_py-0.9.11 → goose_py-0.9.12}/tests/test_regenerate.py +0 -0
  37. {goose_py-0.9.11 → goose_py-0.9.12}/tests/test_state.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: goose-py
3
- Version: 0.9.11
3
+ Version: 0.9.12
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
@@ -56,6 +56,9 @@ class Task[**P, R: Result]:
56
56
  flow_run = self.__get_current_flow_run()
57
57
  node_state = flow_run.get(task=self, index=index)
58
58
 
59
+ if len(node_state.conversation.result_messages) == 0:
60
+ raise Honk("Cannot refine a task that has not been initially generated")
61
+
59
62
  if context is not None:
60
63
  node_state.set_context(context=context)
61
64
  node_state.add_user_message(message=user_message)
@@ -18,14 +18,14 @@ class Base64MediaContent(str):
18
18
 
19
19
  class AIModel(StrEnum):
20
20
  # vertex (production Google, requires GCP environment)
21
- VERTEX_PRO = "vertex_ai/gemini-2.0-pro"
22
- VERTEX_FLASH = "vertex_ai/gemini-2.0-flash"
23
- VERTEX_FLASH_8B = "vertex_ai/gemini-2.0-flash-8b"
21
+ VERTEX_PRO = "vertex_ai/gemini-1.5-pro"
22
+ VERTEX_FLASH = "vertex_ai/gemini-1.5-flash"
23
+ VERTEX_FLASH_8B = "vertex_ai/gemini-1.5-flash-8b"
24
24
 
25
25
  # gemini (publicly available, no GCP environment required)
26
- GEMINI_PRO = "gemini/gemini-2.0-pro"
27
- GEMINI_FLASH = "gemini/gemini-2.0-flash"
28
- GEMINI_FLASH_8B = "gemini/gemini-2.0-flash-8b"
26
+ GEMINI_PRO = "gemini/gemini-1.5-pro"
27
+ GEMINI_FLASH = "gemini/gemini-1.5-flash"
28
+ GEMINI_FLASH_8B = "gemini/gemini-1.5-flash-8b"
29
29
 
30
30
 
31
31
  class UserMediaContentType(StrEnum):
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "goose-py"
3
- version = "0.9.11"
3
+ version = "0.9.12"
4
4
  description = "A tool for AI workflows based on human-computer collaboration and structured output."
5
5
  readme = "README.md"
6
6
  authors = [
@@ -7,6 +7,7 @@ from pytest_mock import MockerFixture
7
7
 
8
8
  from goose import Agent, FlowArguments, Result, flow, task
9
9
  from goose.agent import SystemMessage, TextMessagePart, UserMessage
10
+ from goose.errors import Honk
10
11
 
11
12
 
12
13
  class MyFlowArguments(FlowArguments):
@@ -67,3 +68,14 @@ async def test_refining() -> None:
67
68
  assert random_words[0].result.word == "__ADAPTED__" # adapted
68
69
  assert random_words[1].result.word != "__ADAPTED__" # not adapted
69
70
  assert random_words[2].result.word != "__ADAPTED__" # not adapted
71
+
72
+
73
+ @pytest.mark.asyncio
74
+ @pytest.mark.usefixtures("generate_random_word_adapter")
75
+ async def test_refining_before_generate_fails() -> None:
76
+ with pytest.raises(Honk):
77
+ async with sentence.start_run(run_id="2"):
78
+ await generate_random_word.refine(
79
+ user_message=UserMessage(parts=[TextMessagePart(text="Change it")]),
80
+ context=SystemMessage(parts=[TextMessagePart(text="Extra info")]),
81
+ )
@@ -234,7 +234,7 @@ wheels = [
234
234
 
235
235
  [[package]]
236
236
  name = "goose-py"
237
- version = "0.9.11"
237
+ version = "0.9.12"
238
238
  source = { editable = "." }
239
239
  dependencies = [
240
240
  { name = "jsonpath-ng" },
File without changes
@@ -1,135 +0,0 @@
1
- """
2
- This example demonstrates how to use Goose to plan a meal.
3
-
4
- Meal planning is a good use case because it demonstrates the need for tasks to depend on the outputs of other tasks.
5
- You have your initial flow input, which is your overall health goals, and that's the starting point for breakfast.
6
- But then lunch is a function of both your goals and your breakfast.
7
- And then dinner is a function of your goals, your breakfast, and your lunch.
8
- """
9
-
10
- import pytest
11
-
12
- from goose import Agent, FlowArguments, Result, flow, task
13
- from goose.agent import AIModel, SystemMessage, TextMessagePart, UserMessage
14
-
15
-
16
- class HealthGoals(FlowArguments):
17
- goals: list[str]
18
-
19
-
20
- class Meal(Result):
21
- dish_name: str
22
- ingredients: list[str]
23
- reason: str
24
-
25
-
26
- @task
27
- async def plan_breakfast(*, goals: list[str], agent: Agent) -> Meal:
28
- formatted_goals = "\n".join(f"- {goal}" for goal in goals)
29
- suggested_meal = await agent(
30
- messages=[
31
- UserMessage(
32
- parts=[
33
- TextMessagePart(
34
- text=f"What should I make for breakfast? Here are my health goals:\n{formatted_goals}"
35
- )
36
- ]
37
- ),
38
- ],
39
- system=SystemMessage(
40
- parts=[
41
- TextMessagePart(
42
- text=(
43
- "You are a helpful assistant that helps plan breakfasts based on health goals. "
44
- "Explain why you built the meal you did."
45
- )
46
- )
47
- ]
48
- ),
49
- response_model=Meal,
50
- model=AIModel.GEMINI_FLASH,
51
- task_name="breakfast",
52
- )
53
- return suggested_meal
54
-
55
-
56
- @task
57
- async def plan_lunch(*, goals: list[str], breakfast: Meal, agent: Agent) -> Meal:
58
- formatted_goals = "\n".join(f"- {goal}" for goal in goals)
59
- formatted_breakfast = f"Breakfast: {breakfast.dish_name} ({', '.join(breakfast.ingredients)})"
60
- suggested_meal = await agent(
61
- messages=[
62
- UserMessage(
63
- parts=[
64
- TextMessagePart(text=f"What should I make for lunch? Here are my health goals:\n{formatted_goals}"),
65
- TextMessagePart(text=f"Here was my breakfast:\n{formatted_breakfast}"),
66
- ]
67
- ),
68
- ],
69
- system=SystemMessage(
70
- parts=[
71
- TextMessagePart(
72
- text=(
73
- "You are a helpful assistant that helps plan lunches based on health goals. "
74
- "Consider the breakfast you had when planning your lunch. Explain why you built the meal you did."
75
- ),
76
- )
77
- ]
78
- ),
79
- response_model=Meal,
80
- model=AIModel.GEMINI_FLASH,
81
- task_name="lunch",
82
- )
83
- return suggested_meal
84
-
85
-
86
- @task
87
- async def plan_dinner(*, goals: list[str], lunch: Meal, breakfast: Meal, agent: Agent) -> Meal:
88
- formatted_goals = "\n".join(f"- {goal}" for goal in goals)
89
- formatted_breakfast = f"Breakfast: {breakfast.dish_name} ({', '.join(breakfast.ingredients)})"
90
- formatted_lunch = f"Lunch: {lunch.dish_name} ({', '.join(lunch.ingredients)})"
91
- suggested_meal = await agent(
92
- messages=[
93
- UserMessage(
94
- parts=[
95
- TextMessagePart(
96
- text=f"What should I make for dinner? Here are my health goals:\n{formatted_goals}"
97
- ),
98
- TextMessagePart(text=f"Here was my breakfast:\n{formatted_breakfast}"),
99
- TextMessagePart(text=f"Here was my lunch:\n{formatted_lunch}"),
100
- ]
101
- ),
102
- ],
103
- system=SystemMessage(
104
- parts=[
105
- TextMessagePart(
106
- text=(
107
- "You are a helpful assistant that helps plan dinners based on health goals. "
108
- "Consider the breakfast and lunch you had when planning your dinner. "
109
- "Explain why you built the meal you did."
110
- ),
111
- )
112
- ]
113
- ),
114
- response_model=Meal,
115
- model=AIModel.GEMINI_FLASH,
116
- task_name="dinner",
117
- )
118
- return suggested_meal
119
-
120
-
121
- @flow
122
- async def meal_plan(*, flow_arguments: HealthGoals, agent: Agent) -> None:
123
- breakfast = await plan_breakfast(goals=flow_arguments.goals, agent=agent)
124
- lunch = await plan_lunch(goals=flow_arguments.goals, breakfast=breakfast, agent=agent)
125
- await plan_dinner(goals=flow_arguments.goals, lunch=lunch, breakfast=breakfast, agent=agent)
126
-
127
-
128
- @pytest.mark.asyncio
129
- async def test_meal_plan_flow() -> None:
130
- health_goals = HealthGoals(goals=["lose weight", "have more energy"])
131
- async with meal_plan.start_run(run_id="my-meal-plan") as run:
132
- await meal_plan.generate(health_goals)
133
-
134
- dinner = run.get(task=plan_dinner).result
135
- assert isinstance(dinner.reason, str)
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes