Module: DSPy
- Extended by:
- Dry::Configurable
- Defined in:
- lib/dspy/prediction.rb,
lib/dspy.rb,
lib/dspy/lm.rb,
lib/dspy/field.rb,
lib/dspy/image.rb,
lib/dspy/tools.rb,
lib/dspy/errors.rb,
lib/dspy/memory.rb,
lib/dspy/module.rb,
lib/dspy/prompt.rb,
lib/dspy/re_act.rb,
lib/dspy/example.rb,
lib/dspy/predict.rb,
lib/dspy/version.rb,
lib/dspy/code_act.rb,
lib/dspy/evaluate.rb,
lib/dspy/lm/usage.rb,
lib/dspy/strategy.rb,
lib/dspy/lm/errors.rb,
lib/dspy/signature.rb,
lib/dspy/lm/adapter.rb,
lib/dspy/lm/message.rb,
lib/dspy/tools/base.rb,
lib/dspy/lm/response.rb,
lib/dspy/tools/toolset.rb,
lib/dspy/instrumentation.rb,
lib/dspy/schema_adapters.rb,
lib/dspy/type_serializer.rb,
lib/dspy/chain_of_thought.rb,
lib/dspy/few_shot_example.rb,
lib/dspy/lm/cache_manager.rb,
lib/dspy/lm/retry_handler.rb,
lib/dspy/lm/vision_models.rb,
lib/dspy/teleprompt/utils.rb,
lib/dspy/lm/adapter_factory.rb,
lib/dspy/lm/message_builder.rb,
lib/dspy/memory/memory_store.rb,
lib/dspy/teleprompt/mipro_v2.rb,
lib/dspy/lm/strategy_selector.rb,
lib/dspy/memory/memory_record.rb,
lib/dspy/mixins/type_coercion.rb,
lib/dspy/tools/memory_toolset.rb,
lib/dspy/memory/memory_manager.rb,
lib/dspy/mixins/struct_builder.rb,
lib/dspy/memory/in_memory_store.rb,
lib/dspy/memory/embedding_engine.rb,
lib/dspy/memory/memory_compactor.rb,
lib/dspy/storage/program_storage.rb,
lib/dspy/storage/storage_manager.rb,
lib/dspy/teleprompt/data_handler.rb,
lib/dspy/teleprompt/teleprompter.rb,
lib/dspy/propose/grounded_proposer.rb,
lib/dspy/registry/registry_manager.rb,
lib/dspy/lm/adapters/ollama_adapter.rb,
lib/dspy/lm/adapters/openai_adapter.rb,
lib/dspy/lm/strategies/base_strategy.rb,
lib/dspy/registry/signature_registry.rb,
lib/dspy/subscribers/otel_subscriber.rb,
lib/dspy/teleprompt/simple_optimizer.rb,
lib/dspy/instrumentation/token_tracker.rb,
lib/dspy/lm/adapters/anthropic_adapter.rb,
lib/dspy/lm/structured_output_strategy.rb,
lib/dspy/memory/local_embedding_engine.rb,
lib/dspy/subscribers/logger_subscriber.rb,
lib/dspy/tools/text_processing_toolset.rb,
lib/dspy/instrumentation/event_payloads.rb,
lib/dspy/mixins/instrumentation_helpers.rb,
lib/dspy/subscribers/langfuse_subscriber.rb,
lib/dspy/subscribers/newrelic_subscriber.rb,
lib/dspy/lm/adapters/openai/schema_converter.rb,
lib/dspy/instrumentation/event_payload_factory.rb,
lib/dspy/lm/strategies/anthropic_tool_use_strategy.rb,
lib/dspy/lm/strategies/enhanced_prompting_strategy.rb,
lib/dspy/lm/strategies/anthropic_extraction_strategy.rb,
lib/dspy/lm/strategies/openai_structured_output_strategy.rb
Overview
typed: strict frozen_string_literal: true
Defined Under Namespace
Modules: Instrumentation, Memory, Metrics, Mixins, Propose, Registry, SchemaAdapters, Storage, Subscribers, Teleprompt, Tools Classes: ChainOfThought, CodeAct, CodeActHistoryEntry, CodeActNextStep, ConfigurationError, DeserializationError, Error, Evaluate, Example, FewShotExample, HistoryEntry, Image, InputField, LM, Module, NextStep, OutputField, Predict, Prediction, PredictionInvalidError, Prompt, ReAct, ReActObservationBase, RubyCodeGeneration, RubyCodeObservation, Signature, Strategy, ThoughtBase, TimestampFormat, TypeSerializer, ValidationError
Constant Summary collapse
- VERSION =
"0.17.0"
Class Method Summary collapse
- .logger ⇒ Object
-
.validate_instrumentation! ⇒ Object
Validation methods for instrumentation configuration.
Class Method Details
.logger ⇒ Object
95 96 97 |
# File 'lib/dspy.rb', line 95 def self.logger config.logger end |
.validate_instrumentation! ⇒ Object
Validation methods for instrumentation configuration
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/dspy.rb', line 100 def self.validate_instrumentation! config = self.config.instrumentation raise ArgumentError, "Sampling rate must be between 0.0 and 1.0" unless config.sampling_rate.between?(0.0, 1.0) raise ArgumentError, "Buffer size must be positive" unless config.buffer_size > 0 raise ArgumentError, "Flush interval must be positive" unless config.flush_interval > 0 raise ArgumentError, "Invalid timestamp format" unless config..is_a?(TimestampFormat) if config.enabled && config.subscribers.empty? raise ArgumentError, "Must specify at least one subscriber when instrumentation is enabled" end # Validate subscribers are valid symbols invalid_subscribers = config.subscribers - [:logger, :otel, :newrelic, :langfuse] unless invalid_subscribers.empty? raise ArgumentError, "Invalid subscribers: #{invalid_subscribers.join(', ')}" end end |