From 96bfaeb6ae4f9ca17d117a7cd29c643e249c92c2 Mon Sep 17 00:00:00 2001 From: Yaqub Mahmoud Date: Thu, 13 Feb 2025 10:22:59 +0900 Subject: [PATCH] Update stream-text.ts --- app/lib/.server/llm/stream-text.ts | 55 +++++++++++++++++------------- 1 file changed, 31 insertions(+), 24 deletions(-) diff --git a/app/lib/.server/llm/stream-text.ts b/app/lib/.server/llm/stream-text.ts index 7a0a3ae..1f9ebd3 100644 --- a/app/lib/.server/llm/stream-text.ts +++ b/app/lib/.server/llm/stream-text.ts @@ -26,39 +26,46 @@ export type StreamingOptions = Omit[0], 'model'>; export function streamText(messages: Messages, env: Env, options?: StreamingOptions) { try { - // const azureResourceName = process.env.AZURE_RESOURCE_NAME; - // const azureResourceNameApiKey = process.env.AZURE_RESOURCE_NAME_API_KEY; - // const azure = createAzure({ - // resourceName: azureResourceName, - // apiKey: azureResourceNameApiKey, - // headers: { - // 'api_version': '2024-11-20', - // }, + const azureResourceName = process.env.AZURE_RESOURCE_NAME; + const azureResourceNameApiKey = process.env.AZURE_RESOURCE_NAME_API_KEY; + const azure = createAzure({ + resourceName: azureResourceName, + apiKey: azureResourceNameApiKey, + headers: { + api_version: '2024-11-20', + }, + }); + + // ` + // For all designs I ask you to make, have them be beautiful, not cookie cutter. Make webpages that are fully featured and worthy for production. + // By default, this template supports JSX syntax with Tailwind CSS classes, React hooks, and Lucide React for icons. Do not install other packages for UI themes, icons, etc unless absolutely necessary or I request them. + // Use icons from lucide-react for logos. + // Use stock photos from unsplash where appropriate, only valid URLs you know exist. Do not download the images, only link to them in image tags. + // `; + + return _streamText({ + // model: azure('gpt-4o'), + model: azure('gpt-4o-2'), + system: getSystemPrompt(), + messages: convertToCoreMessages(messages), + maxTokens: 8192, + ...options, + }); + + // const ollama = createOllama({ + // baseURL: 'http://localhost:11434/api', // }); // return _streamText({ - // // model: azure('gpt-4o'), - // model: azure('gpt-4o-2'), + // // model: ollama('llava'), + // // model: ollama('deepseek-r1:7b'), + // model: ollama('deepseek-r1:70b'), // system: getSystemPrompt(), // messages: convertToCoreMessages(messages), // maxTokens: MAX_TOKENS, // ...options, // }); - const ollama = createOllama({ - baseURL: 'http://localhost:11434/api', - }); - - return _streamText({ - // model: ollama('llava'), - // model: ollama('deepseek-r1:7b'), - model: ollama('deepseek-r1:70b'), - system: getSystemPrompt(), - messages: convertToCoreMessages(messages), - maxTokens: MAX_TOKENS, - ...options, - }); - // const anthropic = createAnthropic({ // apiKey: getAPIKey(env), // });