repo_name string | dataset string | owner string | lang string | func_name string | code string | docstring string | url string | sha string |
|---|---|---|---|---|---|---|---|---|
modus | github_2023 | hypermodeinc | typescript | Node.Labels | get Labels(): string[] {
return this.labels;
} | /**
* @deprecated use `labels` (lowercase) instead
*/ | https://github.com/hypermodeinc/modus/blob/f2f0634dfc81c5a8fc99955b75ad581600de65d3/sdk/assemblyscript/src/assembly/neo4j.ts#L243-L245 | f2f0634dfc81c5a8fc99955b75ad581600de65d3 |
modus | github_2023 | hypermodeinc | typescript | Relationship.StartElementId | get StartElementId(): string {
return this.startElementId;
} | /**
* @deprecated use `startElementId` (lowercase) instead
*/ | https://github.com/hypermodeinc/modus/blob/f2f0634dfc81c5a8fc99955b75ad581600de65d3/sdk/assemblyscript/src/assembly/neo4j.ts#L269-L271 | f2f0634dfc81c5a8fc99955b75ad581600de65d3 |
modus | github_2023 | hypermodeinc | typescript | Relationship.EndElementId | get EndElementId(): string {
return this.endElementId;
} | /**
* @deprecated use `endElementId` (lowercase) instead
*/ | https://github.com/hypermodeinc/modus/blob/f2f0634dfc81c5a8fc99955b75ad581600de65d3/sdk/assemblyscript/src/assembly/neo4j.ts#L279-L281 | f2f0634dfc81c5a8fc99955b75ad581600de65d3 |
modus | github_2023 | hypermodeinc | typescript | Relationship.Type | get Type(): string {
return this.type;
} | /**
* @deprecated use `type` (lowercase) instead
*/ | https://github.com/hypermodeinc/modus/blob/f2f0634dfc81c5a8fc99955b75ad581600de65d3/sdk/assemblyscript/src/assembly/neo4j.ts#L289-L291 | f2f0634dfc81c5a8fc99955b75ad581600de65d3 |
modus | github_2023 | hypermodeinc | typescript | Path.Nodes | get Nodes(): Node[] {
return this.nodes;
} | /**
* @deprecated use `nodes` (lowercase) instead
*/ | https://github.com/hypermodeinc/modus/blob/f2f0634dfc81c5a8fc99955b75ad581600de65d3/sdk/assemblyscript/src/assembly/neo4j.ts#L311-L313 | f2f0634dfc81c5a8fc99955b75ad581600de65d3 |
modus | github_2023 | hypermodeinc | typescript | Path.Relationships | get Relationships(): Relationship[] {
return this.relationships;
} | /**
* @deprecated use `relationships` (lowercase) instead
*/ | https://github.com/hypermodeinc/modus/blob/f2f0634dfc81c5a8fc99955b75ad581600de65d3/sdk/assemblyscript/src/assembly/neo4j.ts#L321-L323 | f2f0634dfc81c5a8fc99955b75ad581600de65d3 |
modus | github_2023 | hypermodeinc | typescript | Point2D.X | get X(): f64 {
return this.x;
} | /**
* @deprecated use `x` (lowercase) instead
*/ | https://github.com/hypermodeinc/modus/blob/f2f0634dfc81c5a8fc99955b75ad581600de65d3/sdk/assemblyscript/src/assembly/neo4j.ts#L347-L349 | f2f0634dfc81c5a8fc99955b75ad581600de65d3 |
modus | github_2023 | hypermodeinc | typescript | Point2D.Y | get Y(): f64 {
return this.y;
} | /**
* @deprecated use `y` (lowercase) instead
*/ | https://github.com/hypermodeinc/modus/blob/f2f0634dfc81c5a8fc99955b75ad581600de65d3/sdk/assemblyscript/src/assembly/neo4j.ts#L357-L359 | f2f0634dfc81c5a8fc99955b75ad581600de65d3 |
modus | github_2023 | hypermodeinc | typescript | Point2D.SpatialRefId | get SpatialRefId(): u32 {
return this.spatialRefId;
} | /**
* @deprecated use `spatialRefId` (lowercase) instead
*/ | https://github.com/hypermodeinc/modus/blob/f2f0634dfc81c5a8fc99955b75ad581600de65d3/sdk/assemblyscript/src/assembly/neo4j.ts#L367-L369 | f2f0634dfc81c5a8fc99955b75ad581600de65d3 |
modus | github_2023 | hypermodeinc | typescript | Point2D.String | String(): string {
return this.toString();
} | /**
* @deprecated use `toString` instead
*/ | https://github.com/hypermodeinc/modus/blob/f2f0634dfc81c5a8fc99955b75ad581600de65d3/sdk/assemblyscript/src/assembly/neo4j.ts#L381-L383 | f2f0634dfc81c5a8fc99955b75ad581600de65d3 |
modus | github_2023 | hypermodeinc | typescript | Point3D.Z | get Z(): f64 {
return this.z;
} | /**
* @deprecated use `z` (lowercase) instead
*/ | https://github.com/hypermodeinc/modus/blob/f2f0634dfc81c5a8fc99955b75ad581600de65d3/sdk/assemblyscript/src/assembly/neo4j.ts#L428-L430 | f2f0634dfc81c5a8fc99955b75ad581600de65d3 |
modus | github_2023 | hypermodeinc | typescript | assertEqualLength | function assertEqualLength<T extends number>(a: T[], b: T[]): void {
if (a.length !== b.length) {
throw new Error("Vectors must be the same length.");
}
} | /*
* Copyright 2024 Hypermode Inc.
* Licensed under the terms of the Apache License, Version 2.0
* See the LICENSE file that accompanied this code for further details.
*
* SPDX-FileCopyrightText: 2024 Hypermode Inc. <hello@hypermode.com>
* SPDX-License-Identifier: Apache-2.0
*/ | https://github.com/hypermodeinc/modus/blob/f2f0634dfc81c5a8fc99955b75ad581600de65d3/sdk/assemblyscript/src/assembly/vectors.ts#L10-L14 | f2f0634dfc81c5a8fc99955b75ad581600de65d3 |
modus | github_2023 | hypermodeinc | typescript | AnthropicMessagesModel.createInput | createInput(messages: Message[]): AnthropicMessagesInput {
const model = this.info.fullName;
return <AnthropicMessagesInput>{ model, messages };
} | /**
* Creates an input object for the Anthropic Messages API.
*
* @param messages: An array of messages to send to the model.
* Note that if you want to include a system prompt, you can use the top-level system parameter —
* there is no "system" role for input messages in the Messages API.
* @returns An input object that can be passed to the `invoke` method.
*/ | https://github.com/hypermodeinc/modus/blob/f2f0634dfc81c5a8fc99955b75ad581600de65d3/sdk/assemblyscript/src/models/anthropic/messages.ts#L30-L33 | f2f0634dfc81c5a8fc99955b75ad581600de65d3 |
modus | github_2023 | hypermodeinc | typescript | Message.constructor | constructor(role: string, content: string) {
this._role = role;
this.content = content;
} | /**
* Creates a new message object.
*
* @param role The role of the author of this message.
* @param content The contents of the message.
*/ | https://github.com/hypermodeinc/modus/blob/f2f0634dfc81c5a8fc99955b75ad581600de65d3/sdk/assemblyscript/src/models/anthropic/messages.ts#L47-L50 | f2f0634dfc81c5a8fc99955b75ad581600de65d3 |
modus | github_2023 | hypermodeinc | typescript | Message.role | get role(): string {
return this._role;
} | /**
* The role of the author of this message.
*/ | https://github.com/hypermodeinc/modus/blob/f2f0634dfc81c5a8fc99955b75ad581600de65d3/sdk/assemblyscript/src/models/anthropic/messages.ts#L59-L61 | f2f0634dfc81c5a8fc99955b75ad581600de65d3 |
modus | github_2023 | hypermodeinc | typescript | UserMessage.constructor | constructor(content: string) {
super("user", content);
} | /**
* Creates a new user message object.
*
* @param content The contents of the message.
*/ | https://github.com/hypermodeinc/modus/blob/f2f0634dfc81c5a8fc99955b75ad581600de65d3/sdk/assemblyscript/src/models/anthropic/messages.ts#L80-L82 | f2f0634dfc81c5a8fc99955b75ad581600de65d3 |
modus | github_2023 | hypermodeinc | typescript | AssistantMessage.constructor | constructor(content: string) {
super("assistant", content);
} | /**
* Creates a new assistant message object.
*
* @param content The contents of the message.
*/ | https://github.com/hypermodeinc/modus/blob/f2f0634dfc81c5a8fc99955b75ad581600de65d3/sdk/assemblyscript/src/models/anthropic/messages.ts#L95-L97 | f2f0634dfc81c5a8fc99955b75ad581600de65d3 |
modus | github_2023 | hypermodeinc | typescript | ClassificationModel.createInput | createInput(instances: string[]): ClassificationInput {
return <ClassificationInput>{ instances };
} | /**
* Creates an input object for the classification model.
*
* @param instances - A list of one or more text strings to classify.
* @returns An input object that can be passed to the `invoke` method.
*/ | https://github.com/hypermodeinc/modus/blob/f2f0634dfc81c5a8fc99955b75ad581600de65d3/sdk/assemblyscript/src/models/experimental/classification.ts#L29-L31 | f2f0634dfc81c5a8fc99955b75ad581600de65d3 |
modus | github_2023 | hypermodeinc | typescript | EmbeddingsModel.createInput | createInput(instances: string[]): EmbeddingsInput {
return <EmbeddingsInput>{ instances };
} | /**
* Creates an input object for the embeddings model.
*
* @param instances - A list of one or more text strings to create vector embeddings for.
* @returns An input object that can be passed to the `invoke` method.
*/ | https://github.com/hypermodeinc/modus/blob/f2f0634dfc81c5a8fc99955b75ad581600de65d3/sdk/assemblyscript/src/models/experimental/embeddings.ts#L26-L28 | f2f0634dfc81c5a8fc99955b75ad581600de65d3 |
modus | github_2023 | hypermodeinc | typescript | GeminiGenerateModel.createInput | createInput(contents: PromptContent[]): GeminiGenerateInput {
// for Gemini, the model is part of the URL, not the request body
return <GeminiGenerateInput>{ contents };
} | /**
* Creates an input object for the Gemini Generate Content API.
*
* @param contents The content of the current conversation with the model.
* @returns An input object that can be passed to the `invoke` method.
*/ | https://github.com/hypermodeinc/modus/blob/f2f0634dfc81c5a8fc99955b75ad581600de65d3/sdk/assemblyscript/src/models/gemini/generate.ts#L28-L31 | f2f0634dfc81c5a8fc99955b75ad581600de65d3 |
modus | github_2023 | hypermodeinc | typescript | PromptContent.constructor | constructor(role: string, parts: Part[]) {
this._role = role;
this.parts = parts;
} | /**
* Creates a new content object.
*
* @param role The role of the author of this content.
* @param parts The multi-part content message.
*/ | https://github.com/hypermodeinc/modus/blob/f2f0634dfc81c5a8fc99955b75ad581600de65d3/sdk/assemblyscript/src/models/gemini/generate.ts#L45-L48 | f2f0634dfc81c5a8fc99955b75ad581600de65d3 |
modus | github_2023 | hypermodeinc | typescript | PromptContent.role | get role(): string {
return this._role;
} | /**
* The role of the author of this content.
*/ | https://github.com/hypermodeinc/modus/blob/f2f0634dfc81c5a8fc99955b75ad581600de65d3/sdk/assemblyscript/src/models/gemini/generate.ts#L57-L59 | f2f0634dfc81c5a8fc99955b75ad581600de65d3 |
modus | github_2023 | hypermodeinc | typescript | UserContent.constructor | constructor(parts: Part[]) {
super("user", parts);
} | /**
* Creates a new user content object.
*
* @param parts The multi-part content message.
*/ | https://github.com/hypermodeinc/modus/blob/f2f0634dfc81c5a8fc99955b75ad581600de65d3/sdk/assemblyscript/src/models/gemini/generate.ts#L84-L86 | f2f0634dfc81c5a8fc99955b75ad581600de65d3 |
modus | github_2023 | hypermodeinc | typescript | ModelTextContent.constructor | constructor(content: string) {
super([{ text: content }]);
} | /**
* Creates a new model text content object.
*
* @param content The contents of the message.
*/ | https://github.com/hypermodeinc/modus/blob/f2f0634dfc81c5a8fc99955b75ad581600de65d3/sdk/assemblyscript/src/models/gemini/generate.ts#L99-L101 | f2f0634dfc81c5a8fc99955b75ad581600de65d3 |
modus | github_2023 | hypermodeinc | typescript | SystemTextContent.constructor | constructor(content: string) {
super("system", [{ text: content }]);
} | /**
* Creates a new system text content object.
*
* @param content The contents of the message.
*/ | https://github.com/hypermodeinc/modus/blob/f2f0634dfc81c5a8fc99955b75ad581600de65d3/sdk/assemblyscript/src/models/gemini/generate.ts#L114-L116 | f2f0634dfc81c5a8fc99955b75ad581600de65d3 |
modus | github_2023 | hypermodeinc | typescript | ModelContent.constructor | constructor(parts: Part[]) {
super("model", parts);
} | /**
* Creates a new model content object.
*
* @param parts The multi-part content message.
*/ | https://github.com/hypermodeinc/modus/blob/f2f0634dfc81c5a8fc99955b75ad581600de65d3/sdk/assemblyscript/src/models/gemini/generate.ts#L129-L131 | f2f0634dfc81c5a8fc99955b75ad581600de65d3 |
modus | github_2023 | hypermodeinc | typescript | TextGenerationModel.createInput | createInput(prompt: string): TextGenerationInput {
return <TextGenerationInput>{ prompt };
} | /**
* Creates a new input object for the model.
* @param prompt The prompt text to pass to the model.
* @returns A new input object.
* @remarks Optional properties may be set on the returned input object to
* control the behavior of the model.
*/ | https://github.com/hypermodeinc/modus/blob/f2f0634dfc81c5a8fc99955b75ad581600de65d3/sdk/assemblyscript/src/models/meta/llama.ts#L23-L25 | f2f0634dfc81c5a8fc99955b75ad581600de65d3 |
modus | github_2023 | hypermodeinc | typescript | OpenAIChatModel.createInput | createInput(messages: RequestMessage[]): OpenAIChatInput {
const model = this.info.fullName;
return <OpenAIChatInput>{ model, messages };
} | /**
* Creates an input object for the OpenAI Chat API.
*
* @param messages: An array of messages to send to the chat model.
* @returns An input object that can be passed to the `invoke` method.
*/ | https://github.com/hypermodeinc/modus/blob/f2f0634dfc81c5a8fc99955b75ad581600de65d3/sdk/assemblyscript/src/models/openai/chat.ts#L26-L29 | f2f0634dfc81c5a8fc99955b75ad581600de65d3 |
modus | github_2023 | hypermodeinc | typescript | OpenAIChatInput.requestAudioOutput | requestAudioOutput(voice: string, format: string): void {
this.modalities = [Modality.Text, Modality.Audio];
this.audio = new AudioParameters(voice, format);
} | /**
* Requests audio modality and sets the audio parameters for the input object.
* @param voice The voice the model should use for audio output, such as "ash" or "ballad".
* @param format The format of the audio data, such as "wav" or "mp3".
* @remarks See the model's documentation for a list of all supported voices and formats.
*/ | https://github.com/hypermodeinc/modus/blob/f2f0634dfc81c5a8fc99955b75ad581600de65d3/sdk/assemblyscript/src/models/openai/chat.ts#L69-L72 | f2f0634dfc81c5a8fc99955b75ad581600de65d3 |
modus | github_2023 | hypermodeinc | typescript | ToolChoice.constructor | private constructor(type: string, fnName: string | null = null) {
this.type = type;
if (fnName) {
this.function = { name: fnName };
}
} | /**
* Constructs a new tool choice object.
*
* @remarks
* Constructor is private to prevent direct instantiation.
* Use the static `None`, `Auto` or `Required` properties, or the static `Function` method instead.
*/ | https://github.com/hypermodeinc/modus/blob/f2f0634dfc81c5a8fc99955b75ad581600de65d3/sdk/assemblyscript/src/models/openai/chat.ts#L273-L278 | f2f0634dfc81c5a8fc99955b75ad581600de65d3 |
modus | github_2023 | hypermodeinc | typescript | ToolChoice.None | static get None(): ToolChoice {
return new ToolChoice("none");
} | /**
* Directs the model to not call any tool and instead generates a message.
*/ | https://github.com/hypermodeinc/modus/blob/f2f0634dfc81c5a8fc99955b75ad581600de65d3/sdk/assemblyscript/src/models/openai/chat.ts#L293-L295 | f2f0634dfc81c5a8fc99955b75ad581600de65d3 |
modus | github_2023 | hypermodeinc | typescript | ToolChoice.Auto | static get Auto(): ToolChoice {
return new ToolChoice("auto");
} | /**
* Directs the model to pick between generating a message or calling one or more tools.
*/ | https://github.com/hypermodeinc/modus/blob/f2f0634dfc81c5a8fc99955b75ad581600de65d3/sdk/assemblyscript/src/models/openai/chat.ts#L300-L302 | f2f0634dfc81c5a8fc99955b75ad581600de65d3 |
modus | github_2023 | hypermodeinc | typescript | ToolChoice.Required | static get Required(): ToolChoice {
return new ToolChoice("required");
} | /**
* Directs that the model must call one or more tools.
*/ | https://github.com/hypermodeinc/modus/blob/f2f0634dfc81c5a8fc99955b75ad581600de65d3/sdk/assemblyscript/src/models/openai/chat.ts#L307-L309 | f2f0634dfc81c5a8fc99955b75ad581600de65d3 |
modus | github_2023 | hypermodeinc | typescript | ToolChoice.Function | static Function(name: string): ToolChoice {
return new ToolChoice("function", name);
} | /**
* Forces the model to call a specific tool.
* @param name
* @returns
*/ | https://github.com/hypermodeinc/modus/blob/f2f0634dfc81c5a8fc99955b75ad581600de65d3/sdk/assemblyscript/src/models/openai/chat.ts#L316-L318 | f2f0634dfc81c5a8fc99955b75ad581600de65d3 |
modus | github_2023 | hypermodeinc | typescript | ToolChoice.__DESERIALIZE | __DESERIALIZE(
data: string,
key_start: i32,
key_end: i32,
value_start: i32,
value_end: i32,
): boolean {
throw new Error("Not implemented.");
} | /* eslint-disable @typescript-eslint/no-unused-vars */ | https://github.com/hypermodeinc/modus/blob/f2f0634dfc81c5a8fc99955b75ad581600de65d3/sdk/assemblyscript/src/models/openai/chat.ts#L333-L341 | f2f0634dfc81c5a8fc99955b75ad581600de65d3 |
modus | github_2023 | hypermodeinc | typescript | AudioParameters.constructor | constructor(voice: string, format: string) {
this.voice = voice;
this.format = format;
} | /**
* Creates a new audio output parameters object.
* @param voice The voice the model should use for audio output, such as "ash" or "ballad".
* @param format The format of the audio data, such as "wav" or "mp3".
*/ | https://github.com/hypermodeinc/modus/blob/f2f0634dfc81c5a8fc99955b75ad581600de65d3/sdk/assemblyscript/src/models/openai/chat.ts#L404-L407 | f2f0634dfc81c5a8fc99955b75ad581600de65d3 |
modus | github_2023 | hypermodeinc | typescript | OpenAIChatOutput.created | get created(): Date {
return new Date(this._created * 1000);
} | /**
* The timestamp of when the chat completion was created.
*/ | https://github.com/hypermodeinc/modus/blob/f2f0634dfc81c5a8fc99955b75ad581600de65d3/sdk/assemblyscript/src/models/openai/chat.ts#L446-L448 | f2f0634dfc81c5a8fc99955b75ad581600de65d3 |
modus | github_2023 | hypermodeinc | typescript | ResponseFormat.JsonSchema | static JsonSchema: JsonSchemaFunction = (
jsonSchema: string,
): ResponseFormat => {
return {
type: "json_schema",
jsonSchema: jsonSchema,
};
} | /**
* Enables Structured Outputs which guarantees the model will match your supplied JSON schema.
*
* See https://platform.openai.com/docs/guides/structured-outputs
*/ | https://github.com/hypermodeinc/modus/blob/f2f0634dfc81c5a8fc99955b75ad581600de65d3/sdk/assemblyscript/src/models/openai/chat.ts | f2f0634dfc81c5a8fc99955b75ad581600de65d3 |
modus | github_2023 | hypermodeinc | typescript | Tool.forFunction | static forFunction(name: string, description: string): Tool {
const tool = new Tool();
tool.function = <FunctionDefinition>{ name, description };
return tool;
} | /**
* Creates a new tool object for a function.
* @param name The name of the function to call.
* @param description The description of the function.
*/ | https://github.com/hypermodeinc/modus/blob/f2f0634dfc81c5a8fc99955b75ad581600de65d3/sdk/assemblyscript/src/models/openai/chat.ts#L568-L572 | f2f0634dfc81c5a8fc99955b75ad581600de65d3 |
modus | github_2023 | hypermodeinc | typescript | Tool.withParameter | withParameter(
name: string,
jsonSchemaType: string,
description: string,
): Tool {
const param = <funcParam>{
name: name,
type: jsonSchemaType,
description: description,
};
this._funcParams.push(param);
let schema = `{"type":"object","properties":{`;
for (let i = 0; i < this._funcParams.length; i++) {
if (i > 0) {
schema += ",";
}
const p = this._funcParams[i];
schema += `${JSON.stringify(p.name)}:{"type":${JSON.stringify(p.type)},"description":${JSON.stringify(p.description)}}`;
}
schema += `},"required":[`;
for (let i = 0; i < this._funcParams.length; i++) {
if (i > 0) {
schema += ",";
}
schema += JSON.stringify(this._funcParams[i].name);
}
schema += `],"additionalProperties":false}`;
this.function.parameters = schema;
return this;
} | /**
* Adds a parameter to the function used by the tool.
* Note that the type must be a valid JSON Schema type, not an AssemblyScript type.
* For example, use "integer", not "i32".
* @param name The name of the parameter.
* @param jsonSchemaType The JSON Schema type of the parameter.
* @param description The description of the parameter.
*/ | https://github.com/hypermodeinc/modus/blob/f2f0634dfc81c5a8fc99955b75ad581600de65d3/sdk/assemblyscript/src/models/openai/chat.ts#L582-L613 | f2f0634dfc81c5a8fc99955b75ad581600de65d3 |
modus | github_2023 | hypermodeinc | typescript | Tool.withParametersSchema | withParametersSchema(jsonSchema: string): Tool {
this.function.parameters = jsonSchema;
return this;
} | /**
* Sets the JSON Schema for the parameters of the function used by the tool.
* Use this for defining complex parameters. Prefer `withParameter` for adding simple parameters,
* which will generate the schema for you automatically.
* @jsonSchema A JSON Schema object as a string, describing the parameters the function accepts.
*/ | https://github.com/hypermodeinc/modus/blob/f2f0634dfc81c5a8fc99955b75ad581600de65d3/sdk/assemblyscript/src/models/openai/chat.ts#L621-L624 | f2f0634dfc81c5a8fc99955b75ad581600de65d3 |
modus | github_2023 | hypermodeinc | typescript | TextContentPart.constructor | constructor(text: string) {
super("text");
this.text = text;
} | /**
* Creates a new text content part.
*/ | https://github.com/hypermodeinc/modus/blob/f2f0634dfc81c5a8fc99955b75ad581600de65d3/sdk/assemblyscript/src/models/openai/chat.ts#L898-L901 | f2f0634dfc81c5a8fc99955b75ad581600de65d3 |
modus | github_2023 | hypermodeinc | typescript | ImageContentPart.constructor | constructor(image: Image) {
super("image_url");
this.image = image;
} | /**
* Creates a new image content part.
* The model must support image input for this to work.
* @param image The image information, created using the `Image.fromData` or `Image.fromURL` methods.
*/ | https://github.com/hypermodeinc/modus/blob/f2f0634dfc81c5a8fc99955b75ad581600de65d3/sdk/assemblyscript/src/models/openai/chat.ts#L919-L922 | f2f0634dfc81c5a8fc99955b75ad581600de65d3 |
modus | github_2023 | hypermodeinc | typescript | AudioContentPart.constructor | constructor(audio: Audio) {
super("input_audio");
this.audio = audio;
} | /**
* Creates a new audio content part.
* The model must support audio input for this to work.
* @param audio The audio information, created using the `Audio.fromData` method.
*/ | https://github.com/hypermodeinc/modus/blob/f2f0634dfc81c5a8fc99955b75ad581600de65d3/sdk/assemblyscript/src/models/openai/chat.ts#L941-L944 | f2f0634dfc81c5a8fc99955b75ad581600de65d3 |
modus | github_2023 | hypermodeinc | typescript | RefusalContentPart.constructor | constructor(refusal: string) {
super("refusal");
this.refusal = refusal;
} | /**
* Creates a new refusal content part.
* @param refusal The reason for the refusal.
*/ | https://github.com/hypermodeinc/modus/blob/f2f0634dfc81c5a8fc99955b75ad581600de65d3/sdk/assemblyscript/src/models/openai/chat.ts#L962-L965 | f2f0634dfc81c5a8fc99955b75ad581600de65d3 |
modus | github_2023 | hypermodeinc | typescript | Image.constructor | private constructor(url: string, detail: string | null) {
this.url = url;
this.detail = detail;
} | /**
* Creates a new image object.
* @param url The URL of the image.
* @param detail Specifies the detail level of the image.
*
* @remarks
* Constructor is private to prevent direct instantiation.
* Use the static `fromData` or `fromURL` methods instead.
*/ | https://github.com/hypermodeinc/modus/blob/f2f0634dfc81c5a8fc99955b75ad581600de65d3/sdk/assemblyscript/src/models/openai/chat.ts#L987-L990 | f2f0634dfc81c5a8fc99955b75ad581600de65d3 |
modus | github_2023 | hypermodeinc | typescript | Image.fromData | static fromData<T>(
data: T,
contentType: string,
detail: string | null = null,
): Image {
// Unlike audio, the url needs to contain a full mime type, not just the format.
// Thus, add the "image/" prefix if it's missing.
if (!contentType.startsWith("image/")) {
contentType = "image/" + contentType;
}
let str: string;
if (idof<T>() == idof<Uint8Array>()) {
str = base64.encode(data as Uint8Array);
} else if (isString(data)) {
str = data as string;
} else {
throw new Error(
"Invalid image data type. Data must be a Uint8Array or a base64-encoded string.",
);
}
const url = `data:${contentType};base64,${str}`;
return new Image(url, detail);
} | /**
* Creates a new image object from raw image data.
* @param data The raw image data, supplied as either a `Uint8Array` or a base64-encoded string.
* @param contentType A valid image MIME type supported by the model, such as "image/jpeg" or "image/png".
* @param detail Specifies the detail level of the image. Can be set to "low", "high", or "auto". The default is "auto".
*/ | https://github.com/hypermodeinc/modus/blob/f2f0634dfc81c5a8fc99955b75ad581600de65d3/sdk/assemblyscript/src/models/openai/chat.ts#L1011-L1035 | f2f0634dfc81c5a8fc99955b75ad581600de65d3 |
modus | github_2023 | hypermodeinc | typescript | Image.fromURL | static fromURL(url: string, detail: string | null = null): Image {
return new Image(url, detail);
} | /**
* Creates a new image object from a URL.
* The URL will be sent directly to the model.
* @param url The URL of the image.
* @param detail Specifies the detail level of the image. Can be set to "low", "high", or "auto". The default is "auto".
*/ | https://github.com/hypermodeinc/modus/blob/f2f0634dfc81c5a8fc99955b75ad581600de65d3/sdk/assemblyscript/src/models/openai/chat.ts#L1043-L1045 | f2f0634dfc81c5a8fc99955b75ad581600de65d3 |
modus | github_2023 | hypermodeinc | typescript | Audio.constructor | private constructor(data: Uint8Array, format: string) {
this._data = base64.encode(data);
this.format = format;
} | /**
* Creates a new audio object.
* @param data The raw audio data.
* @param format A valid audio format supported by the model, such as "wav" or "mp3".
*
* @remarks
* Constructor is private to prevent direct instantiation.
* Use the static `fromData` method instead.
*/ | https://github.com/hypermodeinc/modus/blob/f2f0634dfc81c5a8fc99955b75ad581600de65d3/sdk/assemblyscript/src/models/openai/chat.ts#L1062-L1065 | f2f0634dfc81c5a8fc99955b75ad581600de65d3 |
modus | github_2023 | hypermodeinc | typescript | AudioOutput.data | get data(): Uint8Array {
return base64.decode(this._data);
} | /**
* The raw audio data, in the format specified in the request.
*/ | https://github.com/hypermodeinc/modus/blob/f2f0634dfc81c5a8fc99955b75ad581600de65d3/sdk/assemblyscript/src/models/openai/chat.ts#L1070-L1072 | f2f0634dfc81c5a8fc99955b75ad581600de65d3 |
modus | github_2023 | hypermodeinc | typescript | Audio.fromData | static fromData<T>(data: T, format: string): Audio {
// Unlike images, the model expects just the format, not a mime type.
// Thus, strip the "audio/" prefix if present.
if (format.startsWith("audio/")) {
format = format.substring(6);
}
let buf: Uint8Array;
if (idof<T>() == idof<Uint8Array>()) {
buf = data as Uint8Array;
} else if (isString(data)) {
buf = base64.decode(data as string);
} else {
throw new Error(
"Invalid audio data type. Data must be a Uint8Array or a base64-encoded string.",
);
}
return new Audio(buf, format);
} | /**
* Creates a new audio object from raw audio data.
* @param data The raw audio data, supplied as either a `Uint8Array` or a base64-encoded string.
* @param format A valid audio format supported by the model, such as "wav" or "mp3".
*/ | https://github.com/hypermodeinc/modus/blob/f2f0634dfc81c5a8fc99955b75ad581600de65d3/sdk/assemblyscript/src/models/openai/chat.ts#L1092-L1111 | f2f0634dfc81c5a8fc99955b75ad581600de65d3 |
modus | github_2023 | hypermodeinc | typescript | SystemMessage.constructor | constructor(content: T) {
super("system");
if (isString(content)) {
this.content = content;
} else if (isArray(content)) {
const arr = content as ContentPart[];
for (let i = 0; i < arr.length; i++) {
const t = arr[i].type;
if (t != "text") {
throw new Error(
"Invalid content part type. Content parts must be of text type.",
);
}
}
this.content = content;
} else {
throw new Error(
"Invalid content type. Content must be a string or an array of content parts.",
);
}
} | /**
* Creates a new system message object.
*
* @param content The contents of the message, as either a string or as an array of text content parts.
*
* @remarks
* Note that system and developer messages are identical in functionality,
* but the "system" role was renamed to "developer" in the OpenAI Chat API.
* Certain models may require one or the other, so use the type that matches the model's requirements.
*/ | https://github.com/hypermodeinc/modus/blob/f2f0634dfc81c5a8fc99955b75ad581600de65d3/sdk/assemblyscript/src/models/openai/chat.ts#L1135-L1156 | f2f0634dfc81c5a8fc99955b75ad581600de65d3 |
modus | github_2023 | hypermodeinc | typescript | SystemMessage.fromParts | static fromParts(parts: ContentPart[]): SystemMessage<ContentPart[]> {
return new SystemMessage(parts);
} | /**
* Creates a new system message object from content parts.
* The parts should be `TextContentPart` objects.
* @param parts The content parts of the message.
*/ | https://github.com/hypermodeinc/modus/blob/f2f0634dfc81c5a8fc99955b75ad581600de65d3/sdk/assemblyscript/src/models/openai/chat.ts#L1175-L1177 | f2f0634dfc81c5a8fc99955b75ad581600de65d3 |
modus | github_2023 | hypermodeinc | typescript | DeveloperMessage.constructor | constructor(content: T) {
super("developer");
if (isString(content)) {
this.content = content;
} else if (isArray(content)) {
const arr = content as ContentPart[];
for (let i = 0; i < arr.length; i++) {
const t = arr[i].type;
if (t != "text") {
throw new Error(
"Invalid content part type. Content parts must be of text type.",
);
}
}
this.content = content;
} else {
throw new Error(
"Invalid content type. Content must be a string or an array of content parts.",
);
}
} | /**
* Creates a new developer message object.
*
* @param content The contents of the message.
*
* @remarks
* Note that system and developer messages are identical in functionality,
* but the "system" role was renamed to "developer" in the OpenAI Chat API.
* Certain models may require one or the other, so use the type that matches the model's requirements.
*/ | https://github.com/hypermodeinc/modus/blob/f2f0634dfc81c5a8fc99955b75ad581600de65d3/sdk/assemblyscript/src/models/openai/chat.ts#L1201-L1222 | f2f0634dfc81c5a8fc99955b75ad581600de65d3 |
modus | github_2023 | hypermodeinc | typescript | DeveloperMessage.fromParts | static fromParts(parts: ContentPart[]): DeveloperMessage<ContentPart[]> {
return new DeveloperMessage(parts);
} | /**
* Creates a new developer message object from content parts.
* The parts should be `TextContentPart` objects.
* @param parts The content parts of the message.
*/ | https://github.com/hypermodeinc/modus/blob/f2f0634dfc81c5a8fc99955b75ad581600de65d3/sdk/assemblyscript/src/models/openai/chat.ts#L1241-L1243 | f2f0634dfc81c5a8fc99955b75ad581600de65d3 |
modus | github_2023 | hypermodeinc | typescript | UserMessage.constructor | constructor(content: T) {
super("user");
if (isString(content)) {
this.content = content;
} else if (isArray(content)) {
const arr = content as ContentPart[];
for (let i = 0; i < arr.length; i++) {
const t = arr[i].type;
if (t != "text" && t != "image_url" && t != "input_audio") {
throw new Error(
"Invalid content part type. Content parts must be of text, image, or audio type.",
);
}
}
this.content = content;
} else {
throw new Error(
"Invalid content type. Content must be a string or an array of content parts.",
);
}
} | /**
* Creates a new user message object.
* @param content The contents of the message, as either a string or as an array of text, image, or audio content parts.
*/ | https://github.com/hypermodeinc/modus/blob/f2f0634dfc81c5a8fc99955b75ad581600de65d3/sdk/assemblyscript/src/models/openai/chat.ts#L1255-L1276 | f2f0634dfc81c5a8fc99955b75ad581600de65d3 |
modus | github_2023 | hypermodeinc | typescript | UserMessage.fromParts | static fromParts(parts: ContentPart[]): UserMessage<ContentPart[]> {
return new UserMessage(parts);
} | /**
* Creates a new user message object from content parts.
* The parts should be `TextContentPart`, `ImageContentPart`, or `AudioContentPart` objects.
* @param parts The content parts of the message.
*/ | https://github.com/hypermodeinc/modus/blob/f2f0634dfc81c5a8fc99955b75ad581600de65d3/sdk/assemblyscript/src/models/openai/chat.ts#L1295-L1297 | f2f0634dfc81c5a8fc99955b75ad581600de65d3 |
modus | github_2023 | hypermodeinc | typescript | AssistantMessage.constructor | constructor(content: T) {
super("assistant");
if (isString(content)) {
this.content = content;
} else if (isArray(content)) {
const arr = content as ContentPart[];
for (let i = 0; i < arr.length; i++) {
const t = arr[i].type;
if (t != "text" && t != "refusal") {
throw new Error(
"Invalid content part type. Content parts must be of text or refusal type.",
);
}
}
this.content = content;
} else {
throw new Error(
"Invalid content type. Content must be a string or an array of content parts.",
);
}
} | /**
* Creates a new assistant message object.
*
* @param content The contents of the message.
*/ | https://github.com/hypermodeinc/modus/blob/f2f0634dfc81c5a8fc99955b75ad581600de65d3/sdk/assemblyscript/src/models/openai/chat.ts#L1310-L1331 | f2f0634dfc81c5a8fc99955b75ad581600de65d3 |
modus | github_2023 | hypermodeinc | typescript | AssistantMessage.fromParts | static fromParts(parts: ContentPart[]): AssistantMessage<ContentPart[]> {
return new AssistantMessage(parts);
} | /**
* Creates a new assistant message object from content parts.
* The parts should be `TextContentPart` or `RefusalContentPart` objects.
* @param parts The content parts of the message.
*/ | https://github.com/hypermodeinc/modus/blob/f2f0634dfc81c5a8fc99955b75ad581600de65d3/sdk/assemblyscript/src/models/openai/chat.ts#L1368-L1370 | f2f0634dfc81c5a8fc99955b75ad581600de65d3 |
modus | github_2023 | hypermodeinc | typescript | AssistantMessage.fromCompletionMessage | static fromCompletionMessage(
cm: CompletionMessage,
): AssistantMessage<string> {
return cm.toAssistantMessage();
} | /**
* Creates a new assistant message object from a completion message, so it can be used in a conversation.
*/ | https://github.com/hypermodeinc/modus/blob/f2f0634dfc81c5a8fc99955b75ad581600de65d3/sdk/assemblyscript/src/models/openai/chat.ts#L1375-L1379 | f2f0634dfc81c5a8fc99955b75ad581600de65d3 |
modus | github_2023 | hypermodeinc | typescript | AudioRef.constructor | constructor(id: string) {
this.id = id;
} | /**
* Creates a new audio reference object.
* @param id Unique identifier for a previous audio response from the model.
*/ | https://github.com/hypermodeinc/modus/blob/f2f0634dfc81c5a8fc99955b75ad581600de65d3/sdk/assemblyscript/src/models/openai/chat.ts#L1390-L1392 | f2f0634dfc81c5a8fc99955b75ad581600de65d3 |
modus | github_2023 | hypermodeinc | typescript | ToolMessage.constructor | constructor(content: T, toolCallId: string) {
super("tool");
this.toolCallId = toolCallId;
if (isString(content)) {
this.content = content;
} else if (isArray(content)) {
const arr = content as ContentPart[];
for (let i = 0; i < arr.length; i++) {
const t = arr[i].type;
if (t != "text") {
throw new Error(
"Invalid content part type. Content parts must be of text type.",
);
}
}
this.content = content;
} else {
throw new Error(
"Invalid content type. Content must be a string or an array of content parts.",
);
}
} | /**
* Creates a new tool message object.
*
* @param content The contents of the message.
* @param toolCallId The tool call that this message is responding to.
*/ | https://github.com/hypermodeinc/modus/blob/f2f0634dfc81c5a8fc99955b75ad581600de65d3/sdk/assemblyscript/src/models/openai/chat.ts#L1411-L1433 | f2f0634dfc81c5a8fc99955b75ad581600de65d3 |
modus | github_2023 | hypermodeinc | typescript | ToolMessage.fromParts | static fromParts(
toolCallId: string,
parts: ContentPart[],
): ToolMessage<ContentPart[]> {
return new ToolMessage(parts, toolCallId);
} | /**
* Creates a new tool message object from content parts.
* The parts should be `TextContentPart` objects.
* @param toolCallId The tool call that this message is responding to.
* @param parts The content parts of the message.
*/ | https://github.com/hypermodeinc/modus/blob/f2f0634dfc81c5a8fc99955b75ad581600de65d3/sdk/assemblyscript/src/models/openai/chat.ts#L1452-L1457 | f2f0634dfc81c5a8fc99955b75ad581600de65d3 |
modus | github_2023 | hypermodeinc | typescript | CompletionMessage.toAssistantMessage | toAssistantMessage(): AssistantMessage<string> {
const am = new AssistantMessage<string>(this.content);
am.refusal = this.refusal;
am.toolCalls = this.toolCalls;
if (this.audio) {
am.audio = new AudioRef(this.audio!.id);
}
return am;
} | /**
* Converts the completion message to an assistant message, so it can be used in a conversation.
*/ | https://github.com/hypermodeinc/modus/blob/f2f0634dfc81c5a8fc99955b75ad581600de65d3/sdk/assemblyscript/src/models/openai/chat.ts#L1497-L1507 | f2f0634dfc81c5a8fc99955b75ad581600de65d3 |
modus | github_2023 | hypermodeinc | typescript | AudioOutput.expiresAt | get expiresAt(): Date {
return new Date(this._expiresAt * 1000);
} | /**
* The time at which this audio content will no longer be accessible on the server for use in multi-turn conversations.
*/ | https://github.com/hypermodeinc/modus/blob/f2f0634dfc81c5a8fc99955b75ad581600de65d3/sdk/assemblyscript/src/models/openai/chat.ts#L1523-L1525 | f2f0634dfc81c5a8fc99955b75ad581600de65d3 |
modus | github_2023 | hypermodeinc | typescript | OpenAIEmbeddingsModel.createInput | createInput<T>(content: T): OpenAIEmbeddingsInput {
const model = this.info.fullName;
switch (idof<T>()) {
case idof<string>():
case idof<string[]>():
case idof<i64[]>():
case idof<i32[]>():
case idof<i16[]>():
case idof<i8[]>():
case idof<u64[]>():
case idof<u32[]>():
case idof<u16[]>():
case idof<u8[]>():
case idof<i64[][]>():
case idof<i32[][]>():
case idof<i16[][]>():
case idof<i8[][]>():
case idof<u64[][]>():
case idof<u32[][]>():
case idof<u16[][]>():
case idof<u8[][]>():
return <TypedEmbeddingsInput<T>>{ model, input: content };
}
throw new Error("Unsupported input content type.");
} | /**
* Creates an input object for the OpenAI Embeddings API.
*
* @param content The input content to vectorize. Can be any of:
* - A string representing the text to vectorize.
* - An array of strings representing multiple texts to vectorize.
* - An array of integers representing pre-tokenized text to vectorize.
* - An array of arrays of integers representing multiple pre-tokenized texts to vectorize.
*
* @returns An input object that can be passed to the `invoke` method.
*
* @remarks
* The input content must not exceed the maximum token limit of the model.
*/ | https://github.com/hypermodeinc/modus/blob/f2f0634dfc81c5a8fc99955b75ad581600de65d3/sdk/assemblyscript/src/models/openai/embeddings.ts#L35-L61 | f2f0634dfc81c5a8fc99955b75ad581600de65d3 |
Syntax.js | github_2023 | williamtroup | typescript | render | function render() : void {
const tagTypes: string[] = _configuration.highlightAllDomElementTypes as string[];
const tagTypesLength: number = tagTypes.length;
for ( let tagTypeIndex: number = 0; tagTypeIndex < tagTypesLength; tagTypeIndex++ ) {
const domElements: HTMLCollectionOf<Element> = document.getElementsByTagName( tagTypes[ tagTypeIndex ] );
const elements: HTMLElement[] = [].slice.call( domElements );
const elementsLength: number = elements.length;
if ( elementsLength > 0 ) {
Trigger.customEvent( _configuration.events!.onBeforeRender! );
}
for ( let elementIndex: number = 0; elementIndex < elementsLength; elementIndex++ ) {
const element: HTMLElement = elements[ elementIndex ];
let elementBreak: boolean = false;
if ( element.hasAttribute( Constant.SYNTAX_JS_ATTRIBUTE_NAME_LANGUAGE ) && element.getAttribute( Constant.SYNTAX_JS_ATTRIBUTE_NAME_LANGUAGE )!.toLowerCase() === Language.tabbed ) {
const divElements: HTMLElement[] = [].slice.call( element.children );
const divElementsLength: number = divElements.length;
const tabElements: HTMLElement[] = [];
const tabContentElements: HTMLElement[] = [];
element.removeAttribute( Constant.SYNTAX_JS_ATTRIBUTE_NAME_LANGUAGE );
element.className = element.className === Char.empty ? "syntax-highlight" : `${element.className} syntax-highlight`;
element.innerHTML = Char.empty;
const codeContainer: HTMLElement = DomElement.create( "div", "code custom-scroll-bars" );
element.appendChild( codeContainer );
const tabs: HTMLElement = DomElement.create( "div", "tabs" );
codeContainer.appendChild( tabs );
for ( let divElementIndex: number = 0; divElementIndex < divElementsLength; divElementIndex++ ) {
const renderResult: RenderElementResult = renderElement( divElements[ divElementIndex ], codeContainer );
if ( !renderResult.rendered ) {
elementBreak = true;
} else {
renderTab( tabs, tabElements, tabContentElements, renderResult, divElementIndex, renderResult.tabBindingOptions, renderResult.syntaxLanguage );
}
}
} else {
if ( !renderElement( element ).rendered ) {
elementBreak = true;
}
}
if ( elementBreak ) {
break;
}
}
if ( elementsLength > 0 ) {
Trigger.customEvent( _configuration.events!.onAfterRender! );
}
}
} | /*
* ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
* Rendering
* ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
*/ | https://github.com/williamtroup/Syntax.js/blob/60ad74ca902def89d9cfeac6405cd7e6e56053df/src/syntax.ts#L81-L140 | 60ad74ca902def89d9cfeac6405cd7e6e56053df |
Syntax.js | github_2023 | williamtroup | typescript | getObjectFromString | function getObjectFromString( objectString: any ) : StringToJson {
const result: StringToJson = {
parsed: true,
object: null
} as StringToJson;
try {
if ( Is.definedString( objectString ) ) {
result.object = JSON.parse( objectString );
}
} catch ( e1: any ) {
try {
result.object = eval( `(${objectString})` );
if ( Is.definedFunction( result.object ) ) {
result.object = result.object();
}
} catch ( e2: any ) {
if ( !_configuration.safeMode ) {
logError( _configuration.text!.objectErrorText!.replace( "{{error_1}}", e1.message ).replace( "{{error_2}}", e2.message ) );
result.parsed = false;
}
result.object = null;
}
}
return result;
} | /*
* ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
* Default Parameter/Option Handling
* ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
*/ | https://github.com/williamtroup/Syntax.js/blob/60ad74ca902def89d9cfeac6405cd7e6e56053df/src/syntax.ts#L987-L1017 | 60ad74ca902def89d9cfeac6405cd7e6e56053df |
expo-speech-recognition | github_2023 | jamsch | typescript | ExpoSpeechRecognitionModuleWeb.bindEventListener | bindEventListener = <T extends keyof SpeechRecognitionEventMap>(
eventName: T,
ev: SpeechRecognitionEventMap[T],
) => {
const eventPayload = webToNativeEventMap[eventName]?.(ev);
this.emit(
eventName,
// @ts-expect-error payload typings are incorrect
eventPayload,
);
} | // Convert the web event to the native event | https://github.com/jamsch/expo-speech-recognition/blob/e1d414bb9ee0c75dfd5a6f568211e6961bd54071/src/ExpoSpeechRecognitionModule.web.ts | e1d414bb9ee0c75dfd5a6f568211e6961bd54071 |
expo-speech-recognition | github_2023 | jamsch | typescript | nativeListener | const nativeListener = (ev: SpeechRecognitionEventMap[EventName]) => {
const handler =
eventName in webToNativeEventMap
? webToNativeEventMap[eventName as keyof SpeechRecognitionEventMap]
: null;
// @ts-expect-error payload typings are incorrect
const eventPayload = handler?.(ev);
// @ts-expect-error
listener(eventPayload);
}; | // Convert the web event to the native event | https://github.com/jamsch/expo-speech-recognition/blob/e1d414bb9ee0c75dfd5a6f568211e6961bd54071/src/ExpoSpeechRecognitionModule.web.ts#L49-L60 | e1d414bb9ee0c75dfd5a6f568211e6961bd54071 |
expo-speech-recognition | github_2023 | jamsch | typescript | ExpoSpeechRecognitionModuleWeb.getSpeechRecognitionServices | getSpeechRecognitionServices() {
return [] as string[];
} | // removeListeners() {} | https://github.com/jamsch/expo-speech-recognition/blob/e1d414bb9ee0c75dfd5a6f568211e6961bd54071/src/ExpoSpeechRecognitionModule.web.ts#L241-L243 | e1d414bb9ee0c75dfd5a6f568211e6961bd54071 |
expo-speech-recognition | github_2023 | jamsch | typescript | ExpoWebSpeechRecognition.onstart | get onstart() {
return this.#onstart;
} | /** Fired when the speech recognition starts. */ | https://github.com/jamsch/expo-speech-recognition/blob/e1d414bb9ee0c75dfd5a6f568211e6961bd54071/src/ExpoWebSpeechRecognition.ts#L242-L244 | e1d414bb9ee0c75dfd5a6f568211e6961bd54071 |
expo-speech-recognition | github_2023 | jamsch | typescript | ExpoWebSpeechRecognition.onend | get onend() {
return this.#onend;
} | /** Fired when the speech recognition service has disconnected. */ | https://github.com/jamsch/expo-speech-recognition/blob/e1d414bb9ee0c75dfd5a6f568211e6961bd54071/src/ExpoWebSpeechRecognition.ts#L258-L260 | e1d414bb9ee0c75dfd5a6f568211e6961bd54071 |
expo-speech-recognition | github_2023 | jamsch | typescript | ExpoWebSpeechRecognition.onerror | get onerror() {
return this.#onerror;
} | /** Fired when the speech recognition service encounters an error. */ | https://github.com/jamsch/expo-speech-recognition/blob/e1d414bb9ee0c75dfd5a6f568211e6961bd54071/src/ExpoWebSpeechRecognition.ts#L268-L270 | e1d414bb9ee0c75dfd5a6f568211e6961bd54071 |
expo-speech-recognition | github_2023 | jamsch | typescript | ExpoWebSpeechRecognition.onresult | get onresult() {
return this.#onresult;
} | /** Fired when the speech recognition service returns a result —
* a word or phrase has been positively recognized and this has been communicated back to the app. */ | https://github.com/jamsch/expo-speech-recognition/blob/e1d414bb9ee0c75dfd5a6f568211e6961bd54071/src/ExpoWebSpeechRecognition.ts#L292-L294 | e1d414bb9ee0c75dfd5a6f568211e6961bd54071 |
expo-speech-recognition | github_2023 | jamsch | typescript | ExpoWebSpeechRecognition.onnomatch | get onnomatch() {
return this.#onnomatch;
} | /** Fired when the speech recognition service returns a final result with no significant recognition. */ | https://github.com/jamsch/expo-speech-recognition/blob/e1d414bb9ee0c75dfd5a6f568211e6961bd54071/src/ExpoWebSpeechRecognition.ts#L302-L304 | e1d414bb9ee0c75dfd5a6f568211e6961bd54071 |
expo-speech-recognition | github_2023 | jamsch | typescript | ExpoWebSpeechRecognition.onspeechstart | get onspeechstart() {
return this.#onspeechstart;
} | /** Fired when the speech recognition service returns a final result with no significant recognition. */ | https://github.com/jamsch/expo-speech-recognition/blob/e1d414bb9ee0c75dfd5a6f568211e6961bd54071/src/ExpoWebSpeechRecognition.ts#L312-L314 | e1d414bb9ee0c75dfd5a6f568211e6961bd54071 |
expo-speech-recognition | github_2023 | jamsch | typescript | ExpoWebSpeechRecognition.onspeechend | get onspeechend() {
return this.#onspeechend;
} | /** Fired when the speech recognition service returns a final result with no significant recognition. */ | https://github.com/jamsch/expo-speech-recognition/blob/e1d414bb9ee0c75dfd5a6f568211e6961bd54071/src/ExpoWebSpeechRecognition.ts#L322-L324 | e1d414bb9ee0c75dfd5a6f568211e6961bd54071 |
expo-speech-recognition | github_2023 | jamsch | typescript | ExpoWebSpeechRecognition.onaudiostart | get onaudiostart() {
return this.#onaudiostart;
} | /** Fired when the user agent has started to capture audio. */ | https://github.com/jamsch/expo-speech-recognition/blob/e1d414bb9ee0c75dfd5a6f568211e6961bd54071/src/ExpoWebSpeechRecognition.ts#L332-L334 | e1d414bb9ee0c75dfd5a6f568211e6961bd54071 |
expo-speech-recognition | github_2023 | jamsch | typescript | ExpoWebSpeechRecognition.onaudioend | get onaudioend() {
return this.#onaudioend;
} | /** Fired when the user agent has finished capturing audio. */ | https://github.com/jamsch/expo-speech-recognition/blob/e1d414bb9ee0c75dfd5a6f568211e6961bd54071/src/ExpoWebSpeechRecognition.ts#L342-L344 | e1d414bb9ee0c75dfd5a6f568211e6961bd54071 |
expo-speech-recognition | github_2023 | jamsch | typescript | ExpoWebSpeechGrammarList.addFromURI | addFromURI(src: string, weight?: number | undefined): void {
// todo
} | // Indexer property | https://github.com/jamsch/expo-speech-recognition/blob/e1d414bb9ee0c75dfd5a6f568211e6961bd54071/src/ExpoWebSpeechRecognition.ts#L423-L425 | e1d414bb9ee0c75dfd5a6f568211e6961bd54071 |
expo-speech-recognition | github_2023 | jamsch | typescript | ExpoSpeechRecognitionResult.item | item(index: number): SpeechRecognitionAlternative {
return this.#alternatives[index];
} | /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/SpeechRecognitionResult/item) */ | https://github.com/jamsch/expo-speech-recognition/blob/e1d414bb9ee0c75dfd5a6f568211e6961bd54071/src/ExpoWebSpeechRecognition.ts#L477-L479 | e1d414bb9ee0c75dfd5a6f568211e6961bd54071 |
vue3-blog | github_2023 | Peerless-man | typescript | pathResolve | const pathResolve = (dir: string): string => {
return resolve(__dirname, ".", dir);
}; | /** 路径查找 */ | https://github.com/Peerless-man/vue3-blog/blob/dab914ac92f37eaf15520b79718d687eab71b7af/blog-v3-admin/vite.config.ts#L14-L16 | dab914ac92f37eaf15520b79718d687eab71b7af |
vue3-blog | github_2023 | Peerless-man | typescript | warpperEnv | const warpperEnv = (envConf: Recordable): ViteEnv => {
/** 此处为默认值 */
const ret: ViteEnv = {
VITE_PORT: 8848,
VITE_PUBLIC_PATH: "",
VITE_ROUTER_HISTORY: "",
VITE_CDN: false,
VITE_COMPRESSION: "none"
};
for (const envName of Object.keys(envConf)) {
let realName = envConf[envName].replace(/\\n/g, "\n");
realName =
realName === "true" ? true : realName === "false" ? false : realName;
if (envName === "VITE_PORT") {
realName = Number(realName);
}
ret[envName] = realName;
if (typeof realName === "string") {
process.env[envName] = realName;
} else if (typeof realName === "object") {
process.env[envName] = JSON.stringify(realName);
}
}
return ret;
}; | /** 处理环境变量 */ | https://github.com/Peerless-man/vue3-blog/blob/dab914ac92f37eaf15520b79718d687eab71b7af/blog-v3-admin/build/index.ts#L2-L28 | dab914ac92f37eaf15520b79718d687eab71b7af |
vue3-blog | github_2023 | Peerless-man | typescript | setLayoutThemeColor | function setLayoutThemeColor(theme = "default") {
layoutTheme.value.theme = theme;
toggleTheme({
scopeName: `layout-theme-${theme}`
});
$storage.layout = {
layout: layout.value,
theme,
darkMode: dataTheme.value,
sidebarStatus: $storage.layout?.sidebarStatus,
epThemeColor: $storage.layout?.epThemeColor
};
if (theme === "default" || theme === "light") {
setEpThemeColor(getConfig().EpThemeColor);
} else {
const colors = themeColors.value.find(v => v.themeColor === theme);
setEpThemeColor(colors.color);
}
} | /** 设置导航主题色 */ | https://github.com/Peerless-man/vue3-blog/blob/dab914ac92f37eaf15520b79718d687eab71b7af/blog-v3-admin/src/layout/hooks/useDataThemeChange.ts#L41-L60 | dab914ac92f37eaf15520b79718d687eab71b7af |
vue3-blog | github_2023 | Peerless-man | typescript | setEpThemeColor | const setEpThemeColor = (color: string) => {
useEpThemeStoreHook().setEpThemeColor(color);
document.documentElement.style.setProperty("--el-color-primary", color);
for (let i = 1; i <= 2; i++) {
setPropertyPrimary("dark", i, color);
}
for (let i = 1; i <= 9; i++) {
setPropertyPrimary("light", i, color);
}
}; | /** 设置 `element-plus` 主题色 */ | https://github.com/Peerless-man/vue3-blog/blob/dab914ac92f37eaf15520b79718d687eab71b7af/blog-v3-admin/src/layout/hooks/useDataThemeChange.ts#L70-L79 | dab914ac92f37eaf15520b79718d687eab71b7af |
vue3-blog | github_2023 | Peerless-man | typescript | dataThemeChange | function dataThemeChange() {
/* 如果当前是light夜间主题,默认切换到default主题 */
if (useEpThemeStoreHook().epTheme === "light" && dataTheme.value) {
setLayoutThemeColor("default");
} else {
setLayoutThemeColor(useEpThemeStoreHook().epTheme);
}
if (dataTheme.value) {
document.documentElement.classList.add("dark");
} else {
document.documentElement.classList.remove("dark");
}
} | /** 日间、夜间主题切换 */ | https://github.com/Peerless-man/vue3-blog/blob/dab914ac92f37eaf15520b79718d687eab71b7af/blog-v3-admin/src/layout/hooks/useDataThemeChange.ts#L82-L95 | dab914ac92f37eaf15520b79718d687eab71b7af |
vue3-blog | github_2023 | Peerless-man | typescript | changeTitle | function changeTitle(meta: routeMetaType) {
const Title = getConfig().Title;
if (Title) document.title = `${meta.title} | ${Title}`;
else document.title = meta.title;
} | /** 动态title */ | https://github.com/Peerless-man/vue3-blog/blob/dab914ac92f37eaf15520b79718d687eab71b7af/blog-v3-admin/src/layout/hooks/useNav.ts#L60-L64 | dab914ac92f37eaf15520b79718d687eab71b7af |
vue3-blog | github_2023 | Peerless-man | typescript | logout | function logout() {
useUserStoreHook().logOut();
} | /** 退出登录 */ | https://github.com/Peerless-man/vue3-blog/blob/dab914ac92f37eaf15520b79718d687eab71b7af/blog-v3-admin/src/layout/hooks/useNav.ts#L67-L69 | dab914ac92f37eaf15520b79718d687eab71b7af |
vue3-blog | github_2023 | Peerless-man | typescript | findCurrentRoute | function findCurrentRoute(indexPath: string, routes) {
if (!routes) return console.error(errorInfo);
return routes.map(item => {
if (item.path === indexPath) {
if (item.redirect) {
findCurrentRoute(item.redirect, item.children);
} else {
/** 切换左侧菜单 通知标签页 */
emitter.emit("changLayoutRoute", {
indexPath,
parentPath
});
}
} else {
if (item.children) findCurrentRoute(indexPath, item.children);
}
});
} | /** 找到当前路由的信息 */ | https://github.com/Peerless-man/vue3-blog/blob/dab914ac92f37eaf15520b79718d687eab71b7af/blog-v3-admin/src/layout/hooks/useNav.ts#L107-L124 | dab914ac92f37eaf15520b79718d687eab71b7af |
vue3-blog | github_2023 | Peerless-man | typescript | isRemaining | function isRemaining(path: string): boolean {
return remainingPaths.includes(path);
} | /** 判断路径是否参与菜单 */ | https://github.com/Peerless-man/vue3-blog/blob/dab914ac92f37eaf15520b79718d687eab71b7af/blog-v3-admin/src/layout/hooks/useNav.ts#L129-L131 | dab914ac92f37eaf15520b79718d687eab71b7af |
vue3-blog | github_2023 | Peerless-man | typescript | onMouseenter | function onMouseenter(index) {
if (index) activeIndex.value = index;
if (unref(showModel) === "smart") {
if (hasClass(instance.refs["schedule" + index][0], "schedule-active"))
return;
toggleClass(true, "schedule-in", instance.refs["schedule" + index][0]);
toggleClass(false, "schedule-out", instance.refs["schedule" + index][0]);
} else {
if (hasClass(instance.refs["dynamic" + index][0], "card-active")) return;
toggleClass(true, "card-in", instance.refs["dynamic" + index][0]);
toggleClass(false, "card-out", instance.refs["dynamic" + index][0]);
}
} | /** 鼠标移入添加激活样式 */ | https://github.com/Peerless-man/vue3-blog/blob/dab914ac92f37eaf15520b79718d687eab71b7af/blog-v3-admin/src/layout/hooks/useTag.ts#L160-L172 | dab914ac92f37eaf15520b79718d687eab71b7af |
vue3-blog | github_2023 | Peerless-man | typescript | onMouseleave | function onMouseleave(index) {
activeIndex.value = -1;
if (unref(showModel) === "smart") {
if (hasClass(instance.refs["schedule" + index][0], "schedule-active"))
return;
toggleClass(false, "schedule-in", instance.refs["schedule" + index][0]);
toggleClass(true, "schedule-out", instance.refs["schedule" + index][0]);
} else {
if (hasClass(instance.refs["dynamic" + index][0], "card-active")) return;
toggleClass(false, "card-in", instance.refs["dynamic" + index][0]);
toggleClass(true, "card-out", instance.refs["dynamic" + index][0]);
}
} | /** 鼠标移出恢复默认样式 */ | https://github.com/Peerless-man/vue3-blog/blob/dab914ac92f37eaf15520b79718d687eab71b7af/blog-v3-admin/src/layout/hooks/useTag.ts#L175-L187 | dab914ac92f37eaf15520b79718d687eab71b7af |
vue3-blog | github_2023 | Peerless-man | typescript | toCorrectRoute | function toCorrectRoute() {
whiteList.includes(to.fullPath) ? next(_from.fullPath) : next();
} | /** 如果已经登录并存在登录信息后不能跳转到路由白名单,而是继续保持在当前页面 */ | https://github.com/Peerless-man/vue3-blog/blob/dab914ac92f37eaf15520b79718d687eab71b7af/blog-v3-admin/src/router/index.ts#L172-L174 | dab914ac92f37eaf15520b79718d687eab71b7af |
vue3-blog | github_2023 | Peerless-man | typescript | handRank | function handRank(routeInfo: any) {
const { name, path, parentId, meta } = routeInfo;
return isAllEmpty(parentId)
? isAllEmpty(meta?.rank) ||
(meta?.rank === 0 && name !== "Home" && path !== "/")
? true
: false
: false;
} | // 动态路由 | https://github.com/Peerless-man/vue3-blog/blob/dab914ac92f37eaf15520b79718d687eab71b7af/blog-v3-admin/src/router/utils.ts#L31-L39 | dab914ac92f37eaf15520b79718d687eab71b7af |
vue3-blog | github_2023 | Peerless-man | typescript | ascending | function ascending(arr: any[]) {
arr.forEach((v, index) => {
// 当rank不存在时,根据顺序自动创建,首页路由永远在第一位
if (handRank(v)) v.meta.rank = index + 2;
});
return arr.sort(
(a: { meta: { rank: number } }, b: { meta: { rank: number } }) => {
return a?.meta.rank - b?.meta.rank;
}
);
} | /** 按照路由中meta下的rank等级升序来排序路由 */ | https://github.com/Peerless-man/vue3-blog/blob/dab914ac92f37eaf15520b79718d687eab71b7af/blog-v3-admin/src/router/utils.ts#L42-L52 | dab914ac92f37eaf15520b79718d687eab71b7af |
vue3-blog | github_2023 | Peerless-man | typescript | filterTree | function filterTree(data: RouteComponent[]) {
const newTree = cloneDeep(data).filter(
(v: { meta: { showLink: boolean } }) => v.meta?.showLink !== false
);
newTree.forEach(
(v: { children }) => v.children && (v.children = filterTree(v.children))
);
return newTree;
} | /** 过滤meta中showLink为false的菜单 */ | https://github.com/Peerless-man/vue3-blog/blob/dab914ac92f37eaf15520b79718d687eab71b7af/blog-v3-admin/src/router/utils.ts#L55-L63 | dab914ac92f37eaf15520b79718d687eab71b7af |
vue3-blog | github_2023 | Peerless-man | typescript | filterChildrenTree | function filterChildrenTree(data: RouteComponent[]) {
const newTree = cloneDeep(data).filter((v: any) => v?.children?.length !== 0);
newTree.forEach(
(v: { children }) => v.children && (v.children = filterTree(v.children))
);
return newTree;
} | /** 过滤children长度为0的的目录,当目录下没有菜单时,会过滤此目录,目录没有赋予roles权限,当目录下只要有一个菜单有显示权限,那么此目录就会显示 */ | https://github.com/Peerless-man/vue3-blog/blob/dab914ac92f37eaf15520b79718d687eab71b7af/blog-v3-admin/src/router/utils.ts#L66-L72 | dab914ac92f37eaf15520b79718d687eab71b7af |
vue3-blog | github_2023 | Peerless-man | typescript | isOneOfArray | function isOneOfArray(a: Array<string>, b: Array<number>) {
return Array.isArray(a) && Array.isArray(b)
? intersection(a, b).length > 0
? true
: false
: true;
} | /** 判断两个数组彼此是否存在相同值 */ | https://github.com/Peerless-man/vue3-blog/blob/dab914ac92f37eaf15520b79718d687eab71b7af/blog-v3-admin/src/router/utils.ts#L75-L81 | dab914ac92f37eaf15520b79718d687eab71b7af |
vue3-blog | github_2023 | Peerless-man | typescript | filterNoPermissionTree | function filterNoPermissionTree(data: RouteComponent[]) {
const currentRoles =
storageSession().getItem<DataInfo<number>>(sessionKey)?.role;
const newTree = cloneDeep(data).filter((v: any) =>
isOneOfArray(v.meta?.roles, [currentRoles])
);
newTree.forEach(
(v: any) => v.children && (v.children = filterNoPermissionTree(v.children))
);
return filterChildrenTree(newTree);
} | /** 从sessionStorage里取出当前登陆用户的角色roles,过滤无权限的菜单 */ | https://github.com/Peerless-man/vue3-blog/blob/dab914ac92f37eaf15520b79718d687eab71b7af/blog-v3-admin/src/router/utils.ts#L84-L94 | dab914ac92f37eaf15520b79718d687eab71b7af |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.