Upgrades leave old two-parameter openai_compatible_generate[_json] overloads, and two-argument calls still run the old code

オープン 初心者向け
#53 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
76/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
sql
領域
databases

調査の方向性

src/openai_compatible/generate.sqlから始め、2つの関数定義の前にあるクリーンアップブロックを読んでください。IBM iでQSYS2.SYSROUTINESが特定名とパラメーター数をどのように報告するかを確認し、再構築後に4パラメーターのルーチンだけが残り、2引数の呼び出しが現在の実装を使用することを検証してください。

索引モデルが issue の本文から書いたものです。

説明

bug

Upgrading an existing installation leaves the old two-parameter versions of openai_compatible_generate and openai_compatible_generate_json in DBSDK_V1. Two-argument calls keep running that old code.

Observed

On an IBM i system that had an earlier version of the toolkit installed, rebuilding the current source left both versions of each function:

Routine Specific name Parameters Created
OPENAI_COMPATIBLE_GENERATE OPENAI_COMPATIBLE_GENERATE 2 2025-07-10
OPENAI_COMPATIBLE_GENERATE OPENA00001 4 current build
OPENAI_COMPATIBLE_GENERATE_JSON OPENAI_COMPATIBLE_GENERATE_JSON 2 2025-05-12
OPENAI_COMPATIBLE_GENERATE_JSON OPENA00002 4 current build

A call such as openai_compatible_generate('prompt', '{}') resolves to the exact two-parameter match, which is the 2025 code. In this case the old code built the URL without the configured port, so it failed with "Failed to open connection to server at host localhost and port 80". Calls with three or four arguments use the current code, so the behavior depends on how a function is called.

Cause

create or replace function replaces a function only when the parameter list matches. When the parameter list changed, the build added a new overload instead.

Fix

At the top of src/openai_compatible/generate.sql, drop every version of the two functions that doesn't take four parameters, before creating the current ones. On a fresh install this finds nothing. The note is a block comment so that the docs generator, which copies -- lines, leaves it out.

This was verified on IBM i 7.5: after a rebuild, only the two four-parameter functions remain, and two-argument calls use the current code. The change:

--- a/src/openai_compatible/generate.sql
+++ b/src/openai_compatible/generate.sql
@@ -1,5 +1,24 @@
 -- ## OpenAI-compatible endpoints main functionality
 
+/*
+  Earlier versions of the toolkit defined openai_compatible_generate and
+  openai_compatible_generate_json with two parameters. "create or replace" with a different
+  parameter list adds an overload instead of replacing it, and two-argument calls would keep
+  resolving to the old version, so remove any versions that do not take four parameters.
+  (A block comment, so the docs generator, which copies "-- " lines, leaves it out.)
+*/
+begin
+  for old_routine as
+    select specific_name
+      from qsys2.sysroutines
+      where routine_schema = 'DBSDK_V1'
+        and routine_name in ('OPENAI_COMPATIBLE_GENERATE', 'OPENAI_COMPATIBLE_GENERATE_JSON')
+        and in_parms <> 4
+  do
+    execute immediate 'drop specific function dbsdk_v1.' concat old_routine.specific_name;
+  end for;
+end;
+
 -- #### **Function:** `openai_compatible_generate`
 
 -- **Description:** Uses OpenAI-compatible API to generate a reply to the given prompt
主要言語
RPGLE
スター
13
フォーク
7
平均マージ
1日 10時間
マージ済み PR(30日)
4

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

IBM/AI-SQL-Toolkit-IBMi のほかの issue

IBM/AI-SQL-Toolkit-IBMi の issue をすべて見る

似ている issue

Databases の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。