mirror of
https://github.com/LLM-Red-Team/kimi-free-api.git
synced 2025-10-19 00:38:21 +00:00
first commit
This commit is contained in:
25
src/api/routes/chat.ts
Normal file
25
src/api/routes/chat.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import _ from 'lodash';
|
||||
|
||||
import Request from '@/lib/request/Request.ts';
|
||||
import Response from '@/lib/response/Response.ts';
|
||||
import chat from '@/api/controllers/chat.ts';
|
||||
|
||||
export default {
|
||||
|
||||
prefix: '/v1/chat',
|
||||
|
||||
post: {
|
||||
|
||||
'/completions': async (request: Request) => {
|
||||
request
|
||||
.validate('body.messages', _.isArray)
|
||||
chat.setRefreshToken(request.body.refresh_token);
|
||||
const stream = await chat.createCompletionStream(request.body.messages, request.body.use_search);
|
||||
return new Response(stream, {
|
||||
type: "text/event-stream"
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user