Module: Langchain::Datadog::Vectorsearch
- Includes:
- Tracing
- Defined in:
- lib/langchain/datadog/vectorsearch.rb
Overview
Implements hooks for Langchain::Vectorsearch module classes to capture LLM calls and report them to the Datadog LLM Observability API.
Constant Summary collapse
- VECTOR_ATTRIBUTES =
List of various attributes that store vectors.
%w[embedding vector input_vector values].freeze
Instance Method Summary collapse
- #add_texts ⇒ Object
- #ask(question:) ⇒ Object
- #similarity_search(query:) ⇒ Object
- #similarity_search_with_hyde(query:) ⇒ Object
- #update_texts ⇒ Object
Methods included from Tracing
active_parent_id, active_span_id, active_trace_id, agent, end_span, start_span, workflow
Instance Method Details
#add_texts ⇒ Object
13 14 15 16 17 |
# File 'lib/langchain/datadog/vectorsearch.rb', line 13 def add_texts(...) return super unless Datadog.enabled? span(kind: 'workflow') { super } end |
#ask(question:) ⇒ Object
49 50 51 52 53 54 55 |
# File 'lib/langchain/datadog/vectorsearch.rb', line 49 def ask(question:, **) return super unless Datadog.enabled? parameters = { question: } span(parameters, kind: 'workflow') { super } end |
#similarity_search(query:) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/langchain/datadog/vectorsearch.rb', line 25 def similarity_search(query:, **) return super unless Datadog.enabled? parameters = { query: } # Retrieval is not a valid root span kind, therefore when called # directly it's wrapped in a workflow span. if Tracing.active_parent_id == 'undefined' return span(parameters, kind: 'workflow') do span(parameters) { super } end end span(parameters) { super } end |