This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
import { queryAiGateway } from '@utils/aiGatewayClient';
|
||||
import { queryAi } from '@utils/aiGatewayClient';
|
||||
import { ShortcutsResponse } from '../types';
|
||||
import { dbOperations } from '@utils/db';
|
||||
|
||||
export async function anthropicCommand(
|
||||
export async function llamaCommand(
|
||||
parameters: Record<string, string> | undefined
|
||||
): Promise<ShortcutsResponse> {
|
||||
const commandId = Math.random().toString(36).substring(7);
|
||||
@@ -14,7 +14,7 @@ export async function anthropicCommand(
|
||||
let errorMessage: string | undefined;
|
||||
let tokensUsed: number | undefined;
|
||||
|
||||
console.info(`[CMD-${commandId}] Anthropic command started`, {
|
||||
console.info(`[CMD-${commandId}] Llama command started`, {
|
||||
hasParameters: !!parameters,
|
||||
timestamp: new Date().toISOString()
|
||||
});
|
||||
@@ -41,17 +41,14 @@ export async function anthropicCommand(
|
||||
question +
|
||||
'. Structure the response in a manner suitable for spoken communication.';
|
||||
|
||||
const anthropicResponse = await queryAiGateway(
|
||||
prompt,
|
||||
'anthropic/claude-sonnet-4.5'
|
||||
);
|
||||
response = anthropicResponse.text;
|
||||
tokensUsed = anthropicResponse.tokensUsed;
|
||||
const aiResponse = await queryAi(prompt);
|
||||
response = aiResponse.text;
|
||||
tokensUsed = aiResponse.tokensUsed;
|
||||
success = true;
|
||||
|
||||
const duration = Date.now() - startTime;
|
||||
console.info(
|
||||
`[CMD-${commandId}] Anthropic command completed in ${duration}ms`,
|
||||
`[CMD-${commandId}] Llama command completed in ${duration}ms`,
|
||||
{
|
||||
responseLength: response.length,
|
||||
tokensUsed,
|
||||
@@ -69,12 +66,12 @@ export async function anthropicCommand(
|
||||
} catch (error) {
|
||||
const duration = Date.now() - startTime;
|
||||
console.error(
|
||||
`[CMD-${commandId}] Anthropic command failed after ${duration}ms:`,
|
||||
`[CMD-${commandId}] Llama command failed after ${duration}ms:`,
|
||||
error
|
||||
);
|
||||
success = false;
|
||||
errorMessage = error instanceof Error ? error.message : 'Unknown error';
|
||||
response = 'Sorry. There was a problem with Anthropic.';
|
||||
response = 'Sorry. There was a problem with the AI service.';
|
||||
|
||||
return {
|
||||
success: false,
|
||||
@@ -84,7 +81,7 @@ export async function anthropicCommand(
|
||||
if (question) {
|
||||
try {
|
||||
console.info(`[CMD-${commandId}] Saving query to database`);
|
||||
await dbOperations.saveAnthropicQuery({
|
||||
await dbOperations.saveQuery({
|
||||
question,
|
||||
response,
|
||||
success,
|
||||
Reference in New Issue
Block a user