refactor: remove Workers AI as any with proper type definitions
- Add WorkersAIModel, WorkersAITextGenerationInput/Output types - Remove `as any` from summary-service.ts (4 instances) - Remove `as any` from bank-sms-parser.ts (3 instances) - Remove `as any` from n8n-service.ts (2 instances) - Add OpenAIResponse interface for API responses Type-safe Workers AI calls with full IntelliSense support. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { z } from 'zod';
|
||||
import { Env, IntentAnalysis, N8nResponse } from './types';
|
||||
import { Env, IntentAnalysis, N8nResponse, WorkersAITextGenerationOutput, WorkersAITextGenerationInput } from './types';
|
||||
import { createLogger } from './utils/logger';
|
||||
|
||||
const logger = createLogger('n8n-service');
|
||||
@@ -53,10 +53,14 @@ ${userMessage}
|
||||
JSON:`;
|
||||
|
||||
try {
|
||||
const response = await ai.run('@cf/meta/llama-3.1-8b-instruct' as any, {
|
||||
const input: WorkersAITextGenerationInput = {
|
||||
messages: [{ role: 'user', content: prompt }],
|
||||
max_tokens: 100,
|
||||
}) as any;
|
||||
};
|
||||
const response = await ai.run(
|
||||
'@cf/meta/llama-3.1-8b-instruct' as '@cf/meta/llama-3.1-8b-instruct-fp8',
|
||||
input
|
||||
) as WorkersAITextGenerationOutput;
|
||||
|
||||
const text = response.response || '';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user