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,4 +1,4 @@
|
||||
import { Env, BufferedMessage, Summary, ConversationContext } from './types';
|
||||
import { Env, BufferedMessage, Summary, ConversationContext, WorkersAITextGenerationOutput, WorkersAITextGenerationInput } from './types';
|
||||
import { createLogger } from './utils/logger';
|
||||
|
||||
const logger = createLogger('summary-service');
|
||||
@@ -190,10 +190,14 @@ ${userMessages}
|
||||
}
|
||||
|
||||
// 폴백: Workers AI
|
||||
const response = await env.AI.run('@cf/meta/llama-3.1-8b-instruct' as any, {
|
||||
const input: WorkersAITextGenerationInput = {
|
||||
messages: [{ role: 'user', content: prompt }],
|
||||
max_tokens: 500,
|
||||
}) as any;
|
||||
};
|
||||
const response = await env.AI.run(
|
||||
'@cf/meta/llama-3.1-8b-instruct' as '@cf/meta/llama-3.1-8b-instruct-fp8',
|
||||
input
|
||||
) as WorkersAITextGenerationOutput;
|
||||
|
||||
return response.response || '프로필 생성 실패';
|
||||
}
|
||||
@@ -329,14 +333,18 @@ ${integratedProfile}
|
||||
}
|
||||
|
||||
// 폴백: Workers AI
|
||||
const response = await env.AI.run('@cf/meta/llama-3.1-8b-instruct' as any, {
|
||||
const input: WorkersAITextGenerationInput = {
|
||||
messages: [
|
||||
{ role: 'system', content: systemPrompt },
|
||||
...recentContext,
|
||||
{ role: 'user', content: userMessage },
|
||||
],
|
||||
max_tokens: 500,
|
||||
}) as any;
|
||||
};
|
||||
const response = await env.AI.run(
|
||||
'@cf/meta/llama-3.1-8b-instruct' as '@cf/meta/llama-3.1-8b-instruct-fp8',
|
||||
input
|
||||
) as WorkersAITextGenerationOutput;
|
||||
|
||||
return response.response || '응답을 생성할 수 없습니다.';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user