Module: Datadog::AIGuard::Contrib::RubyLLM::ChatInstrumentation
- Defined in:
- lib/datadog/ai_guard/contrib/ruby_llm/chat_instrumentation.rb
Overview
module that gets prepended to RubyLLM::Chat
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.evaluate!(messages) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/datadog/ai_guard/contrib/ruby_llm/chat_instrumentation.rb', line 10 def evaluate!() = .flat_map do || if .tool_call? .tool_calls.map do |tool_call_id, tool_call| AIGuard.assistant(id: tool_call_id, tool_name: tool_call.name, arguments: tool_call.arguments.to_s) end elsif .tool_result? AIGuard.tool(tool_call_id: .tool_call_id, content: .content) else AIGuard.(role: .role, content: .content) end end AIGuard.evaluate(*, allow_raise: true) end |
Instance Method Details
#complete(&block) ⇒ Object
27 28 29 30 31 |
# File 'lib/datadog/ai_guard/contrib/ruby_llm/chat_instrumentation.rb', line 27 def complete(&block) Datadog::AIGuard::Contrib::RubyLLM::ChatInstrumentation.evaluate!() super end |
#handle_tool_calls(response, &block) ⇒ Object
33 34 35 36 37 |
# File 'lib/datadog/ai_guard/contrib/ruby_llm/chat_instrumentation.rb', line 33 def handle_tool_calls(response, &block) Datadog::AIGuard::Contrib::RubyLLM::ChatInstrumentation.evaluate!() super end |