-
Notifications
You must be signed in to change notification settings - Fork 29
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
feat(contents_text): Add contents_*()
helper functions
#170
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems like a reasonable idea and implementation to me. You just need to fix the build failure and add some basic tests.
#' contents_html(turns[[1]]) | ||
#' } | ||
#' | ||
#' @param content The [Turn] or [Content] object to be converted into text. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you pass turns?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just added a method for contents_markdown()
for Chat
instances. I see a lot of utility in that particular output format and less utility in the HTML or text variants. That said I'd be happy to add those if you want.
turns <- list(
user_turn("What's this image?", content_image_url("https://placehold.co/200x200")),
Turn("assistant", "It's a placeholder image.")
)
chat <- Chat$new(Provider("https://example.com"), turns = turns)
cat(contents_markdown(chat))
#> ## User
#>
#> What's this image?
#>
#> ![](https://placehold.co/200x200)
#>
#> ## Assistant
#>
#> It's a placeholder image.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Related: is there a way to create a chat_echo()
(or maybe chat_repeater()
) chat instance that just returns the user input and doesn't call any APIs? Carson made an example like this for Shiny and I've found it to be very useful for debugging and examples when I'm not ready for real model usage yet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that would be pretty straightforward with a new provider.
@hadley this is ready for another look. Sorry for the commit noise, I only just now realized I wasn't able to run checks locally because I had out-of-date credentials. Of course when I finally got to ✅ in the last commit there was an unrelated CI failure and I can't request a rerun. |
I love this idea in general, but also had a couple thoughts on this PR:
|
Fixes #167
Adds
contents_text()
,contents_markdown()
andcontents_html()
generics that can be applied toTurn
andContent
objects.