|
@@ -3,12 +3,14 @@ import type { ValidationChain } from 'express-validator';
|
|
|
import { body } from 'express-validator';
|
|
import { body } from 'express-validator';
|
|
|
|
|
|
|
|
import type Crowi from '~/server/crowi';
|
|
import type Crowi from '~/server/crowi';
|
|
|
-import { openaiClient } from '~/server/service/openai';
|
|
|
|
|
-import { getOpenaiService } from '~/server/service/openai/openai';
|
|
|
|
|
|
|
+import { apiV3FormValidator } from '~/server/middlewares/apiv3-form-validator';
|
|
|
|
|
+import type { ApiV3Response } from '~/server/routes/apiv3/interfaces/apiv3-response';
|
|
|
import loggerFactory from '~/utils/logger';
|
|
import loggerFactory from '~/utils/logger';
|
|
|
|
|
|
|
|
-import { apiV3FormValidator } from '../../../middlewares/apiv3-form-validator';
|
|
|
|
|
-import type { ApiV3Response } from '../interfaces/apiv3-response';
|
|
|
|
|
|
|
+import { openaiClient } from '../services';
|
|
|
|
|
+import { getOpenaiService } from '../services/openai';
|
|
|
|
|
+
|
|
|
|
|
+import { certifyAiService } from './middlewares/certify-ai-service';
|
|
|
|
|
|
|
|
const logger = loggerFactory('growi:routes:apiv3:openai:thread');
|
|
const logger = loggerFactory('growi:routes:apiv3:openai:thread');
|
|
|
|
|
|
|
@@ -20,15 +22,15 @@ type CreateThreadReq = Request<undefined, ApiV3Response, {
|
|
|
type CreateThreadFactory = (crowi: Crowi) => RequestHandler[];
|
|
type CreateThreadFactory = (crowi: Crowi) => RequestHandler[];
|
|
|
|
|
|
|
|
export const createThreadHandlersFactory: CreateThreadFactory = (crowi) => {
|
|
export const createThreadHandlersFactory: CreateThreadFactory = (crowi) => {
|
|
|
- const accessTokenParser = require('../../../middlewares/access-token-parser')(crowi);
|
|
|
|
|
- const loginRequiredStrictly = require('../../../middlewares/login-required')(crowi);
|
|
|
|
|
|
|
+ const accessTokenParser = require('~/server/middlewares/access-token-parser')(crowi);
|
|
|
|
|
+ const loginRequiredStrictly = require('~/server/middlewares/login-required')(crowi);
|
|
|
|
|
|
|
|
const validator: ValidationChain[] = [
|
|
const validator: ValidationChain[] = [
|
|
|
body('threadId').optional().isString().withMessage('threadId must be string'),
|
|
body('threadId').optional().isString().withMessage('threadId must be string'),
|
|
|
];
|
|
];
|
|
|
|
|
|
|
|
return [
|
|
return [
|
|
|
- accessTokenParser, loginRequiredStrictly, validator, apiV3FormValidator,
|
|
|
|
|
|
|
+ accessTokenParser, loginRequiredStrictly, certifyAiService, validator, apiV3FormValidator,
|
|
|
async(req: CreateThreadReq, res: ApiV3Response) => {
|
|
async(req: CreateThreadReq, res: ApiV3Response) => {
|
|
|
const openaiService = getOpenaiService();
|
|
const openaiService = getOpenaiService();
|
|
|
if (openaiService == null) {
|
|
if (openaiService == null) {
|