-
Notifications
You must be signed in to change notification settings - Fork 51
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
Add CloudFlare models helper #161
Comments
Thanks for creating ellmer. I am trying to use the Cloudflare Workers AI Models but couldn't figure out how to configure
This is what I tried with ellmer:
Is it possible to use |
From OpenAI compatible API endpoints · Cloudflare Workers AI docs, it looks like the endpoint for the OpenAI compatible API is It almost works, but it looks like Cloudflare omits the library(ellmer)
base_url = "https://api.cloudflare.com/client/v4/accounts/"
model = "@cf/meta/llama-3.3-70b-instruct-fp8-fast"
chat <- chat_openai(
base_url = paste0(base_url, Sys.getenv("CLOUDFLARE_ACCOUNT_ID"), "/ai/v1/"),
api_key = Sys.getenv("CLOUDFLARE_API_KEY"),
model = model
)
chat$chat("Write a haiku about pizza")
#> Melty cheesy bliss
#> Flavors dancing on my tongue
#> Pizza's sweet
#> Error: <ellmer::Turn> object properties are invalid:
#> - @role must be <character>, not <NULL> Btw, I created an account following these instructions and was able to run the above on the free tier. |
@hadley what do you think about using Line 207 in b692a7d
A very simple fix for this case is - Turn(message$role, content, json = result, tokens = tokens)
+ Turn(message$role %||% "assistant", content, json = result, tokens = tokens) but maybe that's a generally reasonable assumption that could be made in |
@gadenbuie yeah, I think it's fine to fix that in If you do make that fix, it would be worth taking a look to see if other |
(I think it's still worth having a |
https://developers.cloudflare.com/workers-ai/models/
The text was updated successfully, but these errors were encountered: