This app demos a voice-controlled storytelling chatbot. It will start with the bot asking you what kind of story you'd like to hear (e.g. a fairy tale, a mystery, etc.). After each scene, the bot will pause to ask for your input. Direct the story any way you choose!
- bot server code: https://github.com/ai-bot-pro/achatbot/blob/main/src/cmd/bots/image/storytelling/daily_bot.py
- run bot api server on colab: https://github.com/weedge/doraemon-nb/blob/main/achatbot_daily_storytelling_bot.ipynb
- change
BOT_SERVICE_URL
,BOT_SERVICE_AUTH
if need auth for api edge serve env (use wrangler.toml to gen toenv.d.ts
withpnpm cf-typegen
) - cp
env.example
to.env.local
to local dev for nextjs FE page local env
First, run the development server:
npm run test
npm run dev
# or
yarn test
yarn dev
# or
pnpm test
pnpm dev
# or
bun test
bun dev
Open http://localhost:3000 with your browser to see the result.
Besides the dev
script mentioned above c3
has added a few extra scripts that allow you to integrate the application with the Cloudflare Pages environment, these are:
pages:build
to build the application for Pages using the@cloudflare/next-on-pages
CLIcf-typegen
to generate environment in env.d.ts fromwrangler.toml
vars, bings(kv,d1,r2,queue) .preview
to locally preview your Pages application using the Wrangler CLIdeploy
to deploy your Pages application using the Wrangler CLI
Note: while the
dev
script is optimal for local development you should preview your Pages application as well (periodically or before deployments) in order to make sure that it can properly work in the Pages environment (for more details see the@cloudflare/next-on-pages
recommended workflow)
Cloudflare Bindings are what allows you to interact with resources available in the Cloudflare Platform.
You can use bindings during development, when previewing locally your application and of course in the deployed application:
-
To use bindings in dev mode you need to define them in the
next.config.js
file undersetupDevBindings
, this mode uses thenext-dev
@cloudflare/next-on-pages
submodule. For more details see its documentation. -
To use bindings in the preview mode you need to add them to the
pages:preview
script accordingly to thewrangler pages dev
command. For more details see its documentation or the Pages Bindings documentation. -
To use bindings in the deployed application you will need to configure them in the Cloudflare dashboard. For more details see the Pages Bindings documentation.
c3
has added for you an example showing how you can use a KV binding.
In order to enable the example:
- Search for javascript/typescript lines containing the following comment:
and uncomment the commented lines below it.
// KV Example:
- Do the same in the
wrangler.toml
file, where the comment is:# KV Example:
- If you're using TypeScript run the
cf-typegen
script to update theenv.d.ts
file:npm run cf-typegen # or yarn cf-typegen # or pnpm cf-typegen # or bun cf-typegen
After doing this you can run the dev
or preview
script and visit the /api/hello
route to see the example in action.
Finally, if you also want to see the example work in the deployed application make sure to add a MY_KV_NAMESPACE
binding to your Pages application in its dashboard kv bindings settings section. After having configured it make sure to re-deploy your application.