https://github.com/yusukebe/get-platform-proxy-cloudflare-ai
https://github.com/yusukebe/get-platform-proxy-cloudflare-ai
Last synced: about 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/yusukebe/get-platform-proxy-cloudflare-ai
- Owner: yusukebe
- Created: 2024-02-16T09:57:07.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-02-16T09:59:15.000Z (over 2 years ago)
- Last Synced: 2025-03-29T06:42:25.078Z (about 1 year ago)
- Language: TypeScript
- Size: 20.5 KB
- Stars: 7
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# `getPlatformProxy()` + `@cloudflare/ai`
Error when using `getPlatformProxy()` and `@cloudflare/ai` together.
## How to reproduce
1. Clone this repository.
2. `npm i`
3. `npm run start`
## Error message
```
$ tsx src/index.mts
/Users/yusuke/work/c/fetch-duplex/node_modules/wrangler/wrangler-dist/cli.js:29572
throw a;
^
TypeError: RequestInit: duplex option is required when sending a body.
at new Request (/Users/yusuke/work/c/fetch-duplex/node_modules/undici/lib/fetch/request.js:491:15)
at Request (/Users/yusuke/work/c/fetch-duplex/node_modules/miniflare/src/http/request.ts:34:3)
at ProxyStubHandler.#fetcherFetchCall (/Users/yusuke/work/c/fetch-duplex/node_modules/miniflare/src/plugins/core/proxy/client.ts:594:19)
at ProxyStubHandler.#call (/Users/yusuke/work/c/fetch-duplex/node_modules/miniflare/src/plugins/core/proxy/client.ts:501:52)
at Proxy.fetch (/Users/yusuke/work/c/fetch-duplex/node_modules/miniflare/src/plugins/core/proxy/client.ts:484:25)
at InferenceSession.run (/Users/yusuke/work/c/fetch-duplex/node_modules/@cloudflare/ai/src/session.ts:72:28)
at Ai.run (/Users/yusuke/work/c/fetch-duplex/node_modules/@cloudflare/ai/src/ai.ts:113:44)
at (/Users/yusuke/work/c/fetch-duplex/src/index.mts:7:25)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
Node.js v20.10.0
error Command failed with exit code 7.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
```
## Work-around
Adding `duplex:'half'` to fetch option in the `@cloudflare/ai` solves the problem.