Skip to content

Commit d52e3d7

Browse files
authored
Added LLM evaluator to example projects (#1589)
* Added repo links * Added links to remix / nextjs webhooks examples * Added a Realtime learn more snippet * Added the batch llm evaluator docs * Improved snippet * Updated intro
1 parent 3ca0c15 commit d52e3d7

10 files changed

+121
-11
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
---
2+
title: "Batch LLM Evaluator"
3+
sidebarTitle: "Batch LLM Evaluator"
4+
description: "This example project evaluates multiple LLM models using the Vercel AI SDK and streams updates to the frontend using Trigger.dev Realtime."
5+
---
6+
7+
import RealtimeLearnMore from "/snippets/realtime-learn-more.mdx";
8+
9+
## Overview
10+
11+
This demo is a full stack example that uses the following:
12+
13+
- A [Next.js](https://nextjs.org/) app with [Prisma](https://www.prisma.io/) for the database.
14+
- Trigger.dev [Realtime](https://trigger.dev/launchweek/0/realtime) to stream updates to the frontend.
15+
- Work with multiple LLM models using the Vercel [AI SDK](https://sdk.vercel.ai/docs/introduction). (OpenAI, Anthropic, XAI)
16+
- Distribute tasks across multiple tasks using the new [`batch.triggerByTaskAndWait`](https://trigger.dev/docs/triggering#batch-triggerbytaskandwait) method.
17+
18+
## GitHub repo
19+
20+
<Card
21+
title="View the Batch LLM Evaluator repo"
22+
icon="GitHub"
23+
href="https://github.com/triggerdotdev/examples/tree/main/batch-llm-evaluator"
24+
>
25+
Click here to view the full code for this project in our examples repository on GitHub. You can
26+
fork it and use it as a starting point for your own project.
27+
</Card>
28+
29+
## Video
30+
31+
<video
32+
controls
33+
className="w-full aspect-video"
34+
src="https://content.trigger.dev/batch-llm-evaluator.mp4"
35+
></video>
36+
37+
## Relevant code
38+
39+
- View the Trigger.dev task code in the [src/trigger/batch.ts](https://github.com/triggerdotdev/examples/blob/main/batch-llm-evaluator/src/trigger/batch.ts) file.
40+
- The `evaluateModels` task uses the `batch.triggerByTaskAndWait` method to distribute the task to the different LLM models.
41+
- It then passes the results through to a `summarizeEvals` task that calculates some dummy "tags" for each LLM response.
42+
- We use a [useRealtimeRunsWithTag](https://trigger.dev/docs/frontend/react-hooks/realtime#userealtimerunswithtag) hook to subscribe to the different evaluation tasks runs in the [src/components/llm-evaluator.tsx](https://github.com/triggerdotdev/examples/blob/main/batch-llm-evaluator/src/components/llm-evaluator.tsx) file.
43+
- We then pass the relevant run down into three different components for the different models:
44+
- The `AnthropicEval` component: [src/components/evals/Anthropic.tsx](https://github.com/triggerdotdev/examples/blob/main/batch-llm-evaluator/src/components/evals/Anthropic.tsx)
45+
- The `XAIEval` component: [src/components/evals/XAI.tsx](https://github.com/triggerdotdev/examples/blob/main/batch-llm-evaluator/src/components/evals/XAI.tsx)
46+
- The `OpenAIEval` component: [src/components/evals/OpenAI.tsx](https://github.com/triggerdotdev/examples/blob/main/batch-llm-evaluator/src/components/evals/OpenAI.tsx)
47+
- Each of these components then uses [useRealtimeRunWithStreams](https://trigger.dev/docs/frontend/react-hooks/realtime#userealtimerunwithstreams) to subscribe to the different LLM responses.
48+
49+
<RealtimeLearnMore />

docs/guides/example-projects/realtime-fal-ai.mdx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ sidebarTitle: "Realtime image gen with Fal.ai"
44
description: "This example project generates an image from a prompt using Fal.ai and shows the progress of the task on the frontend using Trigger.dev Realtime."
55
---
66

7+
import RealtimeLearnMore from "/snippets/realtime-learn-more.mdx";
8+
79
## Overview
810

911
This full stack Next.js project showcases the following:
@@ -40,3 +42,5 @@ This video walks through the process of creating this task in a Next.js project.
4042
allowfullscreen
4143
/>
4244
</div>
45+
46+
<RealtimeLearnMore />

docs/guides/examples/fal-ai-realtime.mdx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,17 @@ sidebarTitle: "Fal.ai with Realtime"
44
description: "This example task generates an image from a prompt using Fal.ai and shows the progress of the task on the frontend using Trigger.dev Realtime."
55
---
66

7+
## GitHub repo
8+
9+
<Card
10+
title="View the project on GitHub"
11+
icon="GitHub"
12+
href="https://github.com/triggerdotdev/examples/tree/main/realtime-fal-ai-image-generation"
13+
>
14+
Click here to view the full code for this project in our examples repository on GitHub. You can
15+
fork it and use it as a starting point for your own project.
16+
</Card>
17+
718
## Walkthrough
819

920
This video walks through the process of creating this task in a Next.js project.

docs/guides/frameworks/nextjs-webhooks.mdx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,17 @@ import VercelDocsCards from "/snippets/vercel-docs-cards.mdx";
1111
- [A Next.js project, set up with Trigger.dev](/guides/frameworks/nextjs)
1212
- [cURL](https://curl.se/) installed on your local machine. This will be used to send a POST request to your webhook handler.
1313

14+
## GitHub repo
15+
16+
<Card
17+
title="View the project on GitHub"
18+
icon="GitHub"
19+
href="https://github.com/triggerdotdev/examples/tree/main/nextjs-webhooks/my-app"
20+
>
21+
Click here to view the full code for this project in our examples repository on GitHub. You can
22+
fork it and use it as a starting point for your own project.
23+
</Card>
24+
1425
## Adding the webhook handler
1526

1627
The webhook handler in this guide will be an API route.

docs/guides/frameworks/remix-webhooks.mdx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,17 @@ description: "Learn how to trigger a task from a webhook in a Remix app."
99
- [A Remix project, set up with Trigger.dev](/guides/frameworks/remix)
1010
- [cURL](https://curl.se/) installed on your local machine. This will be used to send a POST request to your webhook handler.
1111

12+
## GitHub repo
13+
14+
<Card
15+
title="View the project on GitHub"
16+
icon="GitHub"
17+
href="https://github.com/triggerdotdev/examples/tree/main/remix-webhooks"
18+
>
19+
Click here to view the full code for this project in our examples repository on GitHub. You can
20+
fork it and use it as a starting point for your own project.
21+
</Card>
22+
1223
## Adding the webhook handler
1324

1425
The webhook handler in this guide will be an API route. Create a new file `app/routes/api.webhook-handler.ts` or `app/routes/api.webhook-handler.js`.

docs/guides/frameworks/supabase-edge-functions-basic.mdx

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,6 @@ import NextjsTroubleshootingButtonSyntax from "/snippets/nextjs-button-syntax.md
1717
import WorkerFailedToStartWhenRunningDevCommand from "/snippets/worker-failed-to-start.mdx";
1818
import SupabaseDocsCards from "/snippets/supabase-docs-cards.mdx";
1919

20-
<Info>
21-
The project created in this guide can be found in this [GitHub
22-
repo](https://github.com/triggerdotdev/example-projects/tree/main/supabase).
23-
</Info>
24-
2520
## Overview
2621

2722
Supabase edge functions allow you to trigger tasks either when an event is sent from a third party (e.g. when a new Stripe payment is processed, when a new user signs up to a service, etc), or when there are any changes or updates to your Supabase database.
@@ -36,6 +31,17 @@ This guide shows you how to set up and deploy a simple Supabase edge function ex
3631
- [Create a Trigger.dev account](https://cloud.trigger.dev)
3732
- [Create a new Trigger.dev project](/guides/dashboard/creating-a-project)
3833

34+
## GitHub repo
35+
36+
<Card
37+
title="View the project on GitHub"
38+
icon="GitHub"
39+
href="https://github.com/triggerdotdev/examples/tree/main/supabase-edge-functions"
40+
>
41+
Click here to view the full code for this project in our examples repository on GitHub. You can
42+
fork it and use it as a starting point for your own project.
43+
</Card>
44+
3945
## Initial setup
4046

4147
<Steps>

docs/guides/frameworks/supabase-edge-functions-database-webhooks.mdx

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,14 @@ import NextjsTroubleshootingButtonSyntax from "/snippets/nextjs-button-syntax.md
1313
import WorkerFailedToStartWhenRunningDevCommand from "/snippets/worker-failed-to-start.mdx";
1414
import SupabaseDocsCards from "/snippets/supabase-docs-cards.mdx";
1515

16-
<Info>
17-
The project created in this guide can be found in this [GitHub
18-
repo](https://github.com/triggerdotdev/example-projects/tree/main/supabase).
19-
</Info>
20-
2116
## Overview
2217

2318
Supabase and Trigger.dev can be used together to create powerful workflows triggered by real-time changes in your database tables:
2419

2520
- A Supabase Database Webhook triggers an Edge Function when a row including a video URL is inserted into a table
2621
- The Edge Function triggers a Trigger.dev task, passing the `video_url` column data from the new table row as the payload
2722
- The Trigger.dev task then:
23+
2824
- Uses [FFmpeg](https://www.ffmpeg.org/) to extract the audio track from a video URL
2925
- Uses [Deepgram](https://deepgram.com) to transcribe the extracted audio
3026
- Updates the original table row using the `record.id` in Supabase with the new transcription using `update`
@@ -38,6 +34,17 @@ Supabase and Trigger.dev can be used together to create powerful workflows trigg
3834
- [Create a new Trigger.dev project](/guides/dashboard/creating-a-project)
3935
- [Create a new Deepgram account](https://deepgram.com/) and get your API key from the dashboard
4036

37+
## GitHub repo
38+
39+
<Card
40+
title="View the project on GitHub"
41+
icon="GitHub"
42+
href="https://github.com/triggerdotdev/examples/tree/main/supabase-edge-functions"
43+
>
44+
Click here to view the full code for this project in our examples repository on GitHub. You can
45+
fork it and use it as a starting point for your own project.
46+
</Card>
47+
4148
## Initial setup
4249

4350
<Steps>

docs/guides/introduction.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ Example projects are full projects with example repos you can fork and use. Thes
4040
| Example project | Description | Framework | GitHub Repo |
4141
| :--------------------------------------------------------------------------- | :------------------------------------------------------------------------------------------------------------- | :-------- | :---------------------------------------------------------------------------------------------------- |
4242
| [Realtime Fal.ai image generation](/guides/example-projects/realtime-fal-ai) | Generate an image from a prompt using Fal.ai and show the progress of the task on the frontend using Realtime. | Next.js | [View the repo](https://github.com/triggerdotdev/examples/tree/main/realtime-fal-ai-image-generation) |
43+
| [Batch LLM Evaluator](/guides/example-projects/batch-llm-evaluator) | Evaluate multiple LLM models and stream the results to the frontend. | Next.js | [View the repo](https://github.com/triggerdotdev/examples/tree/main/batch-llm-evaluator) |
4344

4445
## Example tasks
4546

docs/mint.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,10 @@
348348
},
349349
{
350350
"group": "Example projects",
351-
"pages": ["guides/example-projects/realtime-fal-ai"]
351+
"pages": [
352+
"guides/example-projects/realtime-fal-ai",
353+
"guides/example-projects/batch-llm-evaluator"
354+
]
352355
},
353356
{
354357
"group": "Example tasks",

docs/snippets/realtime-learn-more.mdx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
## Learn more about Trigger.dev Realtime
2+
3+
To learn more, take a look at the following resources:
4+
5+
- [Realtime docs](https://trigger.dev/docs/realtime) - learn more about Realtime.
6+
- [Batch Trigger docs](https://trigger.dev/docs/triggering) - learn more about Batch Triggers.
7+
- [React hooks](https://trigger.dev/docs/frontend/react-hooks) - learn more about React hooks.

0 commit comments

Comments
 (0)