import { MorphAPIClient } from '../../core/client.js'; import { APIResource } from '../../core/resource.js'; import { CreateReflexJobInput, ReflexJob, ListReflexJobsInput, ReflexJobList, DeletedReflexJob, ReflexEvent, ReflexConfig, ReflexPredictInput, ReflexPredictResult, ReflexPredictManyInput, ReflexPredictManyResult } from './types.js'; import '../utils/resilience.js'; /** * Reflex: train and serve small text classifiers. * * const morph = new MorphClient({ apiKey }); * const job = await morph.reflex.jobs.create({ trainingData: rows, suffix: 'support' }); * const ready = await morph.reflex.jobs.waitForReady(job.id); * const out = await morph.reflex.predict({ model: ready.fineTunedModel!, text: 'refund please' }); * * Mirrors the OpenAI fine-tuning shape (`reflex.jobs.create/retrieve/list/cancel/delete`) * plus `reflex.predict`. All HTTP goes through the shared `MorphAPIClient` transport. */ /** * @deprecated Prefer the unified `MorphClient` (`new MorphClient({ apiKey }).reflex`). * Standalone clients remain only for backwards compatibility and may be removed in a future * major version — do not use them in new code. */ declare class ReflexClient extends APIResource { /** Train, retrieve, and manage classifier jobs. */ readonly jobs: ReflexJobsResource; constructor(clientOrConfig?: MorphAPIClient | ReflexConfig); /** Classify text against one trained model. The model must be `succeeded`. */ predict(input: ReflexPredictInput): Promise; /** * Classify text against several models in one request. They share a single * prefill, so the input is tokenized once — cheaper and faster than a call per * model. Each model returns its own prediction (or an `error` if it failed). */ predictMany(input: ReflexPredictManyInput): Promise; } declare class ReflexJobsResource extends APIResource { /** Start a training job from labeled data, a description, or unlabeled text. */ create(input: CreateReflexJobInput): Promise; /** Fetch a job by id. */ retrieve(id: string): Promise; /** List the caller's jobs, newest first. */ list(input?: ListReflexJobsInput): Promise; /** Stop a queued or running job. */ cancel(id: string): Promise; /** Delete a job and its trained model. */ delete(id: string): Promise; /** The training loss curve as events, plus a terminal event. */ events(id: string): Promise; /** * Poll until the job reaches a terminal status and return it on success. * Throws a `MorphError` if it fails, is cancelled, or exceeds `timeoutMs`. */ waitForReady(id: string, opts?: { pollMs?: number; timeoutMs?: number; }): Promise; } export { ReflexClient, ReflexJobsResource };