mirror of
https://github.com/vercel-labs/fx.git
synced 2026-10-28 10:15:17 +08:00
Move the libfx cookbook into examples
This commit is contained in:
33 files changed
+23
-23
No files matched your search
@@ -1,15 +1,15 @@
|
||||
name: Cookbook
|
||||
name: Examples
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
paths:
|
||||
- 'cookbook/**'
|
||||
- '.github/workflows/cookbook.yml'
|
||||
- 'examples/**'
|
||||
- '.github/workflows/examples.yml'
|
||||
push:
|
||||
branches: [main]
|
||||
paths:
|
||||
- 'cookbook/**'
|
||||
- '.github/workflows/cookbook.yml'
|
||||
- 'examples/**'
|
||||
- '.github/workflows/examples.yml'
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
@@ -22,14 +22,14 @@ jobs:
|
||||
example: [node-chat, browser-agent, nextjs-agent, nuxt-agent]
|
||||
defaults:
|
||||
run:
|
||||
working-directory: cookbook/${{ matrix.example }}
|
||||
working-directory: examples/${{ matrix.example }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 24
|
||||
cache: npm
|
||||
cache-dependency-path: cookbook/${{ matrix.example }}/package-lock.json
|
||||
cache-dependency-path: examples/${{ matrix.example }}/package-lock.json
|
||||
- run: npm ci
|
||||
- if: matrix.example == 'node-chat'
|
||||
run: node --test ../shared/*.test.mjs
|
||||
@@ -169,7 +169,7 @@ fx builds as a native binary or WebAssembly. Applications embedding fx can provi
|
||||
|
||||
The WebAssembly SDK is experimental. See the [WebAssembly SDK](sdk/README.md) and [ACP documentation](https://fx.sh/docs/using-fx/acp).
|
||||
|
||||
For runnable Node.js, browser, Next.js, and Nuxt applications, see the [libfx cookbook](cookbook/README.md).
|
||||
For runnable Node.js, browser, Next.js, and Nuxt applications, see the [libfx examples](examples/README.md).
|
||||
|
||||
## Extend fx
|
||||
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
import { fileURLToPath } from 'node:url'
|
||||
|
||||
const cookbook = fileURLToPath(new URL('..', import.meta.url))
|
||||
export default {
|
||||
turbopack: { root: cookbook },
|
||||
outputFileTracingRoot: cookbook,
|
||||
}
|
||||
File renamed without changes.
@@ -1,4 +1,4 @@
|
||||
# libfx cookbook
|
||||
# libfx examples
|
||||
|
||||
Small applications built with [libfx](https://fx.sh/docs/lib). Each example keeps
|
||||
the agent calls in its entry point. Start with the one that matches your runtime.
|
||||
@@ -17,7 +17,7 @@ Clone this repository, then open the example directory:
|
||||
|
||||
```sh
|
||||
git clone https://github.com/vercel-labs/fx.git
|
||||
cd fx/cookbook/node-chat
|
||||
cd fx/examples/node-chat
|
||||
npm install
|
||||
```
|
||||
|
||||
@@ -43,7 +43,7 @@ public-demo model and transport policy, not another agent framework.
|
||||
|
||||
Create a Vercel project for each example, with its directory as the project root.
|
||||
Enable **Include source files outside of the Root Directory in the Build Step**
|
||||
so the project can load `cookbook/shared/`. Use Node.js 24.
|
||||
so the project can load `examples/shared/`. Use Node.js 24.
|
||||
|
||||
Set `AI_GATEWAY_API_KEY` as a server-only environment variable. Use a dedicated
|
||||
Gateway key with a daily budget. Never place a provider credential in a browser
|
||||
@@ -63,7 +63,7 @@ and usage policy when adapting the examples.
|
||||
From the repository root:
|
||||
|
||||
```sh
|
||||
node --test cookbook/shared/*.test.mjs
|
||||
node --test examples/shared/*.test.mjs
|
||||
```
|
||||
|
||||
Build the browser, Next.js, and Nuxt examples with `npm run build` in their
|
||||
File renamed without changes.
@@ -2,7 +2,7 @@
|
||||
<html lang="en">
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Browser agent · fx cookbook</title>
|
||||
<title>Browser agent · fx examples</title>
|
||||
<main>
|
||||
<h1>Browser agent</h1>
|
||||
<p>libfx runs in this browser through WebAssembly. Reload to start a new conversation.</p>
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -1,4 +1,4 @@
|
||||
export const metadata = { title: 'Next.js agent · fx cookbook' }
|
||||
export const metadata = { title: 'Next.js agent · fx examples' }
|
||||
|
||||
export default function Layout({ children }) {
|
||||
return <html lang="en"><body>{children}</body></html>
|
||||
File renamed without changes.
@@ -0,0 +1,7 @@
|
||||
import { fileURLToPath } from 'node:url'
|
||||
|
||||
const examplesRoot = fileURLToPath(new URL('..', import.meta.url))
|
||||
export default {
|
||||
turbopack: { root: examplesRoot },
|
||||
outputFileTracingRoot: examplesRoot,
|
||||
}
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -2,7 +2,7 @@
|
||||
<html lang="en">
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Node.js agent · fx cookbook</title>
|
||||
<title>Node.js agent · fx examples</title>
|
||||
<main>
|
||||
<h1>Node.js agent</h1>
|
||||
<p>A native libfx agent. Each request starts a new conversation.</p>
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -7,7 +7,7 @@ const status = ref('')
|
||||
const busy = ref(false)
|
||||
const ready = ref(false)
|
||||
onMounted(() => { ready.value = true })
|
||||
useHead({ title: 'Nuxt agent · fx cookbook', htmlAttrs: { lang: 'en' } })
|
||||
useHead({ title: 'Nuxt agent · fx examples', htmlAttrs: { lang: 'en' } })
|
||||
|
||||
async function send() {
|
||||
busy.value = true
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Reference in new issue
Block a user