Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

[bot] OpenAI legacy text completions API (`client.completions`) not instrumented

オープン
#189 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

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

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
65/100
issue の種類
機能追加
明瞭さ
明確に書かれている
活発さ
静か
技術スタック
ruby

調査の方向性

まず lib/braintrust/contrib/openai/patcher.rb にある既存の ModerationsPatcher とその instrumentation ファイルを確認し、次に対応する ruby_openai の patcher と instrumentation ディレクトリを比較してください。従来のエンドポイントの形式を確認するには、test/fixtures/vcr_cassettes/alexrudall_ruby_openai/completions.yml を使用してください。完了条件は、両方のクライアントの completion メソッドが、記載された input、metadata、output、usage metrics を使って instrumented されていることです。

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

説明

Summary

The OpenAI legacy text completions API (/v1/completions) is available in both the official openai gem and the ruby-openai gem but is not instrumented. This is the original OpenAI generation API, still used today for fine-tuned instruct models (gpt-3.5-turbo-instruct, babbage-002, davinci-002) and other text completion workflows. It is distinct from the chat completions API (/v1/chat/completions), which is already instrumented.

What is missing

Official openai gem

OpenAI::Resources::Completions exposes two generative execution methods, neither of which is patched:

  • client.completions.create(model:, prompt:, max_tokens:, temperature:, top_p:, n:, stop:, ...) — Synchronous text completion; returns a Completion object with choices[].text, usage, model, and id.
  • client.completions.create_streaming(model:, prompt:, ...) — Streaming variant; yields raw SSE chunks aggregating into the same final structure.
ruby-openai gem

OpenAI::Client exposes the equivalent via:

  • client.completions(parameters: { model:, prompt:, max_tokens:, ... }) — Calls /v1/completions directly. Accepts the same parameters as the official SDK.
What a span should capture
  • Input: the prompt (text string or array of strings/tokens)
  • Metadata: model, max_tokens, temperature, top_p, n, stop, frequency_penalty, presence_penalty, seed, logprobs, provider, endpoint (/v1/completions)
  • Output: choices[].text and finish_reason for each completion choice
  • Metrics: prompt_tokens, completion_tokens, total_tokens from the usage object; time_to_first_token

The pattern is identical to the existing ModerationsPatcher — a new CompletionsPatcher wrapping create() and create_streaming() on the respective resource class.

Braintrust docs status

not_found — The Braintrust OpenAI integration docs at https://www.braintrust.dev/docs/integrations/ai-providers/openai and the tracing guide at https://www.braintrust.dev/docs/guides/tracing focus exclusively on chat completions. The legacy /v1/completions endpoint is not mentioned.

Upstream sources

Local repo files inspected

  • lib/braintrust/contrib/openai/patcher.rb — defines ChatPatcher, ResponsesPatcher, ModerationsPatcher; no CompletionsPatcher for OpenAI::Resources::Completions
  • lib/braintrust/contrib/openai/instrumentation/ — contains chat.rb, responses.rb, moderations.rb, common.rb; no completions.rb
  • lib/braintrust/contrib/ruby_openai/patcher.rb — defines ChatPatcher, ResponsesPatcher, ModerationsPatcher; no CompletionsPatcher
  • lib/braintrust/contrib/ruby_openai/instrumentation/ — contains chat.rb, responses.rb, moderations.rb, common.rb; no completions.rb
  • test/fixtures/vcr_cassettes/alexrudall_ruby_openai/completions.yml — recorded cassette showing a POST https://api.openai.com/v1/completions call with gpt-3.5-turbo-instruct, confirming the endpoint is accessible via the ruby-openai gem
  • Grep for Completions (outside of Chat::Completions), instruct, /v1/completions across lib/braintrust/ returns zero instrumentation matches
主要言語
Ruby
スター
9
フォーク
11
平均マージ
3日 43分
マージ済み PR(30日)
9

環境構築

はじめの一歩

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

braintrustdata/braintrust-sdk-ruby のほかの issue

braintrustdata/braintrust-sdk-ruby の issue をすべて見る

似ている issue

Ruby の issue をもっと見る

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

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