MCPcopy Create free account
hub / github.com/Writesonic/GPTRouter / getAllModels

Function getAllModels

src/controllers/model.controller.ts:14–37  ·  view source on GitHub ↗
(
  request: FastifyRequestTypebox<typeof GetAllModelsSchema>,
  reply: FastifyReplyTypebox<typeof GetAllModelsSchema>,
)

Source from the content-addressed store, hash-verified

12 * @returns {Promise<void>} - A Promise that resolves when the operation is complete.
13 */
14export const getAllModels = async (
15 request: FastifyRequestTypebox<typeof GetAllModelsSchema>,
16 reply: FastifyReplyTypebox<typeof GetAllModelsSchema>,
17) => {
18 try {
19 const data = await request.server.orm
20 .getRepository(Model)
21 .find({ relations: ["provider"], order: { order: "ASC" } });
22 const res = data.map(model => ({
23 id: model.id,
24 name: model.name,
25 providerId: model.providerId,
26 providerName: model.provider.name,
27 createdAt: model.createdAt,
28 updatedAt: model.updatedAt,
29 inputType: model.inputType,
30 order: model.order,
31 }));
32 reply.code(200).send(res);
33 } catch (e: any) {
34 Sentry.captureException(e);
35 reply.code(500).send(e);
36 }
37};
38
39/**
40 * Get a model by its ID from the database.

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected