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/events.rb,
lib/dspy/memory.rb,
lib/dspy/module.rb,
lib/dspy/prompt.rb,
lib/dspy/re_act.rb,
lib/dspy/context.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/events/types.rb,
lib/dspy/observability.rb,
lib/dspy/tools/toolset.rb,
lib/dspy/error_formatter.rb,
lib/dspy/schema_adapters.rb,
lib/dspy/teleprompt/gepa.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/events/subscribers.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/utils/serialization.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/events/subscriber_mixin.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/gemini_adapter.rb,
lib/dspy/lm/adapters/ollama_adapter.rb,
lib/dspy/lm/adapters/openai_adapter.rb,
lib/dspy/lm/strategies/base_strategy.rb,
lib/dspy/optimizers/gaussian_process.rb,
lib/dspy/registry/signature_registry.rb,
lib/dspy/teleprompt/simple_optimizer.rb,
lib/dspy/lm/adapters/anthropic_adapter.rb,
lib/dspy/lm/structured_output_strategy.rb,
lib/dspy/memory/local_embedding_engine.rb,
lib/dspy/tools/text_processing_toolset.rb,
lib/dspy/observability/async_span_processor.rb,
lib/dspy/lm/adapters/gemini/schema_converter.rb,
lib/dspy/lm/adapters/openai/schema_converter.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/gemini_structured_output_strategy.rb,
lib/dspy/lm/strategies/openai_structured_output_strategy.rb
Overview
typed: strict frozen_string_literal: true
Defined Under Namespace
Modules: Events, Memory, Metrics, Mixins, Optimizers, Propose, Registry, SchemaAdapters, Storage, Teleprompt, Tools, Utils
Classes: ChainOfThought, CodeAct, CodeActHistoryEntry, CodeActNextStep, ConfigurationError, Context, DeserializationError, Error, ErrorFormatter, Evaluate, EventRegistry, Example, FewShotExample, HistoryEntry, Image, InputField, LM, Module, NextStep, Observability, OutputField, Predict, Prediction, PredictionInvalidError, Prompt, ReAct, ReActObservationBase, RubyCodeGeneration, RubyCodeObservation, Signature, Strategy, ThoughtBase, TypeSerializer, ValidationError
Constant Summary
collapse
- VERSION =
"0.27.0"
Class Method Summary
collapse
Class Method Details
.event(event_name_or_object, attributes = {}) ⇒ Object
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
# File 'lib/dspy.rb', line 49
def self.event(event_name_or_object, attributes = {})
if event_name_or_object.respond_to?(:name) && event_name_or_object.respond_to?(:to_attributes)
event_obj = event_name_or_object
event_name = event_obj.name
attributes = event_obj.to_attributes
if event_obj.is_a?(DSPy::Events::LLMEvent)
otel_attributes = event_obj.to_otel_attributes
create_event_span(event_name, otel_attributes)
else
create_event_span(event_name, attributes)
end
else
event_name = event_name_or_object
raise ArgumentError, "Event name cannot be nil" if event_name.nil?
attributes = {} if attributes.nil?
create_event_span(event_name, attributes)
end
events.notify(event_name, attributes)
end
|
.events ⇒ Object
82
83
84
85
86
87
88
89
90
|
# File 'lib/dspy.rb', line 82
def self.events
@event_registry ||= DSPy::EventRegistry.new.tap do |registry|
registry.subscribe('*') { |event_name, attributes|
emit_log(event_name, attributes) if logger
}
end
end
|
.log(event_name, **attributes) ⇒ Object
38
39
40
41
42
43
44
45
46
47
|
# File 'lib/dspy.rb', line 38
def self.log(event_name, **attributes)
return nil unless logger
emit_log(event_name, attributes)
nil
end
|
.logger ⇒ Object
34
35
36
|
# File 'lib/dspy.rb', line 34
def self.logger
@logger ||= create_logger
end
|