-
Notifications
You must be signed in to change notification settings - Fork 4
Open
Description
Overview
Define observation type constants and attributes as the foundation for Langfuse domain models.
Context
- JS SDK defines observation types in
packages/tracing/src/types.ts(lines 12-22) - Attributes are typed as
LangfuseSpanAttributes,LangfuseGenerationAttributes, etc. - Ruby equivalent should use classes/modules for type safety
Technical Implementation
Create lib/langfuse/types.rb with:
Observation Type Constants
module Langfuse
module Types
OBSERVATION_TYPES = %w[
span generation event embedding
agent tool chain retriever
evaluator guardrail
].freeze
LEVELS = %w[DEBUG DEFAULT WARNING ERROR].freeze
end
endAttribute Classes
Base SpanAttributes:
input,output,metadata,levelstatus_message,version,environment#initialize(**kwargs)for keyword arg initialization#to_hfor hash representation
GenerationAttributes (extends SpanAttributes):
- Additional:
completion_start_time,model,model_parameters usage_details,cost_details,prompt- Prompt should be hash:
{ name:, version:, is_fallback: }
EmbeddingAttributes (extends GenerationAttributes)
TraceAttributes:
name,user_id,session_id,version,releaseinput,output,metadata,tags,public,environment- Same initialization pattern
Aliases for Span-like Types
EventAttributes = SpanAttributes
AgentAttributes = SpanAttributes
ToolAttributes = SpanAttributes
ChainAttributes = SpanAttributes
RetrieverAttributes = SpanAttributes
EvaluatorAttributes = SpanAttributes
GuardrailAttributes = SpanAttributesAcceptance Criteria
-
Langfuse::Types::OBSERVATION_TYPEScontains all 10 types -
Langfuse::Types::SpanAttributescan be instantiated with keyword args -
Langfuse::Types::GenerationAttributesextendsSpanAttributes -
#to_hreturns hash representation of attributes - All attribute classes documented with YARD
- Unit tests for each attribute class
Files to Create
lib/langfuse/types.rb- Type definitionsspec/langfuse/types_spec.rb- Tests
Dependencies
None
Metadata
Metadata
Assignees
Labels
No labels