From d2307402d175338ceab80e29c173d2f7d146b16b Mon Sep 17 00:00:00 2001 From: Collin Dutter Date: Tue, 23 Jul 2024 11:26:15 -0700 Subject: [PATCH] Document accessing Structure output --- docs/griptape-framework/index.md | 29 +++++++---- docs/griptape-framework/structures/agents.md | 49 +++++++++---------- .../structures/pipelines.md | 2 + .../structures/workflows.md | 1 + 4 files changed, 46 insertions(+), 35 deletions(-) diff --git a/docs/griptape-framework/index.md b/docs/griptape-framework/index.md index c31b8942c..b5613b184 100644 --- a/docs/griptape-framework/index.md +++ b/docs/griptape-framework/index.md @@ -111,23 +111,32 @@ agent = Agent( agent.run( "what is 7^12" ) +print("Answer:", agent.output) ``` Here is the chain of thought from the Agent. Notice where it realizes it can use the tool you just injected to do the calculation.[^1] [^1]: In some cases a model might be capable of basic arithmetic. For example, gpt-3.5 returns the correct numeric answer but in an odd format. ``` -[09/08/23 09:53:42] INFO ToolkitTask c87320c5ab1b4988acf25c107b46dffa +[07/23/24 10:47:38] INFO ToolkitTask 6a51060d1fb74e57840a91aa319f26dc Input: what is 7^12 -[09/08/23 09:53:49] INFO Subtask f3f41104a2234a69832c7eacb64e7324 - Thought: The user is asking for the value of 7 raised to the power of 12. I can use the Calculator tool to - perform this calculation. - - Action: {"name": "Calculator", "path": "calculate", "input": {"values": {"expression": - "7**12"}}} - INFO Subtask f3f41104a2234a69832c7eacb64e7324 +[07/23/24 10:47:39] INFO Subtask 0c984616fd2345a7b48a0b0d692daa3c + Actions: [ + { + "tag": "call_RTRm7JLFV0F73dCVPmoWVJqO", + "name": "Calculator", + "path": "calculate", + "input": { + "values": { + "expression": "7**12" + } + } + } + ] + INFO Subtask 0c984616fd2345a7b48a0b0d692daa3c Response: 13841287201 -[09/08/23 09:53:51] INFO ToolkitTask c87320c5ab1b4988acf25c107b46dffa - Output: The value of 7 raised to the power of 12 is 13841287201. +[07/23/24 10:47:40] INFO ToolkitTask 6a51060d1fb74e57840a91aa319f26dc + Output: 13,841,287,201 +Answer: 13,841,287,201 ``` ## Build a Simple Pipeline diff --git a/docs/griptape-framework/structures/agents.md b/docs/griptape-framework/structures/agents.md index 33363198f..8f6a6edb0 100644 --- a/docs/griptape-framework/structures/agents.md +++ b/docs/griptape-framework/structures/agents.md @@ -12,6 +12,8 @@ directly, which the agent uses to dynamically determine whether to use a [Prompt If [tools](../../reference/griptape/structures/agent.md#griptape.structures.agent.Agent.tools) are passed provided to the Agent, a [Toolkit Task](./tasks.md#toolkit-task) will be used. If no [tools](../../reference/griptape/structures/agent.md#griptape.structures.agent.Agent.tools) are provided, a [Prompt Task](./tasks.md#prompt-task) will be used. +You can access the final output of the Agent by using the [output](../../reference/griptape/structures/agent.md#griptape.structures.structure.Structure.output) attribute. + ## Toolkit Task Agent ```python @@ -24,34 +26,31 @@ agent = Agent( tools=[Calculator()] ) -agent.run("what's 123^312?") +agent.run("what's 13^7?") +print("Answer:", agent.output) ``` ``` -[09/08/23 10:11:31] INFO ToolkitTask 319f53af2e564c15a3b97992fc039ec9 - Input: Calculate the following: what's 123^312? -[09/08/23 10:11:55] INFO Subtask cbd5bb8684ad4fc59958201efbf14743 - Thought: The user wants to calculate the value of 123 raised to the power of 312. I can use the Calculator tool - to perform this calculation. - - Action: {"name": "Calculator", "path": "calculate", "input": {"values": {"expression": - "123**312"}}} - INFO Subtask cbd5bb8684ad4fc59958201efbf14743 - Response: - 11230388208945295722090491952733133124202871121067044284403441616854053130045246777417573635449877716182202751456 - 62903768337745814236262209544548389555407097435988334710646912635818793342584092805141253230302226219003560706069 - 42457739968799225811781682901969575983855664495472037997890318771511185547708335412624757899597237206373758262442 - 72269858013479598852506666010704868797813623903160430655651532132073996589276408598241791795573009265505912300559 - 47848517605515539611362917584666826953065776743002119105282582194109888263281423789852046556346579319777145449509 - 5671672325351081760983520684046903739998382099007883142337182654942065184263509761170721 -[09/08/23 10:12:22] INFO ToolkitTask 319f53af2e564c15a3b97992fc039ec9 - Output: The result of 123 raised to the power of 312 is - 11230388208945295722090491952733133124202871121067044284403441616854053130045246777417573635449877716182202751456 - 62903768337745814236262209544548389555407097435988334710646912635818793342584092805141253230302226219003560706069 - 42457739968799225811781682901969575983855664495472037997890318771511185547708335412624757899597237206373758262442 - 72269858013479598852506666010704868797813623903160430655651532132073996589276408598241791795573009265505912300559 - 47848517605515539611362917584666826953065776743002119105282582194109888263281423789852046556346579319777145449509 - 5671672325351081760983520684046903739998382099007883142337182654942065184263509761170721. +[07/23/24 10:53:41] INFO ToolkitTask 487db777bc014193ba90b061451b69a6 + Input: Calculate the following: what's 13^7? +[07/23/24 10:53:42] INFO Subtask 126cefa3ac5347b88495e25af52f3268 + Actions: [ + { + "tag": "call_ZSCH6vNoycOgtPJH2DL2U9ji", + "name": "Calculator", + "path": "calculate", + "input": { + "values": { + "expression": "13**7" + } + } + } + ] + INFO Subtask 126cefa3ac5347b88495e25af52f3268 + Response: 62748517 +[07/23/24 10:53:43] INFO ToolkitTask 487db777bc014193ba90b061451b69a6 + Output: 62,748,517 +Answer: 62,748,517 ``` ## Prompt Task Agent diff --git a/docs/griptape-framework/structures/pipelines.md b/docs/griptape-framework/structures/pipelines.md index 4753ad52d..ad652f6c0 100644 --- a/docs/griptape-framework/structures/pipelines.md +++ b/docs/griptape-framework/structures/pipelines.md @@ -6,6 +6,8 @@ search: ## Overview A [Pipeline](../../reference/griptape/structures/pipeline.md) is very similar to an [Agent](../../reference/griptape/structures/agent.md), but allows for multiple tasks. +You can access the final output of the Pipeline by using the [output](../../reference/griptape/structures/agent.md#griptape.structures.structure.Structure.output) attribute. + ## Context Pipelines have access to the following [context](../../reference/griptape/structures/pipeline.md#griptape.structures.pipeline.Pipeline.context) variables in addition to the [base context](./tasks.md#context). diff --git a/docs/griptape-framework/structures/workflows.md b/docs/griptape-framework/structures/workflows.md index 55014796e..75511171f 100644 --- a/docs/griptape-framework/structures/workflows.md +++ b/docs/griptape-framework/structures/workflows.md @@ -7,6 +7,7 @@ search: A [Workflow](../../reference/griptape/structures/workflow.md) is a non-sequential DAG that can be used for complex concurrent scenarios with tasks having multiple inputs. +You can access the final output of the Workflow by using the [output](../../reference/griptape/structures/agent.md#griptape.structures.structure.Structure.output) attribute. ## Context