mirror of https://github.com/ghostfolio/ghostfolio
5 changed files with 31 additions and 46 deletions
@ -1,34 +0,0 @@ |
|||
import { |
|||
PROPERTY_API_KEY_OPENROUTER, |
|||
PROPERTY_OPENROUTER_MODEL |
|||
} from '@ghostfolio/common/config/properties'; |
|||
|
|||
import { Injectable } from '@nestjs/common'; |
|||
import { createOpenRouter } from '@openrouter/ai-sdk-provider'; |
|||
import { streamText } from 'ai'; |
|||
|
|||
import { PropertyService } from '../../property/property.service'; |
|||
|
|||
@Injectable() |
|||
export class OpenRouterService { |
|||
public constructor(private readonly propertyService: PropertyService) {} |
|||
|
|||
public async getCompletion(prompt: string) { |
|||
const openRouterApiKey = await this.propertyService.getByKey( |
|||
PROPERTY_API_KEY_OPENROUTER |
|||
); |
|||
|
|||
const openRouterModel = await this.propertyService.getByKey( |
|||
PROPERTY_OPENROUTER_MODEL |
|||
); |
|||
|
|||
const openrouter = createOpenRouter({ |
|||
apiKey: openRouterApiKey as string |
|||
}); |
|||
|
|||
return streamText({ |
|||
model: openrouter.chat(openRouterModel as string), |
|||
prompt |
|||
}); |
|||
} |
|||
} |
@ -1,8 +1,3 @@ |
|||
export const PROPERTY_DATA_GATHERING_QUEUE_INTERVAL = |
|||
'DATA_GATHERING_QUEUE_INTERVAL'; |
|||
export const PROPERTY_IS_DEMO_MODE = 'IS_DEMO_MODE'; |
|||
export const PROPERTY_IS_USER_SIGNUP_ENABLED = 'IS_USER_SIGNUP_ENABLED'; |
|||
export const PROPERTY_MAX_PORTFOLIOS = 'MAX_PORTFOLIOS'; |
|||
export const PROPERTY_MAX_USERS = 'MAX_USERS'; |
|||
export const PROPERTY_API_KEY_OPENROUTER = 'API_KEY_OPENROUTER'; |
|||
export const PROPERTY_OPENROUTER_MODEL = 'OPENROUTER_MODEL'; |
|||
|
|||
|
Loading…
Reference in new issue