feat: add development openrouter and fix changes
This commit is contained in:
@@ -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');
|
||||
|
||||
Reference in New Issue
Block a user