alwaysai
Version:
The alwaysAI command-line interface (CLI)
34 lines (32 loc) • 1.19 kB
text/typescript
import { checkUserIsLoggedInComponent } from '../../components/user';
import { CliAuthenticationClient, CliRpcClient } from '../../infrastructure';
import { validateIsUserProject } from '../project';
import { RpcModelVersionWeb } from '@alwaysai/cloud-api';
export async function getModels(props: { yes: boolean; projectUuid?: string }) {
const { yes, projectUuid } = props;
await checkUserIsLoggedInComponent({ yes });
const { username } = await CliAuthenticationClient().getInfo();
const rpcClient = CliRpcClient();
let projectModels: RpcModelVersionWeb[] = [];
if (projectUuid) {
await validateIsUserProject({ project: projectUuid });
const project = await CliRpcClient().getProjectByUUID({
uuid: projectUuid
});
projectModels = await CliRpcClient().getProjectModels({
project_id: project.id
});
}
{
const publicModelVersions = await rpcClient.listPublicModelVersions();
const privateModelVersions = await rpcClient.listPrivateModelVersions({
publisher: username
});
const allModelVersions = [
...publicModelVersions,
...privateModelVersions,
...projectModels
];
return allModelVersions;
}
}