griptape icon indicating copy to clipboard operation
griptape copied to clipboard

Unable to complete the following prompt

Open hyusetiawan opened this issue 1 year ago • 2 comments

Describe the bug Unable to complete a prompt that I thought would be simple to complete, the example prompts are:

  • how many days until Sept 23rd?
  • what is the date 3 days from today? Here's an example log of the output:
Q: how many days until Sept 23rd?
processing...
[09/18/23 04:26:11] INFO     ToolkitTask 7e2af4d35e944089a8f6c47f21f222ee
                             Input: how many days until Sept 23rd?
[09/18/23 04:26:13] INFO     Subtask 72391817347e4b88a85b82f345770137
                             Thought: I can use the DateTime tool to get the current date and time, and then use the Calculator tool to calculate the difference between the two dates.
                             Action: {"type":"tool","name":"DateTime","activity":"get_current_datetime"}
                    INFO     Subtask 72391817347e4b88a85b82f345770137
                             Observation: 2023-09-18 04:26:13.997353
[09/18/23 04:26:16] INFO     Subtask 1121b303ef924961a5fac6a8755f1c72
                             Assistant: Thought: I can use the Calculator tool to calculate the difference between the current date and Sept 23rd.
                             Action: {"type": "tool", "name": "Calculator", "activity": "calculate", "input": {"values": {"expression": "datetime.datetime(2023, 9, 23) - datetime.datetime(2023, 9, 18)"}}}

                             User:
                    INFO     Subtask 1121b303ef924961a5fac6a8755f1c72
                             Observation: name 'datetime' is not defined
[09/18/23 04:26:19] INFO     Subtask 48557b0de8e44fdeba0b90d0ac751f26
                             Assistant: Thought: I need to use the Computer tool to execute the code to get the difference between the two dates.
                             Action: {"type": "tool", "name": "Computer", "activity": "execute_code", "input": {"values": {"code": "import datetime\ndatetime.datetime(2023, 9, 23) - datetime.datetime(2023, 9, 18)", "filename": "difference.py"}}}

                             User:
                    INFO     Subtask 48557b0de8e44fdeba0b90d0ac751f26
                             Observation: Output of "Computer.execute_code" was stored in memory with memory_name "TextToolMemory" and artifact_namespace "7dd313205b8f4e4cb88477395e9d278f"
[09/18/23 04:26:22] INFO     ToolkitTask 7e2af4d35e944089a8f6c47f21f222ee
                             Output: Assistant: Action: {"type": "memory", "name": "TextToolMemory", "activity": "search", "input": {"values": {"memory_name": "TextToolMemory", "artifact_namespace": "7dd313205b8f4e4cb88477395e9d278f", "query":
                             "What is the output of the code?"}}}

                             User:
A: Assistant: Action: {"type": "memory", "name": "TextToolMemory", "activity": "search", "input": {"values": {"memory_name": "TextToolMemory", "artifact_namespace": "7dd313205b8f4e4cb88477395e9d278f", "query": "What is the output of the code?"}}}

User:
Q:

To Reproduce Steps to reproduce the behavior: Using the following setup:

  agent = Agent(
            tools=[Calculator(), DateTime(), Computer()],
            prompt_driver=OpenAiCompletionPromptDriver(model="text-davinci-003"),
            memory=LocalConversationMemoryDriver(file_path="./convo.json").load(),
        )
        Chat(agent).start()

Expected behavior returns the result

Desktop (please complete the following information):

  • macos latest

hyusetiawan avatar Sep 18 '23 04:09 hyusetiawan

highjacking my own thread for a bit, I also have errors for simple arithmetic inputs as shown below:

Q: 3 + 10 - 6
processing...
[09/18/23 05:35:22] INFO     ToolkitTask fbd5ad454fd0412e952e7b65fde7d00b
                             Input: 3 + 10 - 6
