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/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/observability.rb,
lib/dspy/tools/toolset.rb,
lib/dspy/error_formatter.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/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/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/openai_structured_output_strategy.rb
Overview
typed: strict frozen_string_literal: true
Defined Under Namespace
Modules: Memory, Metrics, Mixins, Propose, Registry, SchemaAdapters, Storage, Teleprompt, Tools
Classes: ChainOfThought, CodeAct, CodeActHistoryEntry, CodeActNextStep, ConfigurationError, Context, DeserializationError, Error, ErrorFormatter, Evaluate, 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.19.0"
Class Method Summary
collapse
Class Method Details
.create_logger ⇒ 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
|
# File 'lib/dspy.rb', line 49
def self.create_logger
env = ENV['RACK_ENV'] || ENV['RAILS_ENV'] || 'development'
log_output = ENV['DSPY_LOG']
case env
when 'test'
Dry.Logger(:dspy, formatter: :string) do |config|
config.add_backend(stream: log_output || "log/test.log")
end
when 'development'
Dry.Logger(:dspy, formatter: :string) do |config|
config.add_backend(stream: log_output || "log/development.log")
end
when 'production', 'staging'
Dry.Logger(:dspy, formatter: :json) do |config|
config.add_backend(stream: log_output || $stdout)
end
else
Dry.Logger(:dspy, formatter: :string) do |config|
config.add_backend(stream: log_output || $stdout)
end
end
end
|
.log(event, **attributes) ⇒ Object
36
37
38
39
40
41
42
43
44
45
46
47
|
# File 'lib/dspy.rb', line 36
def self.log(event, **attributes)
return unless logger
context = Context.current.dup
context.delete(:span_stack)
attributes = context.merge(attributes)
attributes[:event] = event
logger.info(attributes)
end
|
.logger ⇒ Object
32
33
34
|
# File 'lib/dspy.rb', line 32
def self.logger
@logger ||= create_logger
end
|