feat: add first version of workbench, increase token limit, improve system prompt

This commit is contained in:
Dominic Elm
2024-07-17 20:54:46 +02:00
parent b4420a22bb
commit 621b8804d8
50 changed files with 2979 additions and 423 deletions

View File

@@ -1,9 +1,7 @@
import { type ActionFunctionArgs } from '@remix-run/cloudflare';
import { StreamingTextResponse, convertToCoreMessages, parseStreamPart, streamText } from 'ai';
import { getAPIKey } from '~/lib/.server/llm/api-key';
import { getAnthropicModel } from '~/lib/.server/llm/model';
import { systemPrompt } from '~/lib/.server/llm/prompts';
import { stripIndents } from '~/utils/stripIndent';
import { StreamingTextResponse, parseStreamPart } from 'ai';
import { streamText } from '../lib/.server/llm/stream-text';
import { stripIndents } from '../utils/stripIndent';
const encoder = new TextEncoder();
const decoder = new TextDecoder();
@@ -12,30 +10,23 @@ export async function action({ context, request }: ActionFunctionArgs) {
const { message } = await request.json<{ message: string }>();
try {
const result = await streamText({
model: getAnthropicModel(getAPIKey(context.cloudflare.env)),
system: systemPrompt,
messages: convertToCoreMessages([
const result = await streamText(
[
{
role: 'user',
content: stripIndents`
I want you to improve the user prompt that is wrapped in \`<original_prompt>\` tags.
I want you to improve the user prompt that is wrapped in \`<original_prompt>\` tags.
IMPORTANT: Only respond with the improved prompt and nothing else!
IMPORTANT: Only respond with the improved prompt and nothing else!
<original_prompt>
${message}
</original_prompt>
`,
<original_prompt>
${message}
</original_prompt>
`,
},
]),
});
if (import.meta.env.DEV) {
result.usage.then((usage) => {
console.log('Usage', usage);
});
}
],
context.cloudflare.env,
);
const transformStream = new TransformStream({
transform(chunk, controller) {