Skip to content

[FLINK-37799][model][docs] Add document for OpenAI Model Function #26671

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

yunfengzhou-hub
Copy link
Contributor

What is the purpose of the change

This PR is a continuation to #26652, adding document for the introduced OpenAI Model Function.

Brief change log

  • Adds document for the OpenAI Model Function.

Verifying this change

This change is a trivial rework / code cleanup without any test coverage.

Does this pull request potentially affect one of the following parts:

  • Dependencies (does it add or upgrade a dependency): no
  • The public API, i.e., is any changed class annotated with @Public(Evolving): no
  • The serializers: no
  • The runtime per-record code paths (performance sensitive): no
  • Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Kubernetes/Yarn, ZooKeeper: no
  • The S3 file system connector: no

Documentation

  • Does this pull request introduce a new feature? yes
  • If yes, how is the feature documented? docs

@yunfengzhou-hub yunfengzhou-hub marked this pull request as ready for review June 12, 2025 07:06
@flinkbot
Copy link
Collaborator

flinkbot commented Jun 12, 2025

CI report:

Bot commands The @flinkbot bot supports the following commands:
  • @flinkbot run azure re-run the last Azure build


# OpenAI

The OpenAI Model Function allows Flink SQL to call OpenAI API for inference tasks.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest a link to the OpenAI javadoc on the words OpenAI API

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the comment! I've add the link.

@yunfengzhou-hub
Copy link
Contributor Author

Hi @fsk119 @lihaosky could you please help review this PR?


The function supports calling remote OpenAI model services via Flink SQL for prediction/inference tasks. Currently, the following tasks are supported:

* chat completions
Copy link
Contributor

@davidradl davidradl Jun 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there needs to be more information about these 2 tasks, and why we are restricted to these tasks?
It would be good to include links to what these mean,
https://platform.openai.com/docs/api-reference/chat
https://platform.openai.com/docs/api-reference/embeddings


## Usage examples

The following example creates a chat completions model and use it to predict sentiment labels for movie reviews.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: use -> uses

WITH (
'provider'='openai',
'endpoint'='https://api.openai.com/v1/chat/completions',
'api-key' = '<YOUR KEY>',
Copy link
Contributor

@davidradl davidradl Jun 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest we define <YOUR KEY>.

<td>required</td>
<td style="word-wrap: break-word;">(none)</td>
<td>String</td>
<td>Full URL of the OpenAI API endpoint, e.g., <code>https://api.openai.com/v1/chat/completions</code> or
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: e.g., -> e.g.

</tbody>
</table>

### chat/completions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

chat/completions is different to chat completions that we mentioned earlier as a task. I suggest being consistent.

<td>optional</td>
<td style="word-wrap: break-word;">"You are a helpful assistant."</td>
<td>String</td>
<td>System message for chat tasks.</td>
Copy link
Contributor

@davidradl davidradl Jun 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be useful to point into the OpenAI docs as to what this and the other parameters mean. I notice we use the phrase system-prompt an System message, I suggest we define one and point to it an only use one way to refer to this. When we say system here - do we mean system role?

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 this pull request may close these issues.

3 participants