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

Passing Function Call Schemas as Variables in OpenAI Function Configurations #2266

Open
sidharthramesh opened this issue Nov 29, 2024 · 0 comments · May be fixed by #2403
Open

Passing Function Call Schemas as Variables in OpenAI Function Configurations #2266

sidharthramesh opened this issue Nov 29, 2024 · 0 comments · May be fixed by #2403

Comments

@sidharthramesh
Copy link

Is your feature request related to a problem? Please describe.
Currently, function call schemas cannot be passed dynamically as variables when configuring OpenAI function calls. This limitation makes it difficult to reuse or dynamically generate schemas in a clean and modular manner. For example, attempting to define a schema in a vars block and reference it in a function configuration results in an output of "parameters":{"[object Object]":null} instead of the expected schema.

This behavior is frustrating as it reduces flexibility and increases redundancy in defining schemas, particularly for use cases where schemas might need to be generated or reused across multiple tools or scenarios.


Describe the solution you'd like
I would like the ability to pass schemas as variables in function call configurations. For instance, the following configuration should work as expected:

providers:
  - id: openai:chat:gpt-4o-audio-preview
    config:
      tools: [
        {
          "type": "function",
          "function": {
            "name": "transcribe_audio",
            "description": "Transcribe the audio",
            "parameters": {{ schema | dump | safe }}
          }
        }
      ]
      tool_choice: 'auto'

tests:
  - vars:
      schema: {
        "type": "object",
        "properties": {
          "transcription": {
            "type": "string",
            "description": "The transcription of the audio"
          }
        },
        "required": ["transcription"]
      }

The schema variable should correctly resolve and be passed into the parameters field without breaking.


Describe alternatives you’ve considered

  1. Hardcoding schemas directly into function configurations: While this works, it results in code duplication and makes schema management cumbersome, especially for large projects with multiple tools or similar schema structures.
  2. Preprocessing the configuration: Writing custom scripts to inject schemas before runtime, but this adds unnecessary complexity and reduces the maintainability of configurations.

Neither of these alternatives is as clean or efficient as supporting schema variables natively.


Additional context
Here’s an example of the error observed when attempting to pass a schema variable:

"parameters": {
  "[object Object]": null
}

Allowing schemas to be passed as variables would enable dynamic and modular schema configurations, improving development workflows and reducing redundancy. This feature would be particularly useful for scenarios requiring reusable or dynamically generated function call schemas.

Thank you for considering this feature! Let me know if further clarification or examples are needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant