gptscript-ai / gptscript

Build AI assistants that interact with your systems
https://gptscript.ai
Apache License 2.0
2.98k stars 261 forks source link

Support default values for args #350

Open jsutton opened 4 months ago

jsutton commented 4 months ago

Feature Request: Default Values for Tool Arguments in GPTScript

Summary

Add the ability to define default values for tool arguments in GPTScript. This feature will enhance the flexibility and usability of tools by allowing users to specify default values for arguments, reducing the need for repetitive input and simplifying tool usage.

Motivation

Currently, GPTScript requires all tool arguments to be explicitly provided each time a tool is invoked. This can lead to repetitive code and increased potential for errors, especially when certain arguments frequently have the same value. By allowing default values for arguments, we can streamline tool usage and improve the overall developer experience.

Proposal

Introduce a syntax for defining default values for tool arguments in the GPTScript configuration. If an argument is not provided during tool invocation, the default value will be used.

Example

Consider a tool that starts a web server. We can define a default value for the port number as follows:

name: startserver
tools: sys.exec
description: start a web server on a specified port
args:
  port: 
    description: the port number to start the server on
    default: 8080

#!python -m http.server ${port}

In this example, if the port argument is not provided, it defaults to 8080.

csantanapr commented 4 months ago

I like this approach. It would be good to support CEL to do some logic in addition on supporting hardcoded values. for example having different defaults based on other arguments presence or values.

cjellick commented 3 months ago

Thanks for the feature request. Sorry for the delayed response. This makes sense to me. Will dicuss it with @ibuildthecloud