kopia lustrzana https://github.com/transitive-bullshit/chatgpt-api
docs: add TSDoc comments
rodzic
15a0c83cb9
commit
e7b30853b6
|
@ -70,7 +70,7 @@ export class Agentic extends EventEmitter {
|
||||||
ky?: types.KyInstance
|
ky?: types.KyInstance
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A task tracker or `false` to disable. By default, tasks will be tracked via the terminal.
|
* A task tracker or `false` to disable. By default, tasks will be tracked via the terminal (assuming `stderr` is a TTY).
|
||||||
*/
|
*/
|
||||||
taskTracker?: TaskTracker | false
|
taskTracker?: TaskTracker | false
|
||||||
} = {}
|
} = {}
|
||||||
|
|
|
@ -42,27 +42,33 @@ type HumanFeedbackMechanismConstructor<
|
||||||
*/
|
*/
|
||||||
export type HumanFeedbackOptions<T extends HumanFeedbackType, TOutput> = {
|
export type HumanFeedbackOptions<T extends HumanFeedbackType, TOutput> = {
|
||||||
/**
|
/**
|
||||||
* What type of feedback to request.
|
* What type of feedback to request. Default: `'confirm'`.
|
||||||
|
*
|
||||||
|
* Possible values:
|
||||||
|
*
|
||||||
|
* - `'confirm'`: The user is asked to confirm the generated output of the task.
|
||||||
|
* - `'select'`: The user is asked to select exactly one of the outputs to keep (assumes output is an array).
|
||||||
|
* - `'multiselect'`: The user is asked to select any number of outputs to keep (assumes output is an array).
|
||||||
*/
|
*/
|
||||||
type?: T
|
type?: T
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether the user can abort the process.
|
* Whether the user can abort the process. Default: `false`.
|
||||||
*/
|
*/
|
||||||
abort?: boolean
|
abort?: boolean
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether the user can edit the output.
|
* Whether the user can edit the output. Default: `false`.
|
||||||
*/
|
*/
|
||||||
editing?: boolean
|
editing?: boolean
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether the user can add free-form text annotations.
|
* Whether the user can add free-form text annotations. Default: `false`.
|
||||||
*/
|
*/
|
||||||
annotations?: boolean
|
annotations?: boolean
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The human feedback mechanism to use for this task.
|
* The human feedback mechanism to use for this task. By default, human feedback is requested via the CLI.
|
||||||
*/
|
*/
|
||||||
mechanism?: HumanFeedbackMechanismConstructor<T, TOutput>
|
mechanism?: HumanFeedbackMechanismConstructor<T, TOutput>
|
||||||
|
|
||||||
|
@ -72,7 +78,7 @@ export type HumanFeedbackOptions<T extends HumanFeedbackType, TOutput> = {
|
||||||
outputLabel?: string
|
outputLabel?: string
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Timeout in milliseconds after which waiting for any user input is aborted (default: +Infinity, i.e. no timeout.)
|
* Timeout in milliseconds after which waiting for any user input is aborted. Default: `+Infinity`, i.e., no timeout.
|
||||||
*/
|
*/
|
||||||
timeoutMs?: number
|
timeoutMs?: number
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,6 +85,9 @@ export abstract class BaseTask<
|
||||||
this._agentic = agentic
|
this._agentic = agentic
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unique identifier for the task.
|
||||||
|
*/
|
||||||
public get id(): string {
|
public get id(): string {
|
||||||
return this._id
|
return this._id
|
||||||
}
|
}
|
||||||
|
@ -93,18 +96,34 @@ export abstract class BaseTask<
|
||||||
return this._agentic.logger
|
return this._agentic.logger
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Zod schema for the task's input.
|
||||||
|
*/
|
||||||
public abstract get inputSchema(): ZodType<TInput>
|
public abstract get inputSchema(): ZodType<TInput>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Zod schema for the task's output.
|
||||||
|
*/
|
||||||
public abstract get outputSchema(): ZodType<TOutput>
|
public abstract get outputSchema(): ZodType<TOutput>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Name of the task for use by language model.
|
||||||
|
*/
|
||||||
public get nameForModel(): string {
|
public get nameForModel(): string {
|
||||||
const name = this.constructor.name
|
const name = this.constructor.name
|
||||||
return name[0].toLowerCase() + name.slice(1)
|
return name[0].toLowerCase() + name.slice(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Human-readable name of the task.
|
||||||
|
*/
|
||||||
public get nameForHuman(): string {
|
public get nameForHuman(): string {
|
||||||
return this.constructor.name
|
return this.constructor.name
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Task description for use by language model.
|
||||||
|
*/
|
||||||
public get descForModel(): string {
|
public get descForModel(): string {
|
||||||
return ''
|
return ''
|
||||||
}
|
}
|
||||||
|
@ -217,11 +236,17 @@ export abstract class BaseTask<
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets retry configuration for this task.
|
||||||
|
*/
|
||||||
public retryConfig(retryConfig: types.RetryConfig): this {
|
public retryConfig(retryConfig: types.RetryConfig): this {
|
||||||
this._retryConfig = retryConfig
|
this._retryConfig = retryConfig
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets cache configuration for this task.
|
||||||
|
*/
|
||||||
public cacheConfig(cacheConfig: types.CacheConfig<TInput, TOutput>): this {
|
public cacheConfig(cacheConfig: types.CacheConfig<TInput, TOutput>): this {
|
||||||
this._cacheConfig = cacheConfig
|
this._cacheConfig = cacheConfig
|
||||||
return this
|
return this
|
||||||
|
|
|
@ -36,11 +36,29 @@ export type SafeParsedData<T extends ZodTypeAny> = T extends ZodTypeAny
|
||||||
: never
|
: never
|
||||||
|
|
||||||
export interface BaseTaskOptions {
|
export interface BaseTaskOptions {
|
||||||
|
/**
|
||||||
|
* Agentic instance
|
||||||
|
*/
|
||||||
agentic?: Agentic
|
agentic?: Agentic
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Number of milliseconds to wait before timing out.
|
||||||
|
*/
|
||||||
timeoutMs?: number
|
timeoutMs?: number
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Configuration for retrying failed requests.
|
||||||
|
*/
|
||||||
retryConfig?: RetryConfig
|
retryConfig?: RetryConfig
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cache storage configuration for memoization / storage of task results.
|
||||||
|
*/
|
||||||
cacheConfig?: CacheConfig<any, any>
|
cacheConfig?: CacheConfig<any, any>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Task identifier
|
||||||
|
*/
|
||||||
id?: string
|
id?: string
|
||||||
|
|
||||||
// TODO
|
// TODO
|
||||||
|
@ -54,14 +72,36 @@ export interface BaseLLMOptions<
|
||||||
TOutput extends TaskOutput = string,
|
TOutput extends TaskOutput = string,
|
||||||
TModelParams extends Record<string, any> = Record<string, any>
|
TModelParams extends Record<string, any> = Record<string, any>
|
||||||
> extends BaseTaskOptions {
|
> extends BaseTaskOptions {
|
||||||
|
/**
|
||||||
|
* Zod schema for validating LLM input.
|
||||||
|
*/
|
||||||
inputSchema?: ZodType<TInput>
|
inputSchema?: ZodType<TInput>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Zod schema for validating LLM output.
|
||||||
|
*/
|
||||||
outputSchema?: ZodType<TOutput>
|
outputSchema?: ZodType<TOutput>
|
||||||
|
|
||||||
cacheConfig?: CacheConfig<TInput, TOutput>
|
cacheConfig?: CacheConfig<TInput, TOutput>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* LLM provider to use.
|
||||||
|
*/
|
||||||
provider?: string
|
provider?: string
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Name of the model to use.
|
||||||
|
*/
|
||||||
model?: string
|
model?: string
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Model parameters to use.
|
||||||
|
*/
|
||||||
modelParams?: TModelParams
|
modelParams?: TModelParams
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Input / output pairs to include in the prompt.
|
||||||
|
*/
|
||||||
examples?: LLMExample[]
|
examples?: LLMExample[]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -121,6 +161,9 @@ export interface LLMExample {
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface RetryConfig extends RetryOptions {
|
export interface RetryConfig extends RetryOptions {
|
||||||
|
/**
|
||||||
|
* Retry strategy to use (default: `'heal'`).
|
||||||
|
*/
|
||||||
strategy?: string
|
strategy?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Ładowanie…
Reference in New Issue