You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "qining-mj (via GitHub)" <gi...@apache.org> on 2025/08/13 15:59:37 UTC

[PR] [model] Support Deepseek Function [flink]

qining-mj opened a new pull request, #26901:
URL: https://github.com/apache/flink/pull/26901

   <!--
   *Thank you very much for contributing to Apache Flink - we are happy that you want to help us improve Flink. To help the community review your contribution in the best possible way, please go through the checklist below, which will get the contribution into a shape in which it can be best reviewed.*
   
   *Please understand that we do not do this to make contributions to Flink a hassle. In order to uphold a high standard of quality for code contributions, while at the same time managing a large number of contributions, we need contributors to prepare the contributions well, and give reviewers enough contextual information for the review. Please also understand that contributions that do not follow this guide will take longer to review and thus typically be picked up with lower priority by the community.*
   
   ## Contribution Checklist
   
     - Make sure that the pull request corresponds to a [JIRA issue](https://issues.apache.org/jira/projects/FLINK/issues). Exceptions are made for typos in JavaDoc or documentation files, which need no JIRA issue.
     
     - Name the pull request in the form "[FLINK-XXXX] [component] Title of the pull request", where *FLINK-XXXX* should be replaced by the actual issue number. Skip *component* if you are unsure about which is the best component.
     Typo fixes that have no associated JIRA issue should be named following this pattern: `[hotfix] [docs] Fix typo in event time introduction` or `[hotfix] [javadocs] Expand JavaDoc for PuncuatedWatermarkGenerator`.
   
     - Fill out the template below to describe the changes contributed by the pull request. That will give reviewers the context they need to do the review.
     
     - Make sure that the change passes the automated tests, i.e., `mvn clean verify` passes. You can set up Azure Pipelines CI to do that following [this guide](https://cwiki.apache.org/confluence/display/FLINK/Azure+Pipelines#AzurePipelines-Tutorial:SettingupAzurePipelinesforaforkoftheFlinkrepository).
   
     - Each pull request should address only one issue, not mix up code from multiple issues.
     
     - Each commit in the pull request has a meaningful commit message (including the JIRA id)
   
     - Once all items of the checklist are addressed, remove the above text and this checklist, leaving only the filled out template below.
   
   
   **(The sections below can be removed for hotfixes of typos)**
   -->
   
   ## What is the purpose of the change
   
   This PR adds an implementation to Flink's Model API. This implementation achieves prediction and inference by invoking DeepSeek APIs based on its okhttp3.
   
   
   ## Brief change log
   
   Adds Model Functions based on DeepSeek API.
   
   
   ## Verifying this change
   
   The changes introduced in this PR is verified by test cases introduced in flink-models/flink-model-deepseek.
   
   ## 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: yes
   
   ## Documentation
   
   Does this pull request introduce a new feature? yes
   If yes, how is the feature documented? docs


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [model] Support Deepseek Function [flink]

Posted by "davidradl (via GitHub)" <gi...@apache.org>.
davidradl commented on code in PR #26901:
URL: https://github.com/apache/flink/pull/26901#discussion_r2275818958


##########
docs/content/docs/connectors/models/deepseek.md:
##########
@@ -0,0 +1,56 @@
+---
+title: "OpenAI"
+weight: 1
+type: docs
+---
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+  http://www.apache.org/licenses/LICENSE-2.0
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+# DeepSeek
+
+The DeepSeek Model Function allows Flink SQL to call [DeepSeek API](https://www.deepseek.com/) for inference tasks.

Review Comment:
   I think we should include a link to the terms of use [https://cdn.deepseek.com/policies/en-US/deepseek-terms-of-use.html](https://cdn.deepseek.com/policies/en-US/deepseek-terms-of-use.html ). 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [model] Support Deepseek Function [flink]

Posted by "davidradl (via GitHub)" <gi...@apache.org>.
davidradl commented on code in PR #26901:
URL: https://github.com/apache/flink/pull/26901#discussion_r2275895852


##########
flink-models/flink-model-deepseek/src/main/java/org/apache/flink/model/deepseek/DeepSeekUtils.java:
##########
@@ -0,0 +1,107 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.model.deepseek;
+
+import org.apache.flink.util.Preconditions;
+
+import okhttp3.OkHttpClient;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.time.Duration;
+import java.util.concurrent.atomic.AtomicInteger;
+
+/** Utility class for managing DeepSeek clients. */
+public class DeepSeekUtils {

Review Comment:
   A suggestion, I would have a had a client manager class that manages the clients and not use statics.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [model] Support Deepseek Function [flink]

Posted by "davidradl (via GitHub)" <gi...@apache.org>.
davidradl commented on code in PR #26901:
URL: https://github.com/apache/flink/pull/26901#discussion_r2275841158


##########
docs/content/docs/connectors/models/deepseek.md:
##########
@@ -0,0 +1,56 @@
+---
+title: "OpenAI"
+weight: 1
+type: docs
+---
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+  http://www.apache.org/licenses/LICENSE-2.0
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+# DeepSeek
+
+The DeepSeek Model Function allows Flink SQL to call [DeepSeek API](https://www.deepseek.com/) for inference tasks.
+
+## Configuration Options
+
+| Option         | Required | Default  | Description                                                         |
+|----------------|----------|----------|---------------------------------------------------------------------|
+| provider       | Yes      | -        | Must be `deepseek`                                                  |
+| endpoint       | Yes      | -        | API endpoint (e.g., `https://api.deepseek.com/v1/chat/completions`) |
+| api-key        | Yes      | -        | DeepSeek API key                                                    |
+| model          | Yes      | -        | Model name (e.g., `deepseek-chat`、`deepseek-reasoner`)                                 |
+| temperature    | No       | 0.7      | Sampling temperature                                                |
+| max-tokens     | No       | -        | Maximum output tokens                                               |
+| dimension      | No       | -        | Embedding vector dimension                                          |

Review Comment:
   is there a link to point to all possible model names



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [model] Support Deepseek Function [flink]

Posted by "davidradl (via GitHub)" <gi...@apache.org>.
davidradl commented on code in PR #26901:
URL: https://github.com/apache/flink/pull/26901#discussion_r2275901885


##########
docs/content/docs/connectors/models/deepseek.md:
##########
@@ -0,0 +1,56 @@
+---
+title: "OpenAI"
+weight: 1
+type: docs
+---
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+  http://www.apache.org/licenses/LICENSE-2.0
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+# DeepSeek
+
+The DeepSeek Model Function allows Flink SQL to call [DeepSeek API](https://www.deepseek.com/) for inference tasks.
+
+## Configuration Options
+
+| Option         | Required | Default  | Description                                                         |
+|----------------|----------|----------|---------------------------------------------------------------------|
+| provider       | Yes      | -        | Must be `deepseek`                                                  |
+| endpoint       | Yes      | -        | API endpoint (e.g., `https://api.deepseek.com/v1/chat/completions`) |

Review Comment:
   we should document` top-p` as well.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [model] Support Deepseek Function [flink]

Posted by "qining-mj (via GitHub)" <gi...@apache.org>.
qining-mj commented on code in PR #26901:
URL: https://github.com/apache/flink/pull/26901#discussion_r2276629657


##########
docs/content/docs/connectors/models/deepseek.md:
##########
@@ -0,0 +1,56 @@
+---
+title: "OpenAI"
+weight: 1
+type: docs
+---
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+  http://www.apache.org/licenses/LICENSE-2.0
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+# DeepSeek
+
+The DeepSeek Model Function allows Flink SQL to call [DeepSeek API](https://www.deepseek.com/) for inference tasks.
+
+## Configuration Options
+
+| Option         | Required | Default  | Description                                                         |
+|----------------|----------|----------|---------------------------------------------------------------------|
+| provider       | Yes      | -        | Must be `deepseek`                                                  |
+| endpoint       | Yes      | -        | API endpoint (e.g., `https://api.deepseek.com/v1/chat/completions`) |

Review Comment:
   @davidradl  Teacher David Radl, I have optimized and tested the code. Please review it again. Thank you for your guidance



##########
docs/content/docs/connectors/models/deepseek.md:
##########
@@ -0,0 +1,56 @@
+---
+title: "OpenAI"
+weight: 1
+type: docs
+---
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+  http://www.apache.org/licenses/LICENSE-2.0
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+# DeepSeek
+
+The DeepSeek Model Function allows Flink SQL to call [DeepSeek API](https://www.deepseek.com/) for inference tasks.

Review Comment:
   @davidradl  Teacher David Radl, I have optimized and tested the code. Please review it again. Thank you for your guidance



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [model] Support Deepseek Function [flink]

Posted by "davidradl (via GitHub)" <gi...@apache.org>.
davidradl commented on code in PR #26901:
URL: https://github.com/apache/flink/pull/26901#discussion_r2275841158


##########
docs/content/docs/connectors/models/deepseek.md:
##########
@@ -0,0 +1,56 @@
+---
+title: "OpenAI"
+weight: 1
+type: docs
+---
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+  http://www.apache.org/licenses/LICENSE-2.0
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+# DeepSeek
+
+The DeepSeek Model Function allows Flink SQL to call [DeepSeek API](https://www.deepseek.com/) for inference tasks.
+
+## Configuration Options
+
+| Option         | Required | Default  | Description                                                         |
+|----------------|----------|----------|---------------------------------------------------------------------|
+| provider       | Yes      | -        | Must be `deepseek`                                                  |
+| endpoint       | Yes      | -        | API endpoint (e.g., `https://api.deepseek.com/v1/chat/completions`) |
+| api-key        | Yes      | -        | DeepSeek API key                                                    |
+| model          | Yes      | -        | Model name (e.g., `deepseek-chat`、`deepseek-reasoner`)                                 |
+| temperature    | No       | 0.7      | Sampling temperature                                                |
+| max-tokens     | No       | -        | Maximum output tokens                                               |
+| dimension      | No       | -        | Embedding vector dimension                                          |

Review Comment:
   is there a link to point to all possible model names



##########
docs/content/docs/connectors/models/deepseek.md:
##########
@@ -0,0 +1,56 @@
+---
+title: "OpenAI"
+weight: 1
+type: docs
+---
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+  http://www.apache.org/licenses/LICENSE-2.0
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+# DeepSeek
+
+The DeepSeek Model Function allows Flink SQL to call [DeepSeek API](https://www.deepseek.com/) for inference tasks.
+
+## Configuration Options
+
+| Option         | Required | Default  | Description                                                         |
+|----------------|----------|----------|---------------------------------------------------------------------|
+| provider       | Yes      | -        | Must be `deepseek`                                                  |
+| endpoint       | Yes      | -        | API endpoint (e.g., `https://api.deepseek.com/v1/chat/completions`) |
+| api-key        | Yes      | -        | DeepSeek API key                                                    |
+| model          | Yes      | -        | Model name (e.g., `deepseek-chat`、`deepseek-reasoner`)                                 |

Review Comment:
   is there a link to point to all possible model names



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [model] Support Deepseek Function [flink]

Posted by "davidradl (via GitHub)" <gi...@apache.org>.
davidradl commented on code in PR #26901:
URL: https://github.com/apache/flink/pull/26901#discussion_r2275814904


##########
docs/content/docs/connectors/models/deepseek.md:
##########
@@ -0,0 +1,56 @@
+---
+title: "OpenAI"
+weight: 1
+type: docs
+---
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+  http://www.apache.org/licenses/LICENSE-2.0
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+# DeepSeek
+
+The DeepSeek Model Function allows Flink SQL to call [DeepSeek API](https://www.deepseek.com/) for inference tasks.
+
+## Configuration Options
+
+| Option         | Required | Default  | Description                                                         |
+|----------------|----------|----------|---------------------------------------------------------------------|
+| provider       | Yes      | -        | Must be `deepseek`                                                  |
+| endpoint       | Yes      | -        | API endpoint (e.g., `https://api.deepseek.com/v1/chat/completions`) |

Review Comment:
   nit: `e.g.,` -> `e.g.`
   
   I suggest a link into the deepseek website to indicate where to find the possible API endpoints. 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [model] Support Deepseek Function [flink]

Posted by "qining-mj (via GitHub)" <gi...@apache.org>.
qining-mj commented on PR #26901:
URL: https://github.com/apache/flink/pull/26901#issuecomment-3188454548

   @davidradl   Teacher David Radl, I have optimized and tested the code. Please review it again. Thank you for your guidance


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [model] Support Deepseek Function [flink]

Posted by "davidradl (via GitHub)" <gi...@apache.org>.
davidradl commented on code in PR #26901:
URL: https://github.com/apache/flink/pull/26901#discussion_r2275919822


##########
docs/content/docs/connectors/models/deepseek.md:
##########
@@ -0,0 +1,56 @@
+---
+title: "OpenAI"
+weight: 1
+type: docs
+---
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+  http://www.apache.org/licenses/LICENSE-2.0
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+# DeepSeek
+
+The DeepSeek Model Function allows Flink SQL to call [DeepSeek API](https://www.deepseek.com/) for inference tasks.

Review Comment:
   I think we should mention the expected schema in the docs, to help the user. i.e. for this it has to be one column called `content`. 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [model] Support Deepseek Function [flink]

Posted by "qining-mj (via GitHub)" <gi...@apache.org>.
qining-mj commented on code in PR #26901:
URL: https://github.com/apache/flink/pull/26901#discussion_r2276629657


##########
docs/content/docs/connectors/models/deepseek.md:
##########
@@ -0,0 +1,56 @@
+---
+title: "OpenAI"
+weight: 1
+type: docs
+---
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+  http://www.apache.org/licenses/LICENSE-2.0
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+# DeepSeek
+
+The DeepSeek Model Function allows Flink SQL to call [DeepSeek API](https://www.deepseek.com/) for inference tasks.
+
+## Configuration Options
+
+| Option         | Required | Default  | Description                                                         |
+|----------------|----------|----------|---------------------------------------------------------------------|
+| provider       | Yes      | -        | Must be `deepseek`                                                  |
+| endpoint       | Yes      | -        | API endpoint (e.g., `https://api.deepseek.com/v1/chat/completions`) |

Review Comment:
   @davidradl  Teacher David Radl, I have optimized and tested the code. Please review it again. Thank you for your guidance



##########
docs/content/docs/connectors/models/deepseek.md:
##########
@@ -0,0 +1,56 @@
+---
+title: "OpenAI"
+weight: 1
+type: docs
+---
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+  http://www.apache.org/licenses/LICENSE-2.0
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+# DeepSeek
+
+The DeepSeek Model Function allows Flink SQL to call [DeepSeek API](https://www.deepseek.com/) for inference tasks.

Review Comment:
   @davidradl  Teacher David Radl, I have optimized and tested the code. Please review it again. Thank you for your guidance



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [model] Support Deepseek Function [flink]

Posted by "qining-mj (via GitHub)" <gi...@apache.org>.
qining-mj commented on PR #26901:
URL: https://github.com/apache/flink/pull/26901#issuecomment-3192034582

   Hi @davidradl, just a kind reminder to seek your guidance on this patch when time permits , I’d be grateful for any feedback!


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [model] Support Deepseek Function [flink]

Posted by "davidradl (via GitHub)" <gi...@apache.org>.
davidradl commented on code in PR #26901:
URL: https://github.com/apache/flink/pull/26901#discussion_r2275854377


##########
docs/content/docs/connectors/models/deepseek.md:
##########
@@ -0,0 +1,56 @@
+---
+title: "OpenAI"
+weight: 1
+type: docs
+---
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+  http://www.apache.org/licenses/LICENSE-2.0
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+# DeepSeek
+
+The DeepSeek Model Function allows Flink SQL to call [DeepSeek API](https://www.deepseek.com/) for inference tasks.
+
+## Configuration Options
+
+| Option         | Required | Default  | Description                                                         |
+|----------------|----------|----------|---------------------------------------------------------------------|
+| provider       | Yes      | -        | Must be `deepseek`                                                  |
+| endpoint       | Yes      | -        | API endpoint (e.g., `https://api.deepseek.com/v1/chat/completions`) |
+| api-key        | Yes      | -        | DeepSeek API key                                                    |
+| model          | Yes      | -        | Model name (e.g., `deepseek-chat`、`deepseek-reasoner`)                                 |
+| temperature    | No       | 0.7      | Sampling temperature                                                |
+| max-tokens     | No       | -        | Maximum output tokens                                               |
+| dimension      | No       | -        | Embedding vector dimension                                          |

Review Comment:
   is the default 1536?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [model] Support Deepseek Function [flink]

Posted by "davidradl (via GitHub)" <gi...@apache.org>.
davidradl commented on code in PR #26901:
URL: https://github.com/apache/flink/pull/26901#discussion_r2275839830


##########
docs/content/docs/connectors/models/deepseek.md:
##########
@@ -0,0 +1,56 @@
+---
+title: "OpenAI"
+weight: 1
+type: docs
+---
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+  http://www.apache.org/licenses/LICENSE-2.0
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+# DeepSeek
+
+The DeepSeek Model Function allows Flink SQL to call [DeepSeek API](https://www.deepseek.com/) for inference tasks.
+
+## Configuration Options
+
+| Option         | Required | Default  | Description                                                         |
+|----------------|----------|----------|---------------------------------------------------------------------|
+| provider       | Yes      | -        | Must be `deepseek`                                                  |
+| endpoint       | Yes      | -        | API endpoint (e.g., `https://api.deepseek.com/v1/chat/completions`) |
+| api-key        | Yes      | -        | DeepSeek API key                                                    |

Review Comment:
   We should point to https://platform.deepseek.com/api_keys. 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [model] Support Deepseek Function [flink]

Posted by "qining-mj (via GitHub)" <gi...@apache.org>.
qining-mj closed pull request #26901: [model] Support Deepseek Function
URL: https://github.com/apache/flink/pull/26901


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [model] Support Deepseek Function [flink]

Posted by "davidradl (via GitHub)" <gi...@apache.org>.
davidradl commented on code in PR #26901:
URL: https://github.com/apache/flink/pull/26901#discussion_r2275814904


##########
docs/content/docs/connectors/models/deepseek.md:
##########
@@ -0,0 +1,56 @@
+---
+title: "OpenAI"
+weight: 1
+type: docs
+---
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+  http://www.apache.org/licenses/LICENSE-2.0
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+# DeepSeek
+
+The DeepSeek Model Function allows Flink SQL to call [DeepSeek API](https://www.deepseek.com/) for inference tasks.
+
+## Configuration Options
+
+| Option         | Required | Default  | Description                                                         |
+|----------------|----------|----------|---------------------------------------------------------------------|
+| provider       | Yes      | -        | Must be `deepseek`                                                  |
+| endpoint       | Yes      | -        | API endpoint (e.g., `https://api.deepseek.com/v1/chat/completions`) |

Review Comment:
   nit: `e.g.,` -> `e.g.`



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [model] Support Deepseek Function [flink]

Posted by "davidradl (via GitHub)" <gi...@apache.org>.
davidradl commented on code in PR #26901:
URL: https://github.com/apache/flink/pull/26901#discussion_r2275899633


##########
flink-models/flink-model-deepseek/src/main/java/org/apache/flink/model/deepseek/DeepSeekChatAndEmbeddingModelFunction.java:
##########
@@ -0,0 +1,189 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.model.deepseek;
+
+import org.apache.flink.configuration.ConfigOption;
+import org.apache.flink.configuration.ConfigOptions;
+import org.apache.flink.configuration.ReadableConfig;
+import org.apache.flink.table.data.GenericRowData;
+import org.apache.flink.table.data.RowData;
+import org.apache.flink.table.data.binary.BinaryStringData;
+import org.apache.flink.table.factories.ModelProviderFactory;
+import org.apache.flink.table.functions.AsyncPredictFunction;
+import org.apache.flink.table.types.logical.VarCharType;
+
+import com.google.gson.Gson;
+import com.google.gson.JsonObject;
+import okhttp3.MediaType;
+import okhttp3.Request;
+import okhttp3.RequestBody;
+import okhttp3.Response;
+import java.io.IOException;
+
+import javax.annotation.Nullable;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.List;
+import java.util.concurrent.CompletableFuture;
+import java.util.stream.Collectors;
+
+/** {@link AsyncPredictFunction} for DeepSeek chat completion task. */
+public class DeepSeekChatAndEmbeddingModelFunction extends AbstractDeepSeekModelFunction {
+    private static final long serialVersionUID = 1L;
+
+    public static final String ENDPOINT_SUFFIX = "chat/completions";
+
+    public static final ConfigOption<String> SYSTEM_PROMPT = 
+            ConfigOptions.key("system-prompt")
+                    .stringType()
+                    .defaultValue("You are a helpful assistant.")
+                    .withDescription("System message for chat tasks.");
+
+    public static final ConfigOption<Double> TEMPERATURE = 
+            ConfigOptions.key("temperature")
+                    .doubleType()
+                    .noDefaultValue()

Review Comment:
   the docs say that temperature has a default of 0.7



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [model] Support Deepseek Function [flink]

Posted by "davidradl (via GitHub)" <gi...@apache.org>.
davidradl commented on code in PR #26901:
URL: https://github.com/apache/flink/pull/26901#discussion_r2275851236


##########
docs/content/docs/connectors/models/deepseek.md:
##########
@@ -0,0 +1,56 @@
+---
+title: "OpenAI"
+weight: 1
+type: docs
+---
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+  http://www.apache.org/licenses/LICENSE-2.0
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+# DeepSeek
+
+The DeepSeek Model Function allows Flink SQL to call [DeepSeek API](https://www.deepseek.com/) for inference tasks.
+
+## Configuration Options
+
+| Option         | Required | Default  | Description                                                         |
+|----------------|----------|----------|---------------------------------------------------------------------|
+| provider       | Yes      | -        | Must be `deepseek`                                                  |
+| endpoint       | Yes      | -        | API endpoint (e.g., `https://api.deepseek.com/v1/chat/completions`) |
+| api-key        | Yes      | -        | DeepSeek API key                                                    |
+| model          | Yes      | -        | Model name (e.g., `deepseek-chat`、`deepseek-reasoner`)                                 |
+| temperature    | No       | 0.7      | Sampling temperature                                                |
+| max-tokens     | No       | -        | Maximum output tokens                                               |

Review Comment:
   there must be a default - I assume it is no limit. also how do we say there is no limit is it -1 ?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [model] Support Deepseek Function [flink]

Posted by "qining-mj (via GitHub)" <gi...@apache.org>.
qining-mj commented on PR #26901:
URL: https://github.com/apache/flink/pull/26901#issuecomment-3193082104

   @davidradl Teacher David Radl, I have optimized and tested the code. Please review it again. Thank you for your guidance.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [model] Support Deepseek Function [flink]

Posted by "davidradl (via GitHub)" <gi...@apache.org>.
davidradl commented on code in PR #26901:
URL: https://github.com/apache/flink/pull/26901#discussion_r2275814904


##########
docs/content/docs/connectors/models/deepseek.md:
##########
@@ -0,0 +1,56 @@
+---
+title: "OpenAI"
+weight: 1
+type: docs
+---
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+  http://www.apache.org/licenses/LICENSE-2.0
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+# DeepSeek
+
+The DeepSeek Model Function allows Flink SQL to call [DeepSeek API](https://www.deepseek.com/) for inference tasks.
+
+## Configuration Options
+
+| Option         | Required | Default  | Description                                                         |
+|----------------|----------|----------|---------------------------------------------------------------------|
+| provider       | Yes      | -        | Must be `deepseek`                                                  |
+| endpoint       | Yes      | -        | API endpoint (e.g., `https://api.deepseek.com/v1/chat/completions`) |

Review Comment:
   nit: `e.g.,` -> `e.g.`
   
   I suggest a link into the deepseek website to indicate where to find the possible API endpoints. 
   
   Currently the code looks to be hard coded to chat completions. The docs imply that other values could be supplied. 
   `  public static final String ENDPOINT_SUFFIX = "chat/completions";`



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [model] Support Deepseek Function [flink]

Posted by "davidradl (via GitHub)" <gi...@apache.org>.
davidradl commented on code in PR #26901:
URL: https://github.com/apache/flink/pull/26901#discussion_r2275901885


##########
docs/content/docs/connectors/models/deepseek.md:
##########
@@ -0,0 +1,56 @@
+---
+title: "OpenAI"
+weight: 1
+type: docs
+---
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+  http://www.apache.org/licenses/LICENSE-2.0
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+# DeepSeek
+
+The DeepSeek Model Function allows Flink SQL to call [DeepSeek API](https://www.deepseek.com/) for inference tasks.
+
+## Configuration Options
+
+| Option         | Required | Default  | Description                                                         |
+|----------------|----------|----------|---------------------------------------------------------------------|
+| provider       | Yes      | -        | Must be `deepseek`                                                  |
+| endpoint       | Yes      | -        | API endpoint (e.g., `https://api.deepseek.com/v1/chat/completions`) |

Review Comment:
   we should document` top-p` and `stop `as well.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [model] Support Deepseek Function [flink]

Posted by "davidradl (via GitHub)" <gi...@apache.org>.
davidradl commented on code in PR #26901:
URL: https://github.com/apache/flink/pull/26901#discussion_r2275892365


##########
flink-models/flink-model-deepseek/src/main/java/org/apache/flink/model/deepseek/DeepSeekUtils.java:
##########
@@ -0,0 +1,107 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.model.deepseek;
+
+import org.apache.flink.util.Preconditions;
+
+import okhttp3.OkHttpClient;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.time.Duration;
+import java.util.concurrent.atomic.AtomicInteger;
+
+/** Utility class for managing DeepSeek clients. */
+public class DeepSeekUtils {
+    private static final Logger LOG = LoggerFactory.getLogger(DeepSeekUtils.class);
+
+    private static final Object LOCK = new Object();
+
+    private static ReferenceValue client;
+
+    public static OkHttpClient createClient(String baseUrl, String apiKey) {
+        synchronized (LOCK) {
+            if (client != null) {
+                LOG.debug("Returning an existing DeepSeek client.");
+                client.referenceCount.incrementAndGet();
+                return client.client;
+            }
+            return new OkHttpClient.Builder()
+                    .connectTimeout(Duration.ofSeconds(30))
+                    .readTimeout(Duration.ofSeconds(30))
+                    .writeTimeout(Duration.ofSeconds(30))
+                    .addInterceptor(chain -> {
+                        okhttp3.Request original = chain.request();
+                        okhttp3.Request request = original.newBuilder()
+                                .header("Authorization", "Bearer " + apiKey)
+                                .header("Content-Type", "application/json")
+                                .method(original.method(), original.body())
+                                .build();
+                        return chain.proceed(request);
+                    })
+                    .build();
+        }
+    }
+
+
+
+    /**
+     * Releases a DeepSeek client instance. If the reference count reaches zero, the client is closed
+     * and removed from the cache.
+     *
+     */
+    public static void releaseClient() {
+        synchronized (LOCK) {
+            Preconditions.checkNotNull(
+                    client, "The creation and release of DeepSeek client does not match.");
+            int count = client.referenceCount.decrementAndGet();
+            if (count == 0) {

Review Comment:
   it this counting correct? 
   We create a client with a reference count of 0,
   the subsequently we add 1 every time the client is referenced. So we will still have a client on count 0. 
   
   I think this would work if the first client was created `this.referenceCount = new AtomicInteger(1);`
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [model] Support Deepseek Function [flink]

Posted by "flinkbot (via GitHub)" <gi...@apache.org>.
flinkbot commented on PR #26901:
URL: https://github.com/apache/flink/pull/26901#issuecomment-3184525909

   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "1213b7b7671a313a90d3edd6956082fe3b2999ca",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "1213b7b7671a313a90d3edd6956082fe3b2999ca",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 1213b7b7671a313a90d3edd6956082fe3b2999ca UNKNOWN
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run azure` re-run the last Azure build
   </details>


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org