Skip to content

fix: allow leading '@' in model IDs for Cloudflare Workers AI#318

Open
Himanshu Kumar (himanshu231204) wants to merge 1 commit into
langchain-ai:mainfrom
himanshu231204:fix/cloudflare-model-id-validation
Open

fix: allow leading '@' in model IDs for Cloudflare Workers AI#318
Himanshu Kumar (himanshu231204) wants to merge 1 commit into
langchain-ai:mainfrom
himanshu231204:fix/cloudflare-model-id-validation

Conversation

@himanshu231204

Copy link
Copy Markdown
Contributor

Summary

The isValidModelId regex in src/constants.ts requires the first character to be alphanumeric, which rejects all Cloudflare Workers AI model IDs (e.g. @cf/meta/llama-3-8b-instruct). This makes Workers AI unusable as an openai-compatible backend.

Fix

One-character change to the regex — add @ to the allowed first character set:

`diff

  • /^[A-Za-z0-9][A-Za-z0-9._:/+-]*$/u

Changes

  • src/constants.ts: Updated regex to accept @ as a valid first character
  • est/constants.test.ts: Added test cases for Cloudflare Workers AI model IDs

Testing

All 26 tests pass (including 3 new ones for @cf/... model IDs).

Fixes #315

cc Colin Francis (@colifran)

The isValidModelId regex required the first character to be alphanumeric,
rejecting Cloudflare Workers AI model IDs like @cf/meta/llama-3-8b-instruct.
Add '@' to the allowed first character set.

Fixes langchain-ai#315
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.

[Bug]: isValidModelId rejects all Cloudflare Workers AI model IDs (leading "@" in "@cf/...")

1 participant