Skip to content

[pull] main from crmne:main #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 411 commits into
base: main
Choose a base branch
from
Open

[pull] main from crmne:main #3

wants to merge 411 commits into from

Conversation

pull[bot]
Copy link

@pull pull bot commented Mar 22, 2025

See Commits and Changes for more details.


Created by pull[bot] (v2.0.0-alpha.1)

Can you help keep this open source service alive? 💖 Please sponsor : )

@pull pull bot added the ⤵️ pull label Mar 22, 2025
crmne and others added 29 commits May 14, 2025 18:12
Replacing instructions for a chat with no prior instructions leads to
`@messages` being assigned to `nil`. To prevent this from happening, use
`reject` instead to ensure an array is always present.

Here is an example of this error:
```
irb(main):007> chat = RubyLLM::Chat.new
=>
#<RubyLLM::Chat:0x000000012bd30d70
...
irb(main):008> chat.with_instructions("You are a good assistant", replace: true)
/opt/homebrew/lib/ruby/gems/3.4.0/gems/ruby_llm-1.3.0rc1/lib/ruby_llm/chat.rb:109:in 'RubyLLM::Chat#add_message': undefined method '<<' for nil (NoMethodError)

      messages << message
               ^^
        from /opt/homebrew/lib/ruby/gems/3.4.0/gems/ruby_llm-1.3.0rc1/lib/ruby_llm/chat.rb:44:in 'RubyLLM::Chat#with_instructions'
        from (irb):8:in '<main>'
        from <internal:kernel>:168:in 'Kernel#loop'
        from /opt/homebrew/Cellar/ruby/3.4.3/lib/ruby/gems/3.4.0/gems/irb-1.14.3/exe/irb:9:in '<top (required)>'
        from /opt/homebrew/opt/ruby/bin/irb:25:in 'Kernel#load'
        from /opt/homebrew/opt/ruby/bin/irb:25:in '<main>'
irb(main):009>
```

Co-authored-by: Carmine Paolino <carmine@paolino.me>
New extension to the API:

Now you can pass a location and a mime_type if we're not able to determine the MIME type for the file from the extension.

e.g.
RubyLLM.chat.ask "what's this?", with: [{ location: "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQzSCawxoHrVtf9AX-o7bp7KVxcmkYWzsIjng&s", mime_type: "image/jpeg" }]

I also introduce a new MissingExtensionError for when we can't determine the MIME type and the user didn't provide one.
- Updated media.rb files for Anthropic, Bedrock, Gemini, Ollama, and OpenAI to use attachment types instead of classes for better clarity and maintainability.
- Enhanced error handling to raise UnsupportedAttachmentError with attachment type.
- Modified format_text_file_for_llm to include mime_type in the output.
- Added 'marcel' gem dependency for improved file type detection.
- Updated chat_content_spec to verify attachment filename and mime_type for various content types, ensuring accurate handling of remote and local files.
- Removed redundant tests and improved error handling for missing extensions and bad URLs.
# Description

In reference to issue: #172 -
this CR exists to allow for applications requiring different, lower
Faraday versions to integrate with this Gem.

# Changes Made

1. Updated the gemspec for Faraday and its dependencies to allow use of
lower versions in case of a conflict.
2. Updated CICD.yml workflow to validate that lower Faraday versions
work.
3. Specs failed on lower Faraday versions so I updated
`lib/ruby_llm/streaming.rb` to allow for legacy Faraday versions to
stream responses as well. Could use feedback definitely in case this
breaks logic in a way you all are uncomfy with.

# Testing

I ran manually rspec with Faraday Version 2.13.1 and 1.10.3, here are
the results prior to CI/CD integration in this repo:

| Faraday Version   |    Validate Gem Install        |  Test Results |
|----------|:-------------:|------:|
| 1.10.3 | ![Screenshot 2025-05-14 at 12 52
57 PM](https://github.com/user-attachments/assets/5233a968-c37f-4de3-9ef0-bdaad17a3a2e)
| ![Screenshot 2025-05-14 at 12 53
03 PM](https://github.com/user-attachments/assets/b21f830f-732a-4aef-94fa-5db07a2be8f8)
|
| 2.13.1 | ![Screenshot 2025-05-14 at 12 52
39 PM](https://github.com/user-attachments/assets/78c81a09-0bed-4f10-bc72-c8e76d16df08)
| ![Screenshot 2025-05-14 at 12 52
46 PM](https://github.com/user-attachments/assets/ded40e55-7296-49a8-b4c8-b11a49ad6726)
|
implement proxy setup in Connection

---------

Co-authored-by: jeff.dean <jeff.dean@kakaomobility.com>
Co-authored-by: Carmine Paolino <carmine@paolino.me>
crmne and others added 30 commits August 13, 2025 11:39
## What this does

Hello, thanks for your work on this library

This is my first contribution here. I think that adding RuboCop
Performance plugin this can benefit on the long term

Each offense has been fixed in an individual commit, with explanation
and benchmarks, where possible.

Some cops have been temporarily disabled because they can break API

## Type of change

- [ ] Bug fix
- [ ] New feature
- [ ] Breaking change ⚠️ ⚠️ ⚠️  **not at the best of my knowledge**
- [ ] Documentation
- [x] Performance improvement

## Scope check

- [x] I read the [Contributing
Guide](https://github.com/crmne/ruby_llm/blob/main/CONTRIBUTING.md)
- [x] This aligns with RubyLLM's focus on **LLM communication**
- [x] This isn't application-specific logic that belongs in user code
- [x] This benefits most users, not just my specific use case

## Quality check

- [x] I ran `overcommit --install` and all hooks pass
- [x] I tested my changes thoroughly
- [x] ~I updated documentation if needed~
- [x] I didn't modify auto-generated files manually (`models.json`,
`aliases.json`)

## API changes

- [ ] Breaking change
- [ ] New public methods/classes
- [ ] Changed method signatures
- [x] No API changes

## Related issues

<!-- Link issues: "Fixes #123" or "Related to #123" -->
Since we no longer gatekeep capabilities and let providers validate their own features, the logging about assuming model existence is unnecessary.
Tools can now return RubyLLM::Content objects with file attachments,
allowing multimodal responses from tool executions. Previously tool
results were always converted to strings.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet