feat(openai): add list models dynamic data
This commit is contained in:
3
packages/backend/src/apps/openai/dynamic-data/index.ts
Normal file
3
packages/backend/src/apps/openai/dynamic-data/index.ts
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
import listModels from './list-models';
|
||||||
|
|
||||||
|
export default [listModels];
|
@@ -0,0 +1,19 @@
|
|||||||
|
import { IGlobalVariable } from '@automatisch/types';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'List models',
|
||||||
|
key: 'listModels',
|
||||||
|
|
||||||
|
async run($: IGlobalVariable) {
|
||||||
|
const response = await $.http.get('/v1/models');
|
||||||
|
|
||||||
|
const models = response.data.data.map((model: { id: string }) => {
|
||||||
|
return {
|
||||||
|
value: model.id,
|
||||||
|
name: model.id,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
return { data: models };
|
||||||
|
},
|
||||||
|
};
|
@@ -2,6 +2,7 @@ import defineApp from '../../helpers/define-app';
|
|||||||
import addAuthHeader from './common/add-auth-header';
|
import addAuthHeader from './common/add-auth-header';
|
||||||
import auth from './auth';
|
import auth from './auth';
|
||||||
import actions from './actions';
|
import actions from './actions';
|
||||||
|
import dynamicData from './dynamic-data';
|
||||||
|
|
||||||
export default defineApp({
|
export default defineApp({
|
||||||
name: 'OpenAI',
|
name: 'OpenAI',
|
||||||
@@ -15,4 +16,5 @@ export default defineApp({
|
|||||||
beforeRequest: [addAuthHeader],
|
beforeRequest: [addAuthHeader],
|
||||||
auth,
|
auth,
|
||||||
actions,
|
actions,
|
||||||
|
dynamicData,
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user