Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document accessing Structure output #1010

Merged
merged 1 commit into from
Jul 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 19 additions & 10 deletions docs/griptape-framework/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
49 changes: 24 additions & 25 deletions docs/griptape-framework/structures/agents.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 2 additions & 0 deletions docs/griptape-framework/structures/pipelines.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
1 change: 1 addition & 0 deletions docs/griptape-framework/structures/workflows.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Loading