repo_name
string
dataset
string
owner
string
lang
string
func_name
string
code
string
docstring
string
url
string
sha
string
project-lakechain
github_2023
awslabs
typescript
LlamaTextProcessorBuilder.withModelParameters
public withModelParameters(parameters: ModelParameters) { this.middlewareProps.modelParameters = parameters; return (this); }
/** * Sets the parameters to pass to the text model. * @param parameters the parameters to pass to the text model. * @default {} * @returns the current builder instance. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/bedrock-text-processors/src/impl/meta/index.ts#L94-L97
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
LlamaTextProcessorBuilder.withSystemPrompt
public withSystemPrompt(prompt: string) { this.middlewareProps.systemPrompt = prompt; return (this); }
/** * Sets the system prompt to use for generating text. * @param prompt the system prompt to use for generating text. * @returns the current builder instance. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/bedrock-text-processors/src/impl/meta/index.ts#L104-L107
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
LlamaTextProcessorBuilder.withPrompt
public withPrompt(prompt: string | r.IReference<any>) { let reference = null; if (typeof prompt === 'string') { reference = r.reference(r.value(prompt)); } else { reference = prompt; } this.middlewareProps.prompt = reference; return (this); }
/** * Sets the prompt to use for generating text. * @param prompt the prompt to use for generating text. * @returns the current builder instance. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/bedrock-text-processors/src/impl/meta/index.ts#L114-L125
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
LlamaTextProcessorBuilder.withRegion
public withRegion(region: string) { this.middlewareProps.region = region; return (this); }
/** * Sets the AWS region in which the model * will be invoked. * @param region the AWS region in which the model * will be invoked. * @returns the current builder instance. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/bedrock-text-processors/src/impl/meta/index.ts#L134-L137
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
LlamaTextProcessorBuilder.build
public build(): LlamaTextProcessor { return (new LlamaTextProcessor( this.scope, this.identifier, { ...this.middlewareProps as LlamaTextProcessorProps, ...this.props } )); }
/** * @returns a new instance of the `LlamaTextProcessor` * service constructed with the given parameters. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/bedrock-text-processors/src/impl/meta/index.ts#L143-L151
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
LlamaTextProcessor.constructor
constructor(scope: Construct, id: string, private props: LlamaTextProcessorProps) { super(scope, id, description, { ...props, queueVisibilityTimeout: cdk.Duration.seconds( 2 * PROCESSING_TIMEOUT.toSeconds() ) }); // Validate the properties. this.props = this.parse(LlamaTextPro...
/** * Construct constructor. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/bedrock-text-processors/src/impl/meta/index.ts#L178-L285
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
LlamaTextProcessor.grantReadProcessedDocuments
grantReadProcessedDocuments(grantee: iam.IGrantable): iam.Grant { return (this.storage.grantRead(grantee)); }
/** * Allows a grantee to read from the processed documents * generated by this middleware. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/bedrock-text-processors/src/impl/meta/index.ts#L291-L293
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
LlamaTextProcessor.supportedInputTypes
supportedInputTypes(): string[] { return ([ 'text/plain', 'text/markdown', 'text/csv', 'text/html', 'application/x-subrip', 'text/vtt', 'application/json', 'application/xml', 'application/json+scheduler' ]); }
/** * @returns an array of mime-types supported as input * type by this middleware. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/bedrock-text-processors/src/impl/meta/index.ts#L299-L311
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
LlamaTextProcessor.supportedOutputTypes
supportedOutputTypes(): string[] { return ([ 'text/plain' ]); }
/** * @returns an array of mime-types supported as output * type by the data producer. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/bedrock-text-processors/src/impl/meta/index.ts#L317-L321
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
LlamaTextProcessor.supportedComputeTypes
supportedComputeTypes(): ComputeType[] { return ([ ComputeType.CPU ]); }
/** * @returns the supported compute types by a given * middleware. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/bedrock-text-processors/src/impl/meta/index.ts#L327-L331
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
LlamaTextProcessor.conditional
conditional() { return (super .conditional() .and(when('type').equals('document-created')) ); }
/** * @returns the middleware conditional statement defining * in which conditions this middleware should be executed. * In this case, we want the middleware to only be invoked * when the document mime-type is supported, and the event * type is `document-created`. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/bedrock-text-processors/src/impl/meta/index.ts#L340-L345
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
LlamaModel.of
public static of(props: LlamaModelProps) { return (new LlamaModel(props)); }
/** * Create a new instance of the `LlamaModel` * by name. * @param props the properties of the model. * @returns a new instance of the `LlamaModel`. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/bedrock-text-processors/src/impl/meta/definitions/model.ts#L84-L86
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
LlamaModel.constructor
constructor(props: LlamaModelProps) { this.name = props.name; }
/** * Create a new instance of the `LlamaModel`. * @param props the properties of the model. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/bedrock-text-processors/src/impl/meta/definitions/model.ts#L92-L94
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
Lambda.getContent
private async getContent(event: CloudEvent) { const content = [{ text: (await event.resolve(USER_PROMPT)).toString('utf-8') }]; // Add the document to the prompt. const document = event.data().document(); const text = (await document.data().asBuffer()).toString('utf-8'); content.push(...
/** * Creates the content array to pass to the model. * @param events the events to create a prompt for. * @returns a promise to an array of messages to pass to the model. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/bedrock-text-processors/src/impl/meta/lambdas/handler/index.ts#L72-L85
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
Lambda.transform
private async transform(event: CloudEvent): Promise<Buffer> { const messages: Message[] = [{ role: 'user', content: await this.getContent(event) }]; // Request to the model. const request: ConverseCommandInput = { modelId: MODEL_ID, messages, inferenceConfig: MODEL_PARAMET...
/** * Transforms the document using the given parameters. * @param event the CloudEvent to process. * @returns a promise to a buffer containing the transformed document. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/bedrock-text-processors/src/impl/meta/lambdas/handler/index.ts#L92-L119
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
Lambda.recordHandler
async recordHandler(record: SQSRecord): Promise<CloudEvent> { return (await this.processEvent( CloudEvent.from(record.body) )); }
/** * @param record the SQS record to process that contains * the EventBridge event providing information about the * S3 event. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/bedrock-text-processors/src/impl/meta/lambdas/handler/index.ts#L153-L157
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
Lambda.handler
public async handler(event: SQSEvent, _: Context) { return (await processPartialResponse( event, this.recordHandler.bind(this), processor )); }
// eslint-disable-next-line @typescript-eslint/no-unused-vars
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/bedrock-text-processors/src/impl/meta/lambdas/handler/index.ts#L167-L171
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
MistralTextProcessorBuilder.withModel
public withModel(model: MistralTextModel) { this.middlewareProps.model = model; return (this); }
/** * Sets the Mistral model to use for generating text. * @param model the Mistral text model to use. * @returns the current builder instance. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/bedrock-text-processors/src/impl/mistral/index.ts#L83-L86
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
MistralTextProcessorBuilder.withModelParameters
public withModelParameters(parameters: ModelParameters) { this.middlewareProps.modelParameters = parameters; return (this); }
/** * Sets the parameters to pass to the text model. * @param parameters the parameters to pass to the text model. * @default {} * @returns the current builder instance. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/bedrock-text-processors/src/impl/mistral/index.ts#L94-L97
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
MistralTextProcessorBuilder.withSystemPrompt
public withSystemPrompt(prompt: string) { this.middlewareProps.systemPrompt = prompt; return (this); }
/** * Sets the system prompt to use for generating text. * @param prompt the system prompt to use for generating text. * @returns the current builder instance. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/bedrock-text-processors/src/impl/mistral/index.ts#L104-L107
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
MistralTextProcessorBuilder.withPrompt
public withPrompt(prompt: string | r.IReference<any>) { let reference = null; if (typeof prompt === 'string') { reference = r.reference(r.value(prompt)); } else { reference = prompt; } this.middlewareProps.prompt = reference; return (this); }
/** * Sets the prompt to use for generating text. * @param prompt the prompt to use for generating text. * @returns the current builder instance. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/bedrock-text-processors/src/impl/mistral/index.ts#L114-L125
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
MistralTextProcessorBuilder.withRegion
public withRegion(region: string) { this.middlewareProps.region = region; return (this); }
/** * Sets the AWS region in which the model * will be invoked. * @param region the AWS region in which the model * will be invoked. * @returns the current builder instance. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/bedrock-text-processors/src/impl/mistral/index.ts#L134-L137
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
MistralTextProcessorBuilder.build
public build(): MistralTextProcessor { return (new MistralTextProcessor( this.scope, this.identifier, { ...this.middlewareProps as MistralTextProcessorProps, ...this.props } )); }
/** * @returns a new instance of the `MistralTextProcessor` * service constructed with the given parameters. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/bedrock-text-processors/src/impl/mistral/index.ts#L143-L151
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
MistralTextProcessor.constructor
constructor(scope: Construct, id: string, private props: MistralTextProcessorProps) { super(scope, id, description, { ...props, queueVisibilityTimeout: cdk.Duration.seconds( 2 * PROCESSING_TIMEOUT.toSeconds() ) }); // Validate the properties. this.props = this.parse(MistralTex...
/** * Construct constructor. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/bedrock-text-processors/src/impl/mistral/index.ts#L178-L285
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
MistralTextProcessor.grantReadProcessedDocuments
grantReadProcessedDocuments(grantee: iam.IGrantable): iam.Grant { return (this.storage.grantRead(grantee)); }
/** * Allows a grantee to read from the processed documents * generated by this middleware. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/bedrock-text-processors/src/impl/mistral/index.ts#L291-L293
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
MistralTextProcessor.supportedInputTypes
supportedInputTypes(): string[] { return (this.props.model.inputs); }
/** * @returns an array of mime-types supported as input * type by this middleware. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/bedrock-text-processors/src/impl/mistral/index.ts#L299-L301
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
MistralTextProcessor.supportedOutputTypes
supportedOutputTypes(): string[] { return (this.props.model.outputs); }
/** * @returns an array of mime-types supported as output * type by the data producer. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/bedrock-text-processors/src/impl/mistral/index.ts#L307-L309
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
MistralTextProcessor.supportedComputeTypes
supportedComputeTypes(): ComputeType[] { return ([ ComputeType.CPU ]); }
/** * @returns the supported compute types by a given * middleware. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/bedrock-text-processors/src/impl/mistral/index.ts#L315-L319
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
MistralTextProcessor.conditional
conditional() { return (super .conditional() .and(when('type').equals('document-created')) ); }
/** * @returns the middleware conditional statement defining * in which conditions this middleware should be executed. * In this case, we want the middleware to only be invoked * when the document mime-type is supported, and the event * type is `document-created`. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/bedrock-text-processors/src/impl/mistral/index.ts#L328-L333
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
MistralTextModel.of
public static of(props: MistralTextModelProps) { return (new MistralTextModel(props)); }
/** * Create a new instance of the `MistralTextModel` * by name. * @param props the properties of the model. * @returns a new instance of the `MistralTextModel`. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/bedrock-text-processors/src/impl/mistral/definitions/model.ts#L139-L141
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
MistralTextModel.constructor
constructor(props: MistralTextModelProps) { this.name = props.name; this.inputs = props.inputs; this.outputs = props.outputs; }
/** * Constructs a new instance of the `MistralTextModel`. * @param props the properties of the model. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/bedrock-text-processors/src/impl/mistral/definitions/model.ts#L147-L151
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
Lambda.getContent
private async getContent(event: CloudEvent) { const content = [{ text: (await event.resolve(USER_PROMPT)).toString('utf-8') }]; // Add the document to the prompt. const document = event.data().document(); const text = (await document.data().asBuffer()).toString('utf-8'); content.push(...
/** * Creates the content array to pass to the model. * @param events the events to create a prompt for. * @returns a promise to an array of messages to pass to the model. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/bedrock-text-processors/src/impl/mistral/lambdas/handler/index.ts#L72-L85
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
Lambda.transform
private async transform(event: CloudEvent): Promise<Buffer> { const messages: Message[] = [{ role: 'user', content: await this.getContent(event) }]; // Request to the model. const request: ConverseCommandInput = { modelId: MODEL_ID, messages, inferenceConfig: MODEL_PARAMET...
/** * Transforms the document using the given parameters. * @param event the CloudEvent to process. * @returns a promise to a buffer containing the transformed document. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/bedrock-text-processors/src/impl/mistral/lambdas/handler/index.ts#L92-L119
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
Lambda.recordHandler
async recordHandler(record: SQSRecord): Promise<CloudEvent> { return (await this.processEvent( CloudEvent.from(record.body) )); }
/** * @param record the SQS record to process that contains * the EventBridge event providing information about the * S3 event. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/bedrock-text-processors/src/impl/mistral/lambdas/handler/index.ts#L153-L157
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
Lambda.handler
public async handler(event: SQSEvent, _: Context) { return (await processPartialResponse( event, this.recordHandler.bind(this), processor )); }
// eslint-disable-next-line @typescript-eslint/no-unused-vars
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/bedrock-text-processors/src/impl/mistral/lambdas/handler/index.ts#L167-L171
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
TitanTextProcessorBuilder.withModel
public withModel(model: TitanTextModel) { this.middlewareProps.model = model; return (this); }
/** * Sets the Titan model to use for generating text. * @param model the Titan text model to use. * @returns the current builder instance. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/bedrock-text-processors/src/impl/titan/index.ts#L83-L86
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
TitanTextProcessorBuilder.withModelParameters
public withModelParameters(parameters: ModelParameters) { this.middlewareProps.modelParameters = parameters; return (this); }
/** * Sets the parameters to pass to the text model. * @param parameters the parameters to pass to the text model. * @default {} * @returns the current builder instance. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/bedrock-text-processors/src/impl/titan/index.ts#L94-L97
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
TitanTextProcessorBuilder.withPrompt
public withPrompt(prompt: string | r.IReference<any>) { let reference = null; if (typeof prompt === 'string') { reference = r.reference(r.value(prompt)); } else { reference = prompt; } this.middlewareProps.prompt = reference; return (this); }
/** * Sets the prompt to use for generating text. * @param prompt the prompt to use for generating text. * @returns the current builder instance. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/bedrock-text-processors/src/impl/titan/index.ts#L104-L115
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
TitanTextProcessorBuilder.withRegion
public withRegion(region: string) { this.middlewareProps.region = region; return (this); }
/** * Sets the AWS region in which the model * will be invoked. * @param region the AWS region in which the model * will be invoked. * @returns the current builder instance. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/bedrock-text-processors/src/impl/titan/index.ts#L124-L127
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
TitanTextProcessorBuilder.build
public build(): TitanTextProcessor { return (new TitanTextProcessor( this.scope, this.identifier, { ...this.middlewareProps as TitanTextProcessorProps, ...this.props } )); }
/** * @returns a new instance of the `TitanTextProcessor` * service constructed with the given parameters. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/bedrock-text-processors/src/impl/titan/index.ts#L133-L141
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
TitanTextProcessor.constructor
constructor(scope: Construct, id: string, private props: TitanTextProcessorProps) { super(scope, id, description, { ...props, queueVisibilityTimeout: cdk.Duration.seconds( 2 * PROCESSING_TIMEOUT.toSeconds() ) }); // Validate the properties. this.props = this.parse(TitanTextPro...
/** * Construct constructor. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/bedrock-text-processors/src/impl/titan/index.ts#L168-L274
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
TitanTextProcessor.grantReadProcessedDocuments
grantReadProcessedDocuments(grantee: iam.IGrantable): iam.Grant { return (this.storage.grantRead(grantee)); }
/** * Allows a grantee to read from the processed documents * generated by this middleware. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/bedrock-text-processors/src/impl/titan/index.ts#L280-L282
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
TitanTextProcessor.supportedInputTypes
supportedInputTypes(): string[] { return ([ 'text/plain', 'text/markdown', 'text/csv', 'text/html', 'application/x-subrip', 'text/vtt', 'application/json', 'application/xml', 'application/json+scheduler' ]); }
/** * @returns an array of mime-types supported as input * type by this middleware. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/bedrock-text-processors/src/impl/titan/index.ts#L288-L300
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
TitanTextProcessor.supportedOutputTypes
supportedOutputTypes(): string[] { return ([ 'text/plain' ]); }
/** * @returns an array of mime-types supported as output * type by the data producer. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/bedrock-text-processors/src/impl/titan/index.ts#L306-L310
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
TitanTextProcessor.supportedComputeTypes
supportedComputeTypes(): ComputeType[] { return ([ ComputeType.CPU ]); }
/** * @returns the supported compute types by a given * middleware. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/bedrock-text-processors/src/impl/titan/index.ts#L316-L320
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
TitanTextProcessor.conditional
conditional() { return (super .conditional() .and(when('type').equals('document-created')) ); }
/** * @returns the middleware conditional statement defining * in which conditions this middleware should be executed. * In this case, we want the middleware to only be invoked * when the document mime-type is supported, and the event * type is `document-created`. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/bedrock-text-processors/src/impl/titan/index.ts#L329-L334
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
TitanTextModel.of
public static of(props: TitanTextModelProps) { return (new TitanTextModel(props)); }
/** * Create a new instance of the `TitanTextModel` * by name. * @param props the properties of the model. * @returns a new instance of the `TitanTextModel`. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/bedrock-text-processors/src/impl/titan/definitions/model.ts#L68-L70
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
TitanTextModel.constructor
constructor(props: TitanTextModelProps) { this.name = props.name; }
/** * Initialize the Titan text model. * @param props the properties of the model. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/bedrock-text-processors/src/impl/titan/definitions/model.ts#L76-L78
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
Lambda.getContent
private async getContent(event: CloudEvent) { const content = [{ text: (await event.resolve(USER_PROMPT)).toString('utf-8') }]; // Add the document to the prompt. const document = event.data().document(); const text = (await document.data().asBuffer()).toString('utf-8'); content.push(...
/** * Creates the content array to pass to the model. * @param events the events to create a prompt for. * @returns a promise to an array of messages to pass to the model. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/bedrock-text-processors/src/impl/titan/lambdas/handler/index.ts#L70-L83
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
Lambda.transform
private async transform(event: CloudEvent): Promise<Buffer> { const messages: Message[] = [{ role: 'user', content: await this.getContent(event) }]; // Invoke the model. const response = await bedrock.send(new ConverseCommand({ modelId: MODEL_ID, messages, inferenceConfig:...
/** * Transforms the document using the given parameters. * @param event the CloudEvent to process. * @returns a promise to a buffer containing the transformed document. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/bedrock-text-processors/src/impl/titan/lambdas/handler/index.ts#L90-L107
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
Lambda.recordHandler
async recordHandler(record: SQSRecord): Promise<CloudEvent> { return (await this.processEvent( CloudEvent.from(record.body) )); }
/** * @param record the SQS record to process that contains * the EventBridge event providing information about the * S3 event. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/bedrock-text-processors/src/impl/titan/lambdas/handler/index.ts#L141-L145
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
Lambda.handler
public async handler(event: SQSEvent, _: Context) { return (await processPartialResponse( event, this.recordHandler.bind(this), processor )); }
// eslint-disable-next-line @typescript-eslint/no-unused-vars
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/bedrock-text-processors/src/impl/titan/lambdas/handler/index.ts#L155-L159
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
BertExtractiveSummarizerBuilder.withMaxInstances
public withMaxInstances(maxInstances: number) { this.middlewareProps.maxInstances = maxInstances; return (this); }
/** * The maximum amount of instances the * cluster can have. Keep this number to * a reasonable value to avoid over-provisioning * the cluster. * @param maxInstances the maximum amount of instances. * @default 5 */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/bert-extractive-summarizer/src/index.ts#L94-L97
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
BertExtractiveSummarizerBuilder.withRatio
public withRatio(ratio: number) { this.middlewareProps.ratio = ratio; return (this); }
/** * Sets the summarization ratio to use expressed * in percentage between 0.1 and 1.0. * @param ratio the summarization ratio to use. * @returns the builder instance. * @default 0.2 */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/bert-extractive-summarizer/src/index.ts#L106-L109
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
BertExtractiveSummarizerBuilder.build
public build(): BertExtractiveSummarizer { const props = BertExtractiveSummarizerPropsSchema.parse({ ...this.middlewareProps, ...this.props }); return (new BertExtractiveSummarizer( this.scope, this.identifier, { ...this.middlewareProps as BertExtractiveSummarizerProps, ...
/** * @returns a new instance of the `BertExtractiveSummarizer` * service constructed with the given parameters. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/bert-extractive-summarizer/src/index.ts#L115-L128
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
BertExtractiveSummarizer.constructor
constructor(scope: Construct, id: string, private props: BertExtractiveSummarizerProps) { super(scope, id, description, { ...props, queueVisibilityTimeout: cdk.Duration.seconds( 6 * PROCESSING_TIMEOUT.toSeconds() ) }); // Validate the properties. this.props = this.parse(BertEx...
/** * Construct constructor. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/bert-extractive-summarizer/src/index.ts#L156-L194
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
BertExtractiveSummarizer.grantReadProcessedDocuments
grantReadProcessedDocuments(grantee: iam.IGrantable): iam.Grant { return (this.storage.grantRead(grantee)); }
/** * Allows a grantee to read from the processed documents * generated by this middleware. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/bert-extractive-summarizer/src/index.ts#L343-L345
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
BertExtractiveSummarizer.supportedInputTypes
supportedInputTypes(): string[] { return ([ 'text/plain' ]); }
/** * @returns an array of mime-types supported as input * type by this middleware. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/bert-extractive-summarizer/src/index.ts#L351-L355
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
BertExtractiveSummarizer.supportedOutputTypes
supportedOutputTypes(): string[] { return ([ 'text/plain' ]); }
/** * @returns an array of mime-types supported as output * type by the data producer. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/bert-extractive-summarizer/src/index.ts#L361-L365
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
BertExtractiveSummarizer.supportedComputeTypes
supportedComputeTypes(): ComputeType[] { return ([ ComputeType.CPU, ComputeType.GPU ]); }
/** * @returns the supported compute types by a given * middleware. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/bert-extractive-summarizer/src/index.ts#L371-L376
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
BertExtractiveSummarizer.conditional
conditional() { return (super .conditional() .and(when('type').equals('document-created')) ); }
/** * @returns the middleware conditional statement defining * in which conditions this middleware should be executed. * In this case, we want the middleware to only be invoked * when the document mime-type is supported, and the event * type is `document-created`. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/bert-extractive-summarizer/src/index.ts#L385-L390
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
CharacterTextSplitterBuilder.withChunkSize
public withChunkSize(chunkSize: number) { this.providerProps.chunkSize = chunkSize; return (this); }
/** * Sets the chunk size. * @param chunkSize the chunk size to assign. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/character-text-splitter/src/index.ts#L89-L92
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
CharacterTextSplitterBuilder.withChunkOverlap
public withChunkOverlap(chunkOverlap: number) { this.providerProps.chunkOverlap = chunkOverlap; return (this); }
/** * Sets the chunk overlap. * @param chunkOverlap the chunk overlap to assign. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/character-text-splitter/src/index.ts#L98-L101
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
CharacterTextSplitterBuilder.withSeparator
public withSeparator(separator: string) { this.providerProps.separator = separator; return (this); }
/** * Sets the separator to use between chunks. * @param separator the separator to use. * @returns the builder itself. * @default `\n\n` */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/character-text-splitter/src/index.ts#L109-L112
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
CharacterTextSplitterBuilder.build
public build(): CharacterTextSplitter { return (new CharacterTextSplitter( this.scope, this.identifier, { ...this.providerProps as CharacterTextSplitterProps, ...this.props } )); }
/** * @returns a new instance of the `CharacterTextSplitter` * service constructed with the given parameters. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/character-text-splitter/src/index.ts#L118-L126
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
CharacterTextSplitter.constructor
constructor(scope: Construct, id: string, props: CharacterTextSplitterProps) { super(scope, id, description, { ...props, queueVisibilityTimeout: cdk.Duration.seconds( 6 * PROCESSING_TIMEOUT.toSeconds() ) }); // Validate the properties. props = this.parse(CharacterTextSplitterP...
/** * Construct constructor. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/character-text-splitter/src/index.ts#L153-L224
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
CharacterTextSplitter.grantReadProcessedDocuments
grantReadProcessedDocuments(grantee: iam.IGrantable): iam.Grant { return (this.storage.grantRead(grantee)); }
/** * Allows a grantee to read from the processed documents * generated by this middleware. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/character-text-splitter/src/index.ts#L230-L232
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
CharacterTextSplitter.supportedInputTypes
supportedInputTypes(): string[] { return ([ 'text/plain' ]); }
/** * @returns an array of mime-types supported as input * type by this middleware. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/character-text-splitter/src/index.ts#L238-L242
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
CharacterTextSplitter.supportedOutputTypes
supportedOutputTypes(): string[] { return ([ 'text/plain' ]); }
/** * @returns an array of mime-types supported as output * type by the data producer. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/character-text-splitter/src/index.ts#L248-L252
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
CharacterTextSplitter.supportedComputeTypes
supportedComputeTypes(): ComputeType[] { return ([ ComputeType.CPU ]); }
/** * @returns the supported compute types by a given * middleware. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/character-text-splitter/src/index.ts#L258-L262
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
CharacterTextSplitter.conditional
conditional() { return (super .conditional() .and(when('type').equals('document-created')) ); }
/** * @returns the middleware conditional statement defining * in which conditions this middleware should be executed. * In this case, we want the middleware to only be invoked * when the document mime-type is supported, and the event * type is `document-created`. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/character-text-splitter/src/index.ts#L271-L276
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
Lambda.getMetadata
getMetadata(chunk: string, order: number, total: number): DocumentMetadata { return ({ properties: { kind: 'text', attrs: { chunk: { id: crypto .createHash('sha256') .update(chunk) .digest('hex'), order, to...
/** * @param chunk the chunk of text to return metadata for. * @param order the order of the chunk. * @param total the total number of chunks in the document. * @returns the metadata for the chunk. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/character-text-splitter/src/lambdas/text-splitter/index.ts#L67-L83
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
Lambda.processEvent
async processEvent(event: CloudEvent): Promise<CloudEvent> { const document = event.data().document(); // We load the text file in memory. const text = (await document.data().asBuffer()).toString('utf-8'); // Create the text splitter. const textSplitter = new CharacterTextSplitter({ separato...
/** * @param event the event to process. * @note the next decorator will automatically forward the * returned cloud event to the next middlewares */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/character-text-splitter/src/lambdas/text-splitter/index.ts#L124-L147
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
Lambda.handler
async handler(event: SQSEvent, _: Context): Promise<SQSBatchResponse> { return (await processPartialResponse( event, (record: SQSRecord) => this.processEvent( CloudEvent.from(JSON.parse(record.body)) ), processor )); }
// eslint-disable-next-line @typescript-eslint/no-unused-vars
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/character-text-splitter/src/lambdas/text-splitter/index.ts#L156-L164
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
EmailTextProcessorBuilder.withOutputFormat
public withOutputFormat(outputFormat: OutputFormat) { this.providerProps.outputFormat = outputFormat; return (this); }
/** * Sets the desired output format. * @param outputFormat the desired output format. * @default text * @returns the builder instance. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/email-text-processor/src/index.ts#L78-L81
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
EmailTextProcessorBuilder.withIncludeAttachments
public withIncludeAttachments(includeAttachments: boolean) { this.providerProps.includeAttachments = includeAttachments; return (this); }
/** * Sets whether to include attachments. * @param includeAttachments whether to include attachments. * @default false * @returns the builder instance. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/email-text-processor/src/index.ts#L89-L92
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
EmailTextProcessorBuilder.withIncludeImageLinks
public withIncludeImageLinks(includeImageLinks: boolean) { this.providerProps.includeImageLinks = includeImageLinks; return (this); }
/** * Sets whether to include CID attachments to data URL images. * @param includeImageLinks whether to include image links. * @default false * @returns the builder instance. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/email-text-processor/src/index.ts#L100-L103
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
EmailTextProcessorBuilder.build
public build(): EmailTextProcessor { return (new EmailTextProcessor( this.scope, this.identifier, { ...this.providerProps as EmailTextProcessorProps, ...this.props } )); }
/** * @returns a new instance of the `EmailTextProcessor` * service constructed with the given parameters. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/email-text-processor/src/index.ts#L109-L117
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
EmailTextProcessor.constructor
constructor(scope: Construct, id: string, private props: EmailTextProcessorProps) { super(scope, id, description, { ...props, queueVisibilityTimeout: cdk.Duration.seconds( 6 * PROCESSING_TIMEOUT.toSeconds() ) }); // Validate the properties. this.props = this.parse(EmailTextPro...
/** * Construct constructor. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/email-text-processor/src/index.ts#L144-L224
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
EmailTextProcessor.grantReadProcessedDocuments
grantReadProcessedDocuments(grantee: iam.IGrantable): iam.Grant { return (this.storage.grantRead(grantee)); }
/** * Allows a grantee to read from the processed documents * generated by this middleware. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/email-text-processor/src/index.ts#L230-L232
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
EmailTextProcessor.supportedInputTypes
supportedInputTypes(): string[] { return ([ 'message/rfc822', 'application/vnd.ms-outlook' ]); }
/** * @returns an array of mime-types supported as input * type by this middleware. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/email-text-processor/src/index.ts#L238-L243
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
EmailTextProcessor.supportedOutputTypes
supportedOutputTypes(): string[] { if (this.props.includeAttachments) { return (['*/*']); } if (this.props.outputFormat === 'text') { return (['text/plain']); } else if (this.props.outputFormat === 'html') { return (['text/html']); } else { return (['application/json']); ...
/** * @returns an array of mime-types supported as output * type by the data producer. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/email-text-processor/src/index.ts#L249-L260
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
EmailTextProcessor.supportedComputeTypes
supportedComputeTypes(): ComputeType[] { return ([ ComputeType.CPU ]); }
/** * @returns the supported compute types by a given * middleware. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/email-text-processor/src/index.ts#L266-L270
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
EmailTextProcessor.conditional
conditional() { return (super .conditional() .and(when('type').equals('document-created')) ); }
/** * @returns the middleware conditional statement defining * in which conditions this middleware should be executed. * In this case, we want the middleware to only be invoked * when the document mime-type is supported, and the event * type is `document-created`. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/email-text-processor/src/index.ts#L279-L284
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
asJson
const asJson = (message: MessageText, headers: Headers): string => { return (JSON.stringify({ headers: Object.fromEntries(headers), text: message.text, html: message.html })); };
/** * @param message the message associated with the email. * @returns an object describing the attributes * of the email. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/email-text-processor/src/lambdas/parser/convert.ts#L35-L41
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
Lambda.createCallbacks
private createCallbacks(event: CloudEvent, parser: MailParser) { let headers: Headers; return ({ onData: (data: AttachmentStream | MessageText) => { if (data.type === 'attachment') { if (!INCLUDE_ATTACHMENTS) { data.release(); } else { this.onAttachment...
/** * A function creating a closure capturing the * email document parsing results. * @param e the cloud event associated with the * email document. * @returns a closure exposing the event handlers * to process the email document. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/email-text-processor/src/lambdas/parser/index.ts#L181-L199
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
Lambda.processEvent
async processEvent(event: CloudEvent): Promise<any> { const document = event.data().document(); const parser = new MailParser({ skipImageLinks: !INCLUDE_IMAGE_LINKS }); // We create a readable stream from the document. const readable = await document.data().asReadStream(); // Create a ...
/** * Parses the input email document, and processes its * content, attachments and headers as a stream. * @param event the event to process. * @note the next decorator will automatically forward the * returned cloud event to the next middlewares */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/email-text-processor/src/lambdas/parser/index.ts#L208-L230
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
Lambda.handler
async handler(event: SQSEvent, _: Context): Promise<SQSBatchResponse> { return (await processPartialResponse( event, (record: SQSRecord) => this.processEvent( CloudEvent.from(JSON.parse(record.body)) ), processor )); }
// eslint-disable-next-line @typescript-eslint/no-unused-vars
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/email-text-processor/src/lambdas/parser/index.ts#L239-L247
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
JMESPathProcessorBuilder.withExpression
public withExpression(expression: string) { // Validate the expression. jmespath.search({}, expression); this.providerProps.expression = expression; return (this); }
/** * Sets the JMESPath expression to apply. * @param expression the JMESPath expression to apply. * @returns the builder itself. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/jmespath-processor/src/index.ts#L76-L81
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
JMESPathProcessorBuilder.build
public build(): JMESPathProcessor { return (new JMESPathProcessor( this.scope, this.identifier, { ...this.providerProps as JMESPathProcessorProps, ...this.props } )); }
/** * @returns a new instance of the `JMESPathProcessor` * service constructed with the given parameters. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/jmespath-processor/src/index.ts#L87-L95
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
JMESPathProcessor.constructor
constructor(scope: Construct, id: string, props: JMESPathProcessorProps) { super(scope, id, description, { ...props, queueVisibilityTimeout: cdk.Duration.seconds( 6 * PROCESSING_TIMEOUT.toSeconds() ) }); // Validate the properties. props = this.parse(JMESPathProcessorPropsSche...
/** * Construct constructor. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/jmespath-processor/src/index.ts#L122-L191
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
JMESPathProcessor.grantReadProcessedDocuments
grantReadProcessedDocuments(grantee: iam.IGrantable): iam.Grant { return (this.storage.grantRead(grantee)); }
/** * Allows a grantee to read from the processed documents * generated by this middleware. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/jmespath-processor/src/index.ts#L197-L199
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
JMESPathProcessor.supportedInputTypes
supportedInputTypes(): string[] { return ([ 'application/json' ]); }
/** * @returns an array of mime-types supported as input * type by this middleware. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/jmespath-processor/src/index.ts#L205-L209
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
JMESPathProcessor.supportedOutputTypes
supportedOutputTypes(): string[] { return ([ 'application/json', 'text/plain' ]); }
/** * @returns an array of mime-types supported as output * type by the data producer. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/jmespath-processor/src/index.ts#L215-L220
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
JMESPathProcessor.supportedComputeTypes
supportedComputeTypes(): ComputeType[] { return ([ ComputeType.CPU ]); }
/** * @returns the supported compute types by a given * middleware. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/jmespath-processor/src/index.ts#L226-L230
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
JMESPathProcessor.conditional
conditional() { return (super .conditional() .and(when('type').equals('document-created')) ); }
/** * @returns the middleware conditional statement defining * in which conditions this middleware should be executed. * In this case, we want the middleware to only be invoked * when the document mime-type is supported, and the event * type is `document-created`. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/jmespath-processor/src/index.ts#L239-L244
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
Lambda.getType
private getType(obj: any): string { return (typeof obj === 'object' ? 'application/json' : 'text/plain' ); }
/** * @param obj a javascript object. * @returns the type of the object. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/jmespath-processor/src/lambdas/processor/index.ts#L70-L75
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
Lambda.handler
async handler(event: SQSEvent, _: Context): Promise<SQSBatchResponse> { return (await processPartialResponse( event, (record: SQSRecord) => this.processEvent( CloudEvent.from(JSON.parse(record.body)) ), processor )); }
// eslint-disable-next-line @typescript-eslint/no-unused-vars
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/jmespath-processor/src/lambdas/processor/index.ts#L126-L134
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
KeybertTextProcessorBuilder.withTopN
public withTopN(topN: number) { this.middlewareProps.topN = topN; return (this); }
/** * Sets the maximum number of keywords to extract. * @param topN the maximum number of keywords to extract. * @default 5 */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/keybert-text-processor/src/index.ts#L72-L75
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
KeybertTextProcessorBuilder.withUseMaxSum
public withUseMaxSum(useMaxSum: boolean) { this.middlewareProps.useMaxSum = useMaxSum; return (this); }
/** * Sets whether to use the max sum algorithm. * @param useMaxSum whether to use the max sum algorithm. * @default false */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/keybert-text-processor/src/index.ts#L82-L85
4285173e80584eedfc1a8424d3d1b6c1a7038088