fix: fix some change
This commit is contained in:
@@ -3,8 +3,6 @@ import { ConfigService } from '@nestjs/config';
|
||||
|
||||
@Injectable()
|
||||
export class ChatbotService {
|
||||
private openRouter: any;
|
||||
|
||||
constructor(
|
||||
/**
|
||||
* Inject Config Service
|
||||
@@ -13,23 +11,16 @@ export class ChatbotService {
|
||||
) {}
|
||||
|
||||
private async getOpenRouter() {
|
||||
if (!this.openRouter) {
|
||||
const { OpenRouter } = await import('@openrouter/sdk');
|
||||
const { OpenRouter } = await import('@openrouter/sdk');
|
||||
|
||||
this.openRouter = new OpenRouter({
|
||||
apiKey: this.configService.get<string>('openRouter.apiKey'),
|
||||
});
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
||||
return this.openRouter;
|
||||
return new OpenRouter({
|
||||
apiKey: this.configService.get<string>('openRouter.apiKey'),
|
||||
});
|
||||
}
|
||||
|
||||
public async chat(message: string) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
||||
const openRouter = await this.getOpenRouter();
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
|
||||
const response = await openRouter.chat.send({
|
||||
chatRequest: {
|
||||
model: this.configService.get<string>('openRouter.model'),
|
||||
@@ -63,7 +54,6 @@ export class ChatbotService {
|
||||
throw new Error('Expected non-streaming response');
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
|
||||
const content = response.choices[0]?.message?.content;
|
||||
|
||||
if (typeof content !== 'string') {
|
||||
|
||||
Reference in New Issue
Block a user