guidance-ai / guidance

A guidance language for controlling large language models.
MIT License
18.13k stars 1.01k forks source link

Fix regex for urls in image function #928

Open kklemon opened 1 week ago

kklemon commented 1 week ago

The regex for matching urls in the image function starts with a $ character (ref), i.e. the "match end of string"-metacharacter, which seems to be wrong. I guess the intention was to match against the start of the string, which could be achieved with a ^ character, but since re.match matches against the start of a string already, this can also be omitted in this specific case.

This led to the situation that urls are generally not recognized and can't be used with the image function. This PR attempts to fix this issue by modifying the aforementioned regex and additionally providing tests for the _image module to prevent such problems in the future.

riedgar-ms commented 6 days ago

Tag @nking-1

codecov-commenter commented 6 days ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 59.26%. Comparing base (ba86754) to head (dea02aa).

:exclamation: Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #928 +/- ## ========================================== + Coverage 57.18% 59.26% +2.08% ========================================== Files 64 64 Lines 4711 4711 ========================================== + Hits 2694 2792 +98 + Misses 2017 1919 -98 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.