feat: add development openrouter and fix changes

This commit is contained in:
2026-10-23 19:19:40 +03:30
parent ce17808543
commit 97b1e48cfd
3 changed files with 25 additions and 10 deletions
@@ -6,6 +6,7 @@ import { Conversation } from '@/modules/conversation/entities/conversation.entit
import { ConversationService } from '@/modules/conversation/providers/conversation.service';
import { MessageRole } from '@/modules/conversation/enums/message-role.enum';
import { OpenRouterService } from '@/common/modules/open-router/providers/open-router.service';
import { SendChatCompletionRequestResponse } from '@openrouter/sdk/models/operations';
@Injectable()
export class ChatbotService {
@@ -77,12 +78,19 @@ export class ChatbotService {
const openRouter = await this.openRouterService.getOpenRouter();
const response = await openRouter.chat.send({
chatRequest: {
model: this.configService.getOrThrow<string>('openRouter.model'),
messages,
},
});
let response: SendChatCompletionRequestResponse;
try {
response = await openRouter.chat.send({
chatRequest: {
model: this.configService.getOrThrow<string>('openRouter.model'),
messages,
},
});
} catch (err) {
console.error('[ChatbotService] OpenRouter request failed:', err);
throw err;
}
if (response instanceof ReadableStream) {
throw new Error('Expected non-streaming response');