Skip to content

[runtime] Introduce AI model client function API - #4504

Open
haruki-830 wants to merge 1 commit into
apache:masterfrom
haruki-830:feature/community-ai-function-api
Open

[runtime] Introduce AI model client function API#4504
haruki-830 wants to merge 1 commit into
apache:masterfrom
haruki-830:feature/community-ai-function-api

Conversation

@haruki-830

Copy link
Copy Markdown
Contributor

This PR introduces a generic AI model client API and adds support for using AI functions in YAML pipeline jobs:

transform:
  - source-table: db.users
    projection: ID, AI_COMPLETE('chat_model', CONTENT, 'Complete the text') AS COMPLETED

pipeline:
  model:
    - name: chat_model
      type: openai-compatible
      options:
        model-name: your-model
        endpoint: https://example.com/v1
        api-key: your-api-key

The model client is discovered through the common Factory SPI and validated with FactoryHelper. It is created during pipeline translation and follows the open/close lifecycle of the transform operator.

This PR provides the generic model API and runtime integration. The concrete OpenAI-compatible model client will be introduced in a follow-up PR.

The new API is added alongside the existing Model API. No existing model API is removed. Framework changes are limited to the following:

  • Added AiModelClient, ModelContext, AiModelClientFactory, and capability interfaces for text generation and embedding.
  • Added factory-based YAML model definitions using name, type, and options.
  • Kept compatibility with the existing model-name/class-name configuration and legacy model UDF API.
  • Added the generic AI_COMPLETE and AI_EMBED functions.
  • Added validation for constant model arguments, undeclared models, invalid model names, and duplicate declarations.
  • Added a Dummy model for testing, together with YAML parser, Factory, Calcite/Janino, runtime, MiniCluster, and E2E coverage.

Was generative AI tooling used to co-author this PR?
  • Yes (please specify the tool below)

Generated-by: Codex (gpt-5.6-sol)

@haruki-830
haruki-830 force-pushed the feature/community-ai-function-api branch from 5c404eb to 46f6f0c Compare August 12, 2026 02:43
@haruki-830
haruki-830 marked this pull request as ready for review August 12, 2026 02:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant