Repository navigation
v3.0.0-alpha.4
Pre-releaseWhat 3.0.0-alpha.4 brings
ngx_mruby 3.0 is the next major version. In addition to ordinary web services, it aims to run Ruby rules in front of AI applications, model APIs and MCP servers. This fourth pre-release adds a shared dictionary: keys and values that all workers of one nginx read and change. It is the first part of the planned agent proxy; the other parts are still planned for the pre-releases after it ("What comes next" below).
-
One counter for all workers.
mruby_shared_dict NAME SIZE [evict];in thehttpblock declares a shared dictionary, a zone of nginx's shared memory, andNginx::SharedDict["NAME"]returns it in a script (#898). A Ruby global variable belongs to one worker, so a counter in it counts the requests of that worker only. An entry of a shared dictionary is one for all workers, andincradds to its number atomically: when two workers add at the same time, both additions count.http { mruby_shared_dict counters 1m; server { location /count { mruby_content_handler_code ' n = Nginx::SharedDict["counters"].incr "count" Nginx.rputs "request #{n} of all workers" '; } } }
The number in the response counts the requests to
/countof all workers, and a reload does not reset it. The page of mruby_shared_dict has an example that limits each API key to 1000 requests a day.- Values: a key is a String, and a value is a String, an Integer or a Float. The methods are
get,set,incr,delete,keys(prefix)andsize(Nginx::SharedDict). - Time to live:
setandincrtake it in seconds, and an entry whose time to live has ended reads as missing.incrsets it only when it creates the key: inincr key, 1, 60, the 60 seconds start at the first call, and the counter starts again after them. - Reload: the entries stay when the name and the size of the zone stay the same. They are lost when nginx stops, and a binary upgrade starts with empty zones.
- A zone without room:
setandincrremove the expired entries, and raiseNginx::SharedDict::FullErrorwhen that does not make room. Withevict, they then remove the least recently used entries, at most 30 in one call, and still raise when that does not make room. Useevictfor a cache, and for counters whose keys come from outside, such as a counter per client address. Leave it out for a budget, such as a limit per API key: an entry that goes away lets requests through that the limit should have stopped. - Scope: the dictionary belongs to one host and to
http {}. Scripts instream {}have noNginx::SharedDict.
- Values: a key is a String, and a value is a String, an Integer or a Float. The methods are
-
Instructions per request close to those of 3.0.0-alpha.3. Before the tag, the tip of
next(96d2dc9a9) was compared with 3.0.0-alpha.3 under callgrind. No scenario is atWARNorFAIL. In the number that the comparison judges, without the GC and the constant lookups that missed mruby's cache, the largest change is in the scenario that routes by the model in a JSON body of 2 KB (+0.78%, 762 instructions per request), and the largest decrease in the handler from a file (-0.71%, 88 instructions). The totals per request, GC included, change by -0.55% to +1.21%. A request of a configuration withoutmruby_shared_dictruns no code of the dictionary. In the same run, onegetof a String of 16 bytes took 1,014 instructions and oneincr888, without the GC and with the String literal of the key, in a dictionary of 1,000 entries. These are instruction counts, not wall-clock times; the table is below. -
Two fixes of
Nginx.redirect. With a URL that starts withhttp://,https://or$scheme, it sets every field of theLocationelement that it adds to nginx's response headers. The responses are unchanged; a module from outside the nginx distribution that reads the fields now reads correct values (#891). It also compares its target with these prefixes only when the target is at least as long as the prefix, so that the target alone decides whether a short one, such ashttp:, is an external or an internal redirect (#893). 2.7.16 has the same two fixes. -
Try it locally.
examples/startuses Docker Compose to run an nginx that routes requests by model to two mock APIs. No provider API key is needed. Since this pre-release, its log handler writes the id of the request, the model and the upstream into the line ofaccess_log, which 2.x leaves empty with the same configuration (#889). The migration guide lists what changes for a configuration or a script of 2.x.
The comparison with 3.0.0-alpha.3 (callgrind, before the tag)
Base v3.0.0-alpha.3 (6c8e05ba6), head 96d2dc9a9, in a Linux container on an arm64 host. The four dict_* scenarios need mruby_shared_dict, which the base does not have, so they have no comparison (n/a).
perf: N=20000 WARMUP=2000; Ir per request of nginx; WARN from 3.0%, FAIL from 5.0% on the number in the column judged: w/o GC/const (Ir/req minus the GC and the constant lookups that missed the cache), or w/o GC (minus the GC only) where the head clears the constant cache more often, or clears it and misses more lookups (const_clears, const_misses)
perf: units: stream_sleep = completed TCP session; other rows = HTTP request
perf: gems: 8 in both builds, 0 at different commits, 0 only in base, 0 only in head
perf: mruby: base 4.1.0, head 4.1.0; accepted differences (accepted.txt): none apply
scenario base Ir/req head Ir/req change base w/o GC head w/o GC change w/o GC base w/o GC/const head w/o GC/const change w/o GC/const GC share judged result
hello 11198 11159 -0.34% 10487 10451 -0.34% 10487 10451 -0.34% 6.3%/6.3% w/o GC/const ok
headers 29990 29937 -0.18% 24804 24680 -0.50% 24804 24680 -0.50% 17.3%/17.6% w/o GC/const ok
var 20309 20213 -0.47% 17272 17155 -0.68% 17272 17155 -0.68% 15.0%/15.1% w/o GC/const ok
filter 14625 14569 -0.39% 12855 12771 -0.65% 12855 12771 -0.65% 12.1%/12.3% w/o GC/const ok
sleep 15402 15339 -0.41% 14185 14112 -0.51% 14185 14112 -0.51% 7.9%/8.0% w/o GC/const ok
sub_request 44535 44292 -0.55% 42875 42614 -0.61% 42111 41850 -0.62% 3.7%/3.8% w/o GC/const ok
file 14246 14191 -0.38% 12475 12387 -0.71% 12475 12387 -0.71% 12.4%/12.7% w/o GC/const ok
dict_base - - - - - - - - - - - n/a (base: unknown directive)
dict_lookup - - - - - - - - - - - n/a (base: unknown directive)
dict_get - - - - - - - - - - - n/a (base: unknown directive)
dict_incr - - - - - - - - - - - n/a (base: unknown directive)
proxy_plain_2k 21812 21769 -0.20% 21812 21769 -0.20% 21812 21769 -0.20% 0.0%/0.0% w/o GC/const ok
proxy_plain_64k 22120 22086 -0.16% 22120 22086 -0.16% 22120 22086 -0.16% 0.0%/0.0% w/o GC/const ok
proxy_stream_plain_50 54096 54086 -0.02% 54096 54086 -0.02% 54096 54086 -0.02% 0.0%/0.0% w/o GC/const ok
responses_stream_plain_50 55350 55347 -0.01% 55350 55347 -0.01% 55350 55347 -0.01% 0.0%/0.0% w/o GC/const ok
auth 48119 48703 +1.21% 41931 42390 +1.09% 41931 41822 -0.26% 12.9%/13.0% w/o GC/const ok
route_json_2k 105630 106552 +0.87% 97087 97849 +0.78% 97087 97849 +0.78% 8.1%/8.2% w/o GC/const ok
ruby_call_1 10968 11008 +0.37% 10241 10267 +0.25% 10241 10267 +0.25% 6.6%/6.7% w/o GC/const ok
ruby_call_10 41500 41760 +0.63% 34182 34402 +0.64% 34182 34402 +0.64% 17.6%/17.6% w/o GC/const ok
stream_sleep 12232 12236 +0.03% 11289 11292 +0.03% 11289 11292 +0.03% 7.7%/7.7% w/o GC/const ok
What comes next
The next pre-releases are planned to add the parts of an AI gateway below. None of them is in this pre-release.
- A filter that reads the server-sent events (SSE) of a streamed model response one event at a time, for example to count token usage.
- Re-selecting the upstream, and a timeout for the first byte from the upstream, for model API fallback.
- A reference agent proxy built on these parts and on the shared dictionary. It is planned to keep the token and money budgets of each client key in the shared dictionary of one host; a non-blocking socket API that would share them across hosts is in the plan too, and its design is still to be evaluated.
Step 7 of the v3 plan lists the parts and their order: the shared dictionary is its part (a), and these are parts (b) to (e). The uses they serve include MCP tool authorization, limits on bursts of agent calls, model API fallback and AI crawler control; the home page and the list of uses show the design status of each.
Behavior changes: read before upgrading
No entry of "Behavior changes" was added since 3.0.0-alpha.3. This section copies the two entries whose text changed. The first has the link to the advisory, published after 3.0.0-alpha.3; the behavior is that of 3.0.0-alpha.3. The second describes the access log of the local example (#889); the entry of #770 that it names is in the release notes. The other changes of the release notes since 3.0.0-alpha.3 are under "New features" (the shared dictionary) and "Build and test changes". The release notes of this tag have all 80 entries.
An mruby body filter no longer runs a second time on the empty buffer at the end of a proxied response
- Before: on a response from an upstream (
proxy_pass,fastcgi_pass,uwsgi_pass,scgi_passormemcached_pass), after an earlier phase handler leftNginx.rputsorNginx.echooutput in the module context and then declined, anmruby_output_body_filter(_code)ran a second time on the empty last buffer that the upstream sends after the body. A body filter whose output on an empty body is non-empty, such as one that prepends to or appends tof.body, produced bytes on that second run, and they were sent after the response, past itsContent-Length. - Now: the body filter passes that trailing empty buffer on without running its code again, so no bytes are sent after the framed response.
- Why it changed:
- The defect: the bytes that a body filter whose output on an empty body is non-empty produced on the second run and that were sent past the response's
Content-Length. On a connection that is kept alive, the client reads those bytes as the start of the next response on that connection; GHSA-5qjv-293c-64f8 has the details. - Why the old behavior could not be kept: the second run had no body to transform, so any bytes it produced could only follow a response that was already framed and sent.
- What the documentation promised:
docs/class_and_method/did not describe the body filter running a second time, anddocs/directives/did not describe output after the response.
- The defect: the bytes that a body filter whose output on an empty body is non-empty produced on the second run and that were sent past the response's
- Affected: a location with
mruby_output_body_filter(_code)whose output on an empty body is non-empty, served from an upstream whoseContent-Lengthis known, with an earlier handler that leavesNginx.rputsorNginx.echooutput and then returns a negative code the request declines past (in practiceNginx::DECLINED). A body filter that leaves an empty body empty, such asf.body = f.body.upcase, a static file, and a response sent chunked are unchanged. - What to do: nothing; rebuild the module with this release. A body filter that was guarded against an empty body (for example with
unless f.body.empty?) can keep the guard or drop it.
The local start example binds to loopback and adds mock model routing (#672)
- Before:
examples/start/compose.yamlpublished host port 8080 on all interfaces, and the trial demonstrated only the/helloRuby handler. - Now: the host binding is
127.0.0.1:8080:8080. The trial retains/helloand adds/v1/responses, which checks a public demonstration key and selects one of two loopback mock endpoints by model. Its log handler,log.rb, assigns the id of the request, the model and the upstream to nginx variables, andaccess_logwrites them with the status as one JSON object per request of/v1/responses(#889); 2.x leaves the three values empty with the same configuration, because its log handlers run afteraccess_log(see the entry of #770 below). The bilingual walkthrough checks route selection, credential replacement, rejected requests, the access log lines, editing, restoration and reload. - Why it changed:
- The reason: the first exercise should demonstrate the model-routing use case without a provider account or real key, and the access log lines show, in a local run, what 3.0 can write and 2.x cannot.
- Why the old behavior could not be kept: exposing the trial on every host interface is unnecessary for a local-only exercise;
/helloremains available. - What the documentation promised: the earlier start page showed a Hello response and explained that the host port was broadly published.
- Affected: users running the development example from
examples/start/; no runtime API or stable 2.x configuration is changed. - What to do: run the updated walkthrough locally. The bundled keys are demonstration values, and the mock response is not LLM inference, a provider compatibility test or API-format conversion. Do not publish this trial as a service.
3.0.0-alpha.4で得られるもの
ngx_mruby 3.0は、次のメジャーバージョンです。通常のWebサービスに加えて、AIアプリケーション、モデルAPI、MCPサーバーの前でRubyのルールを動かすことを目指しています。この4つ目のプレリリースでは、共有辞書を足しました。共有辞書のキーと値は、1つのnginxのすべてのワーカーが読み書きします。共有辞書は、計画しているエージェントプロキシの部品のうち、最初に入ったものです。ほかの部品は、この後のプレリリースで足す予定です。下の「これから入るもの」を見てください。
-
すべてのワーカーで1つのカウンタを使えます。
httpブロックにmruby_shared_dict NAME SIZE [evict];を書くと、共有辞書を宣言します。共有辞書は、nginxの共有メモリのゾーンです。スクリプトでは、Nginx::SharedDict["NAME"]で取得します(#898)。Rubyのグローバル変数はワーカーごとに別なので、そこに置いたカウンタは、そのワーカーのリクエストだけを数えます。共有辞書では、すべてのワーカーが同じエントリを読み書きします。incrはアトミックに加算するので、2つのワーカーが同時に加算しても、両方の加算が反映されます。http { mruby_shared_dict counters 1m; server { location /count { mruby_content_handler_code ' n = Nginx::SharedDict["counters"].incr "count" Nginx.rputs "request #{n} of all workers" '; } } }
レスポンスに出る数は、すべてのワーカーが受けた
/countへのリクエストの数です。リロードしても、数は最初に戻りません。mruby_shared_dictのリファレンスに、リクエストをAPIキーごとに1日1000件までに制限する例があります。- 値:キーはStringで、値はString、Integer、Floatのどれかです。メソッドは、
get、set、incr、delete、keys(prefix)、sizeです。詳しくはNginx::SharedDictにあります。 - TTL:
setとincrに、秒で指定します。TTLが切れたエントリは、無いものとして扱います。incrがTTLを設定するのは、キーを作るときだけです。incr key, 1, 60では、最初の呼び出しから60秒を数え、60秒が過ぎるとカウンタは最初から数え直します。 - リロード:ゾーンの名前とサイズが同じなら、エントリは残ります。nginxを止めるとエントリは消えます。バイナリアップグレードの後は、空のゾーンで始まります。
- 空きの無いゾーン:
setとincrは期限切れのエントリを消し、それでも空かなければNginx::SharedDict::FullErrorを出します。evictを付けた共有辞書では、期限切れのエントリを消しても空かないと、期限内のエントリも、最後に使われた時刻が古い順に1回の呼び出しで30件まで消します。それでも空かなければ、例外を出します。evictは、キャッシュの共有辞書と、クライアントのアドレスのようにクライアントが決める値をキーにするカウンタの共有辞書に付けてください。APIキーごとのリクエスト数のように、上限を超えたリクエストを止めるために数えるカウンタの共有辞書には付けないでください。エントリが消えると、止めるはずのリクエストが通ります。 - 使える範囲:1台のホストの
http {}で使えます。stream {}のスクリプトにNginx::SharedDictはありません。
- 値:キーはStringで、値はString、Integer、Floatのどれかです。メソッドは、
-
リクエストあたりの命令数は、3.0.0-alpha.3に近い値です。 タグを付ける前の確認で、
nextの先端(96d2dc9a9)と3.0.0-alpha.3を、callgrindで比べました。WARNとFAILのシナリオはありません。判定に使う値は、GCと、mrubyの定数キャッシュに当たらなかった定数の参照を除いた命令数です。この値がいちばん大きく変わったのは、2KBのJSONのボディにあるモデルで振り分けるシナリオで、0.78%、1リクエストあたり762命令増えました。いちばん大きく減ったのは、ファイルに書いたハンドラで、0.71%、88命令です。GCも含めた1リクエストあたりの命令数の合計は、シナリオによって0.55%の減少から1.21%の増加までの範囲で変わりました。mruby_shared_dictを書いていない設定では、リクエストの処理で共有辞書のコードは動きません。同じ実行で測った共有辞書の操作は、16バイトのStringのgetが1回1,014命令、incrが1回888命令でした。エントリが1,000個ある共有辞書での値です。GCの命令は除き、キーのStringのリテラルからオブジェクトを作る命令は含みます。どれも命令数で、実行時間ではありません。表は下にあります。 -
Nginx.redirectの2つの不具合を直しました。http://、https://、$schemeのどれかで始まるURLをNginx.redirectに渡したときに、nginxのレスポンスヘッダのリストに加えるLocationの要素の、すべてのフィールドを設定するようにしました。レスポンスは変わりません。nginxの配布物に含まれないモジュールがこれらのフィールドを読むと、正しい値を読むようになります(#891)。また、リダイレクト先をこれらの接頭辞と比べるのは、リダイレクト先が接頭辞と同じ長さ以上のときだけにしました。http:のような短いリダイレクト先が外部リダイレクトになるか内部リダイレクトになるかは、リダイレクト先だけで決まります(#893)。同じ2つの修正は、2.7.16にも入っています。 -
手元で試せます。
examples/startは、Docker Composeで、モデルに応じてリクエストを2つのモックAPIのどちらかへ振り分けるnginxを動かします。プロバイダのAPIキーは不要です。このプレリリースから、この例のlogハンドラが、リクエストのID、モデル、upstreamをaccess_logの行に出します。2.xでは、同じ設定でもこの3つの値が空になります(#889)。2.xの設定やスクリプトで変わる点は、移行の手引きにあります。
タグを付ける前に測った、3.0.0-alpha.3との比較
callgrindで測りました。baseはv3.0.0-alpha.3(6c8e05ba6)、headは96d2dc9a9で、arm64のホストのLinuxのコンテナを使いました。dict_*の4つのシナリオは、baseに無いmruby_shared_dictを使うので、比べられずn/aになります。
perf: N=20000 WARMUP=2000; Ir per request of nginx; WARN from 3.0%, FAIL from 5.0% on the number in the column judged: w/o GC/const (Ir/req minus the GC and the constant lookups that missed the cache), or w/o GC (minus the GC only) where the head clears the constant cache more often, or clears it and misses more lookups (const_clears, const_misses)
perf: units: stream_sleep = completed TCP session; other rows = HTTP request
perf: gems: 8 in both builds, 0 at different commits, 0 only in base, 0 only in head
perf: mruby: base 4.1.0, head 4.1.0; accepted differences (accepted.txt): none apply
scenario base Ir/req head Ir/req change base w/o GC head w/o GC change w/o GC base w/o GC/const head w/o GC/const change w/o GC/const GC share judged result
hello 11198 11159 -0.34% 10487 10451 -0.34% 10487 10451 -0.34% 6.3%/6.3% w/o GC/const ok
headers 29990 29937 -0.18% 24804 24680 -0.50% 24804 24680 -0.50% 17.3%/17.6% w/o GC/const ok
var 20309 20213 -0.47% 17272 17155 -0.68% 17272 17155 -0.68% 15.0%/15.1% w/o GC/const ok
filter 14625 14569 -0.39% 12855 12771 -0.65% 12855 12771 -0.65% 12.1%/12.3% w/o GC/const ok
sleep 15402 15339 -0.41% 14185 14112 -0.51% 14185 14112 -0.51% 7.9%/8.0% w/o GC/const ok
sub_request 44535 44292 -0.55% 42875 42614 -0.61% 42111 41850 -0.62% 3.7%/3.8% w/o GC/const ok
file 14246 14191 -0.38% 12475 12387 -0.71% 12475 12387 -0.71% 12.4%/12.7% w/o GC/const ok
dict_base - - - - - - - - - - - n/a (base: unknown directive)
dict_lookup - - - - - - - - - - - n/a (base: unknown directive)
dict_get - - - - - - - - - - - n/a (base: unknown directive)
dict_incr - - - - - - - - - - - n/a (base: unknown directive)
proxy_plain_2k 21812 21769 -0.20% 21812 21769 -0.20% 21812 21769 -0.20% 0.0%/0.0% w/o GC/const ok
proxy_plain_64k 22120 22086 -0.16% 22120 22086 -0.16% 22120 22086 -0.16% 0.0%/0.0% w/o GC/const ok
proxy_stream_plain_50 54096 54086 -0.02% 54096 54086 -0.02% 54096 54086 -0.02% 0.0%/0.0% w/o GC/const ok
responses_stream_plain_50 55350 55347 -0.01% 55350 55347 -0.01% 55350 55347 -0.01% 0.0%/0.0% w/o GC/const ok
auth 48119 48703 +1.21% 41931 42390 +1.09% 41931 41822 -0.26% 12.9%/13.0% w/o GC/const ok
route_json_2k 105630 106552 +0.87% 97087 97849 +0.78% 97087 97849 +0.78% 8.1%/8.2% w/o GC/const ok
ruby_call_1 10968 11008 +0.37% 10241 10267 +0.25% 10241 10267 +0.25% 6.6%/6.7% w/o GC/const ok
ruby_call_10 41500 41760 +0.63% 34182 34402 +0.64% 34182 34402 +0.64% 17.6%/17.6% w/o GC/const ok
stream_sleep 12232 12236 +0.03% 11289 11292 +0.03% 11289 11292 +0.03% 7.7%/7.7% w/o GC/const ok
これから入るもの
この後のプレリリースでは、AIゲートウェイの部品を足す予定です。次の部品は、どれもこのプレリリースにはまだありません。
- ストリーミングで返るモデルの応答から、server-sent events(SSE)のイベントを1つずつ読むフィルタを足す予定です。トークンの使用量を数えるときなどに使います。
- upstreamを選び直す仕組みと、upstreamから最初のバイトを受け取るまでのタイムアウトを足す予定です。モデルAPIのフォールバックに使います。
- これらの部品と共有辞書で作る、リファレンス実装のエージェントプロキシを足す予定です。このプロキシは、クライアントのキーごとのトークンと金額の予算を、1台のホストの共有辞書に置く計画です。複数のホストで予算を共有するための、ノンブロッキングのソケットAPIも計画にあり、設計はこれから評価します。
部品とその順序は、v3の計画のステップ7にあります。共有辞書はその(a)で、上の部品は(b)から(e)です。これらの部品を使う用途には、MCPのツール呼び出しの認可、エージェントが短時間に繰り返す呼び出しの制限、モデルAPIのフォールバック、AIクローラーの制御などがあります。用途ごとの設計の状態は、トップページと用途の一覧にあります。
更新前に確認する挙動の変更
3.0.0-alpha.3から追加された項目はありません。この節には、文面が変わった2つの項目を載せます。1つ目には、3.0.0-alpha.3の後に公開したアドバイザリへのリンクを足しました。挙動は3.0.0-alpha.3と同じです。2つ目には、手元で試す例のアクセスログの説明を足しました(#889)。この項目が参照する#770の項目は、リリースノートにあります。3.0.0-alpha.3からのリリースノートの変更は、ほかに、「新機能」の共有辞書の項目と、「ビルドとテストの変更」の項目にあります。全80項目は、このタグのリリースノートにあります。
proxyのレスポンスの最後の空のバッファで、mrubyのボディフィルタが2回目に走らなくなった
- 変更前:upstream(
proxy_pass、fastcgi_pass、uwsgi_pass、scgi_pass、memcached_pass)からのレスポンスで、前段のフェーズのハンドラがNginx.rputsかNginx.echoの出力をmodule contextに残してDECLINEDしたあと、mruby_output_body_filter(_code)が、upstreamがボディのあとに送る空のlast bufferに対して2回目に走っていました。空のボディへの出力が非空になるボディフィルタ、たとえばf.bodyに前置きや後置きをするものは、この2回目でバイトを作り、そのバイトがレスポンスのContent-Lengthを超えて送られていました。 - 変更後:ボディフィルタは、この空のlast bufferをコードを走らせずに次へ渡します。枠付けされたレスポンスの後ろには何も送られません。
- 変更の理由:
- 不具合:空のボディへの出力が非空になるボディフィルタが2回目に作り、レスポンスの
Content-Lengthを超えて送られていたバイトです。keepaliveの接続では、クライアントがこのバイトを、その接続の次のレスポンスの先頭として読みます。詳細はGHSA-5qjv-293c-64f8にあります。 - 前の挙動を残せなかった理由:2回目には変換するボディが無いので、作られたバイトは、すでに枠付けして送ったレスポンスの後ろに続くしかありませんでした。
- ドキュメントが示していた挙動:
docs/class_and_method/は、ボディフィルタが2回目に走ることを書いていません。docs/directives/も、レスポンスの後ろに出力が出ることを書いていません。
- 不具合:空のボディへの出力が非空になるボディフィルタが2回目に作り、レスポンスの
- 影響の範囲:
mruby_output_body_filter(_code)で空のボディへの出力が非空になるものがあり、Content-Lengthの分かるupstreamから配信され、前段のハンドラがNginx.rputsかNginx.echoの出力を残して、リクエストがdeclineして通り過ぎる負のコード(実際にはNginx::DECLINED)を返す場合です。空のボディを空のまま返すボディフィルタ(たとえばf.body = f.body.upcase)、静的ファイル、chunkedで送るレスポンスは変わりません。 - 必要な対応:ありません。このリリースでモジュールをビルドし直してください。空のボディをガードしていたボディフィルタ(たとえば
unless f.body.empty?)は、ガードを残しても外してもかまいません。
ローカルの導入例をループバックに限定し、mockのモデル振り分けを加える(#672)
- 変更前:
examples/start/compose.yamlはホストの全インターフェースでポート8080を公開し、試用は/helloのRubyハンドラだけを扱っていました。 - 変更後:ホストの公開先を
127.0.0.1:8080:8080にします。/helloを残し、公開のデモ用キーを検査してモデルに応じた2つのループバックmockへ転送する/v1/responsesを加えます。/v1/responsesのlogハンドラのlog.rbは、リクエストのID、モデル、upstreamをnginxの変数に代入します。access_logは、その値とステータスを、リクエストごとに1つのJSONのオブジェクトとして書きます(#889)。2.xではlogハンドラがaccess_logの後に動くので、同じ設定でも、この3つの値は空になります。詳しくは、下の#770の項目にあります。英日の手順で、転送先、認証情報の差し替え、拒否するリクエスト、アクセスログの行、編集、復元、リロードを確認します。 - 変更の理由:
- 背景:プロバイダのアカウントや本物のキーを用意せず、最初の試用でモデル振り分けの用途を確認できるようにするためです。アクセスログの行では、2.xでは書けず3.0では書ける値を、手元で動かして確かめられます。
- 前の挙動を残せなかった理由:ローカルだけの試用に全インターフェースへの公開は不要です。
/helloは引き続き使えます。 - ドキュメントが示していた挙動:従来の導入ページはHelloの応答を示し、ホストのポートが広く公開されることを説明していました。
- 影響の範囲:開発版の
examples/start/を実行する利用者です。ランタイムAPIや安定版2.xの設定は変わりません。 - 必要な対応:更新した手順をローカルで実行してください。同梱のキーはデモ用で、mockの応答はLLMによる生成、プロバイダ互換性の試験、API形式の変換ではありません。この試用を公開サービスにしないでください。