This commit is contained in:
@@ -74,7 +74,6 @@ export class AiService {
|
||||
'تو دستیار هوشمند منوی رستوران هستی.',
|
||||
'فقط بر اساس منوی زیر به سوالات کاربر پاسخ بده.',
|
||||
'اگر اطلاعات کافی در منو نیست، صادقانه بگو.',
|
||||
'خیلی کوتاه جواب بده.',
|
||||
'وقتی غذایی پیشنهاد میدهی، فقط از شناسههای (id) موجود در منو استفاده کن.',
|
||||
'پاسخ را فقط و فقط به صورت JSON معتبر برگردان، بدون متن اضافه یا markdown:',
|
||||
'{"answer":"پاسخ کوتاه فارسی","foodIds":["id1","id2"]}',
|
||||
@@ -171,8 +170,8 @@ export class AiService {
|
||||
if (!answer) {
|
||||
this.logger.error(
|
||||
`Empty AI content. finish_reason=${choice?.finish_reason ?? 'unknown'} ` +
|
||||
`reasoning_tokens=${choice?.message?.reasoning_content?.length ?? 0} ` +
|
||||
`usage=${JSON.stringify(aiResponse.usage ?? null)}`,
|
||||
`reasoning_tokens=${choice?.message?.reasoning_content?.length ?? 0} ` +
|
||||
`usage=${JSON.stringify(aiResponse.usage ?? null)}`,
|
||||
);
|
||||
throw new ServiceUnavailableException(AiMessage.NO_RESPONSE_FROM_AI_MODEL);
|
||||
}
|
||||
@@ -237,7 +236,7 @@ export class AiService {
|
||||
}
|
||||
|
||||
private buildMenuContext(
|
||||
foods: Array<Pick<Food, 'id' | 'title' | 'desc' | 'content' | 'price'>>,
|
||||
foods: Array<Pick<Food, 'id' | 'title' | 'desc' | 'content' >>,
|
||||
): string {
|
||||
if (!foods.length) {
|
||||
return 'منوی رستوران در حال حاضر خالی است.';
|
||||
@@ -250,8 +249,7 @@ export class AiService {
|
||||
`${index + 1}. id: ${food.id}`,
|
||||
`نام: ${food.title ?? 'بدون نام'}`,
|
||||
`توضیحات: ${food.desc ?? 'ندارد'}`,
|
||||
`محتویات: ${contents}`,
|
||||
`قیمت: ${food.price ?? 'نامشخص'}`,
|
||||
`محتویات: ${contents}`
|
||||
].join('\n');
|
||||
})
|
||||
.join('\n\n');
|
||||
@@ -267,8 +265,8 @@ export class AiService {
|
||||
if (!raw) {
|
||||
this.logger.error(
|
||||
`Empty AI content. finish_reason=${choice?.finish_reason ?? 'unknown'} ` +
|
||||
`reasoning_tokens=${choice?.message?.reasoning_content?.length ?? 0} ` +
|
||||
`usage=${JSON.stringify(aiResponse.usage ?? null)}`,
|
||||
`reasoning_tokens=${choice?.message?.reasoning_content?.length ?? 0} ` +
|
||||
`usage=${JSON.stringify(aiResponse.usage ?? null)}`,
|
||||
);
|
||||
throw new ServiceUnavailableException(AiMessage.NO_RESPONSE_FROM_AI_MODEL);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user