Class: Verica::OpenAIWrapper
- Inherits:
-
Object
- Object
- Verica::OpenAIWrapper
- Defined in:
- lib/verica/openai_wrapper.rb
Overview
The official openai gem has no auto-instrumentation, so Verica ships its
own thin decorator: everything delegates to the real client; only
chat.completions.create is intercepted to emit ONE gen_ai.* span (pinned
semconv, the exact attributes the Verica normalizer accepts). Fail-open:
instrumentation errors never reach the caller; provider errors always do.
Defined Under Namespace
Classes: ChatProxy, CompletionsProxy
Instance Method Summary collapse
- #chat ⇒ Object
-
#initialize(client) ⇒ OpenAIWrapper
constructor
A new instance of OpenAIWrapper.
- #method_missing(name) ⇒ Object
- #respond_to_missing?(name, include_private = false) ⇒ Boolean
Constructor Details
#initialize(client) ⇒ OpenAIWrapper
Returns a new instance of OpenAIWrapper.
12 13 14 |
# File 'lib/verica/openai_wrapper.rb', line 12 def initialize(client) @client = client end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name) ⇒ Object
20 21 22 |
# File 'lib/verica/openai_wrapper.rb', line 20 def method_missing(name, ...) @client.public_send(name, ...) end |
Instance Method Details
#chat ⇒ Object
16 17 18 |
# File 'lib/verica/openai_wrapper.rb', line 16 def chat ChatProxy.new(@client.chat) end |
#respond_to_missing?(name, include_private = false) ⇒ Boolean
24 25 26 |
# File 'lib/verica/openai_wrapper.rb', line 24 def respond_to_missing?(name, include_private = false) @client.respond_to?(name, include_private) || super end |