Skip to content
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

Cloudflare Worker integration test suite #215

Merged
merged 2 commits into from
Mar 7, 2024
Merged

Conversation

aron
Copy link
Contributor

@aron aron commented Mar 7, 2024

This is currently failing but acts as a starting point for verifying that we can run the Replicate library on Cloudflare workers.

The test uses a simple Cloudflare Worker implementation that uses the streaming API (as this exercises a bunch of the API surface area) to stream back a response from a language model and uses the experimental unstable_dev functionality in the wrangler library to run the worker via workerd in a test. We then verify that the test receives a successful response.

Currently we have the following issues:

  • node:crypto needs to be replaced with web crypto (node >= 15).
  • replace Buffer with Blob where possible or abstract behind a conditional.
  • process.env also needs to be accessed behind a conditional.

This is currently failing but acts as a starting point for verifying that
we can run the Replicate library on Cloudflare workers.

The test creates a cloudflare worker that uses the streaming API (as this
exercises a bunch of the API surface area) and uses the experimental
unstable_dev library to run the worker in a test. We then verify that
the test receives a successful response.

Currently we have the following issues:

* `node:crypto` needs to be replaced with web crypto (node >= 15).
* replace Buffer with Blob where possible or abstract behind a conditional.
* `process.env` also needs to be accessed behind a conditional.
Copy link
Member

@mattt mattt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is awesome, @aron! Really glad to have test coverage for Cloudflare Workers.

integration/cloudflare-worker/index.test.js Outdated Show resolved Hide resolved
Co-authored-by: Mattt <mattt@replicate.com>
@aron aron merged commit 91a35e5 into main Mar 7, 2024
3 checks passed
@aron aron deleted the cloudflare-integration branch March 7, 2024 13:31
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.

None yet

2 participants