generated from IBM/template-graphql-typescript
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Memory consumption enhancements (#55)
* Stream file in and out of mongo, add pubsub api, add wip cloudant version * Fix compare logic Signed-off-by: Sean Sundberg <[email protected]>
- Loading branch information
Showing
30 changed files
with
1,074 additions
and
254 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,3 +13,4 @@ test-report.xml | |
**/charts/*.tgz | ||
Chart.lock | ||
.env | ||
output.log |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { CloudantV1 } from "@ibm-cloud/cloudant"; | ||
import {IamAuthenticator} from "ibm-cloud-sdk-core"; | ||
|
||
export interface CloudantBackendConfig { | ||
url: string; | ||
apikey: string; | ||
} | ||
|
||
export const cloudantBackend = (): Partial<CloudantBackendConfig> => { | ||
return { | ||
apikey: process.env.CLOUDANT_API_KEY, | ||
url: process.env.CLOUDANT_URL, | ||
} | ||
} | ||
|
||
let _instance: CloudantV1; | ||
export const cloudantClient = ({apikey, url}: CloudantBackendConfig): CloudantV1 => { | ||
if (_instance) { | ||
return _instance; | ||
} | ||
|
||
const authenticator = new IamAuthenticator({apikey}) | ||
|
||
const instance = new CloudantV1({ | ||
authenticator, | ||
}); | ||
instance.setServiceUrl(url); | ||
|
||
return _instance = instance; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export * from './cloudant.backend' | ||
export * from './mongodb.config' | ||
export * from './watsonx.config' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import {AIModelInputFormatter, AIModelInputModel, AIModelModel, InputField} from "../models"; | ||
import {Field, ID, ObjectType} from "@nestjs/graphql"; | ||
|
||
@ObjectType({description: 'AI Model'}) | ||
export class AiModel implements AIModelModel { | ||
@Field(() => ID) | ||
id: string; | ||
@Field() | ||
name: string; | ||
@Field() | ||
deploymentId: string; | ||
@Field({nullable: true}) | ||
description?: string; | ||
@Field({nullable: true}) | ||
default?: boolean; | ||
@Field() | ||
label: string; | ||
@Field(() => [AIModelInput]) | ||
inputs: AIModelInputModel[]; | ||
} | ||
|
||
@ObjectType({description: 'AI Model input'}) | ||
export class AIModelInput implements AIModelInputModel { | ||
@Field() | ||
name: string; | ||
@Field(() => [String], {nullable: true}) | ||
aliases?: string[]; | ||
@Field({nullable: true}) | ||
formatterName?: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
export * from './csv-document.graphql' | ||
export * from './ai-model.graphql' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import {Query, Resolver} from "@nestjs/graphql"; | ||
|
||
import {AiModel} from "../../graphql-types"; | ||
import {AiModelApi} from "../../services"; | ||
import {AIModelInputFormatter, AIModelInputModel, AIModelModel, InputField} from "../../models"; | ||
|
||
@Resolver(of => AiModel) | ||
export class AiModelsResolver { | ||
|
||
constructor(private readonly service: AiModelApi) {} | ||
|
||
@Query(returns => [AiModel]) | ||
async listAiModels(): Promise<AIModelModel[]> { | ||
const models = await this.service.listAIModels() | ||
|
||
return models.map(mapAiModel) | ||
} | ||
} | ||
|
||
const mapAiModel = (model: AIModelModel): AIModelModel => { | ||
return Object.assign({}, model, {inputs: mapInputs(model.inputs)}) | ||
} | ||
|
||
const mapInputs = (inputs: InputField[]): AIModelInputModel[] => { | ||
return inputs.map(mapInput) | ||
} | ||
|
||
const mapInput = (input: InputField): AIModelInputModel => { | ||
if (typeof input === 'string') { | ||
return {name: input} | ||
} | ||
|
||
return input | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './ai-models.resolver' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
import {Provider} from "@nestjs/common"; | ||
|
||
import {CsvDocumentResolver} from "./csv-document"; | ||
import {AiModelsResolver} from "./ai-models"; | ||
|
||
export * from './csv-document' | ||
|
||
export const providers: Provider[] = [ | ||
CsvDocumentResolver | ||
CsvDocumentResolver, | ||
AiModelsResolver, | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.