[09/18/23 05:35:25] ERROR    Subtask fbd5ad454fd0412e952e7b65fde7d00b
                             Invalid activity input JSON: 'values' is a required property

                             Failed validating 'required' in schema:
                                 {'$id': 'InputSchema',
                                  '$schema': 'http://json-schema.org/draft-07/schema#',
                                  'additionalProperties': False,
                                  'properties': {'values': {'additionalProperties': False,
                                                            'properties': {'expression': {'description': 'Arithmetic '
                                                                                                         'expression '
                                                                                                         'parsable '
                                                                                                         'in '
                                                                                                         'pure '
                                                                                                         'Python. '
                                                                                                         'Single '
                                                                                                         'line '
                                                                                                         'only. '
                                                                                                         "Don't "
                                                                                                         'use '
                                                                                                         'any '
                                                                                                         'imports '
                                                                                                         'or '
                                                                                                         'external '
                                                                                                         'libraries',
                                                                                          'type': 'string'}},
                                                            'required': ['expression'],
                                                            'type': 'object'}},
                                  'required': ['values'],
                                  'type': 'object'}

                             On instance:
                                 {'expression': '3 + 10 - 6'}
INFO     Subtask e03e564cc07e40abbbab850525d9f979
                             Thought: I can use the Calculator tool to calculate the expression "3 + 10 - 6".

                             Action:
                             {
                               "type": "tool",
                               "name": "Calculator",
                               "activity": "calculate",
                               "input": {
                                 "expression": "3 + 10 - 6"
                               }
                             }
                    INFO     Subtask e03e564cc07e40abbbab850525d9f979
                             Observation: {'error': 'Activity input JSON validation error: \'values\' is a required property\n\nFailed validating \'required\' in schema:\n    {\'$id\': \'InputSchema\',\n     \'$schema\':
                             \'http://json-schema.org/draft-07/schema#\',\n     \'additionalProperties\': False,\n     \'properties\': {\'values\': {\'additionalProperties\': False,\n                               \'properties\':
                             {\'expression\': {\'description\': \'Arithmetic \'\n                                                                            \'expression \'\n
                             \'parsable \'\n                                                                            \'in \'\n                                                                            \'pure \'\n
                             \'Python. \'\n                                                                            \'Single \'\n                                                                            \'line \'\n
                             \'only. \'\n                                                                            "Don\'t "\n                                                                            \'use \'\n
                             \'any \'\n                                                                            \'imports \'\n                                                                            \'or \'\n
                             \'external \'\n                                                                            \'libraries\',\n                                                             \'type\': \'string\'}},\n
                             \'required\': [\'expression\'],\n                               \'type\': \'object\'}},\n     \'required\': [\'values\'],\n     \'type\': \'object\'}\n\nOn instance:\n    {\'expression\': \'3 + 10 - 6\'}'}
[09/18/23 05:35:28] INFO     Subtask 8f7a9b446f1b426a88c489773f8fa53b
                             Thought: It seems like I made a mistake in the action input. I need to provide the expression inside the "values" object.
                             Action: {"type": "tool", "name": "Calculator", "activity": "calculate", "input": {"values": {"expression": "3 + 10 - 6"}}}
                    INFO     Subtask 8f7a9b446f1b426a88c489773f8fa53b
                             Observation: 7
[09/18/23 05:35:29] INFO     ToolkitTask fbd5ad454fd0412e952e7b65fde7d00b
                             Output: The result of the expression "3 + 10 - 6" is 7.
A: The result of the expression "3 + 10 - 6" is 7.

It will eventually finish but the errors seem to be consistent

hyusetiawan avatar Sep 18 '23 05:09 hyusetiawan

Hey @hyusetiawan!

Once this PR goes in, this should work:

from griptape.structures import Agent
from griptape.tools import DateTime
from griptape.drivers import OpenAiCompletionPromptDriver

agent = Agent(
    tools=[DateTime()],
    prompt_driver=OpenAiCompletionPromptDriver(model="text-davinci-003"),
)
agent.run("what is the date 3 days from today?")
[09/20/23 17:18:01] INFO     ToolkitTask da71c6cc22034d0f8abed2c632fbb1aa
                             Input: what is the date 3 days from today?
[09/20/23 17:18:03] INFO     Subtask 3ae8b048367b47c7b5f628114441b8ce
                             Thought: I can use the DateTime tool to get the current date and time, then use the DateTime tool to get the
                             relative date and time.
                             Action: {"type":"tool","name":"DateTime","activity":"get_current_datetime"}
                    INFO     Subtask 3ae8b048367b47c7b5f628114441b8ce
                             Observation: 2023-09-20 17:18:03.601120
[09/20/23 17:18:05] INFO     Subtask ce41cc90361a469fa90e0cc1f4ac7bed
                             Assistant: Thought: I can use the DateTime tool to get the relative date and time.
                             Action: {"type": "tool", "name": "DateTime", "activity": "get_relative_datetime", "input": {"values":
                             {"relative_date_string": "in 3 days"}}}

                             User:
                    INFO     Subtask ce41cc90361a469fa90e0cc1f4ac7bed
                             Observation: 2023-09-23 17:18:05.171933
                    INFO     ToolkitTask da71c6cc22034d0f8abed2c632fbb1aa
                             Output: Assistant: Answer: The date 3 days from today is 2023-09-23 17:18:05.171933.

The question "how many days until Sept 23rd?" is a little different because the answer is expected to be an number, not a date. I've got a working prototype of this, I'll create a PR for it tomorrow.

collindutter avatar Sep 21 '23 00:09 collindutter

Closing, this appears to be resolved today:

from griptape.structures import Agent
from griptape.tools import DateTime

agent = Agent(
    tools=[DateTime()],
)
agent.run("what is the date 3 days from today?")
agent.run("how many days until Sept 23rd?")
[08/08/24 13:01:58] INFO     ToolkitTask 65fefc956d8545e98796963e594f0273
                             Input: what is the date 3 days from today?
[08/08/24 13:01:59] INFO     Subtask 960ba3fa4956429aaf3740532b723f22
                             Actions: [
                               {
                                 "tag": "call_DjpwGLkeM3uFiVFe7HziPakY",
                                 "name": "DateTime",
                                 "path": "get_current_datetime",
                                 "input": {
                                   "values": {}
                                 }
                               }
                             ]
                    INFO     Subtask 960ba3fa4956429aaf3740532b723f22
                             Response: 2024-08-08 13:01:59.698669
[08/08/24 13:02:00] INFO     Subtask 038b1d580b3548f28eddffed1d8a4345
                             Actions: [
                               {
                                 "tag": "call_2uFfhL8D9hjaDY4YabCZBxyV",
                                 "name": "DateTime",
                                 "path": "get_relative_datetime",
                                 "input": {
                                   "values": {
                                     "relative_date_string": "in 3 days"
                                   }
                                 }
                               }
                             ]
                    INFO     Subtask 038b1d580b3548f28eddffed1d8a4345
                             Response: 2024-08-11 13:02:00.359099
[08/08/24 13:02:01] INFO     ToolkitTask 65fefc956d8545e98796963e594f0273
                             Output: The date 3 days from today is August 11, 2024.
                    INFO     ToolkitTask 65fefc956d8545e98796963e594f0273
                             Input: how many days until Sept 23rd?
                    INFO     Subtask 2cf61b8d7407450da8bb41fa9442f3fb
                             Actions: [
                               {
                                 "tag": "call_JyVCbQHYqJlBadOT5Fg8y4oU",
                                 "name": "DateTime",
                                 "path": "get_current_datetime",
                                 "input": {
                                   "values": {}
                                 }
                               }
                             ]
                    INFO     Subtask 2cf61b8d7407450da8bb41fa9442f3fb
                             Response: 2024-08-08 13:02:01.989108
[08/08/24 13:02:02] INFO     Subtask 137a20e6bc4a4594bcbceedc55c07d84
                             Actions: [
                               {
                                 "tag": "call_Aq2B0uRWXcvK1yfgjBiXsueV",
                                 "name": "DateTime",
                                 "path": "get_relative_datetime",
                                 "input": {
                                   "values": {
                                     "relative_date_string": "September 23, 2024"
                                   }
                                 }
                               }
                             ]
                    INFO     Subtask 137a20e6bc4a4594bcbceedc55c07d84
                             Response: 2024-09-23 00:00:00
[08/08/24 13:02:03] INFO     ToolkitTask 65fefc956d8545e98796963e594f0273
                             Output: There are 46 days until September 23, 2024.

collindutter avatar Aug 08 '24 20:08 collindutter