Skip to content

Conversation

@dimroc
Copy link

@dimroc dimroc commented Jun 26, 2025

Currently, the quickstart example errors because the CoT original_signature remains a string rather than a Signature instance.

 result = cot.call(question: "Two dice are tossed. What is the probability that the sum equals two?")
[Desiru] 2025-06-26 11:07:40 -0700: WARN -- Retrying module execution (attempt 1/3)
[Desiru] 2025-06-26 11:07:41 -0700: WARN -- Retrying module execution (attempt 2/3)
[Desiru] 2025-06-26 11:07:42 -0700: WARN -- Retrying module execution (attempt 3/3)
[Desiru] 2025-06-26 11:07:43 -0700: ERROR -- Module execution failed: undefined method 'output_fields' for an instance of String
(ponds):2:in '<main>': Module execution failed: undefined method 'output_fields' for an instance of String (Desiru::ModuleError)
/Users/dimroc/.gem/ruby/3.4.2/bundler/gems/desiru-b5b302af0e3b/lib/desiru/modules/chain_of_thought.rb:26:in 'Desiru::Modules::ChainOfThought#build_system_prompt': undefined method 'output_fields' for an instance of String (NoMethodError)

          #{@original_signature.output_fields.keys.map { |field| "#{field}: Your #{field} here" }.join("\n")}
                               ^^^^^^^^^^^^^^
        from /Users/dimroc/.gem/ruby/3.4.2/bundler/gems/desiru-b5b302af0e3b/lib/desiru/modules/predict.rb:33:in 'Desiru::Modules::Predict#build_prompt'
        from /Users/dimroc/.gem/ruby/3.4.2/bundler/gems/desiru-b5b302af0e3b/lib/desiru/modules/predict.rb:15:in 'Desiru::Modules::Predict#forward'
        from /Users/dimroc/.gem/ruby/3.4.2/bundler/gems/desiru-b5b302af0e3b/lib/desiru/module.rb:50:in 'Desiru::Module#call'
        from /Users/dimroc/.gem/ruby/3.4.2/bundler/gems/desiru-b5b302af0e3b/lib/desiru/core/traceable.rb:20:in 'Desiru::Core::Traceable#call'

This PR ensures the ChainOfThought#original_signature becomes a Signature instance. To implement this, there were a few liberties taken:

  1. DRY'd up the signature wrapping into Signature.wrap
  2. Made ChainOfThought#original_signature a public attr_reader for easier access and testability, mimicing Module#signature.

Testing details and red, green refactor

Screenshot 2025-06-26 at 11 02 18 AM

Original error:

Screenshot 2025-06-26 at 10 44 47 AM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant