Learn more about Mintlify
Enter your email to receive updates about new features and product releases.
TypeScript types and interfaces used in the LangSmith SDK
interface Run extends BaseRun {
id: string;
session_id?: string;
child_run_ids?: string[];
child_runs?: Run[];
feedback_stats?: KVMap;
app_path?: string;
status?: string;
prompt_tokens?: number;
completion_tokens?: number;
total_tokens?: number;
}
interface BaseRun {
id?: string;
name: string;
start_time?: number | string;
run_type: string;
end_time?: number | string;
extra?: KVMap;
error?: string;
serialized?: object;
events?: KVMap[];
inputs: KVMap;
outputs?: KVMap;
reference_example_id?: string;
parent_run_id?: string;
tags?: string[];
trace_id?: string;
dotted_order?: string;
attachments?: Attachments;
}
interface RunCreate extends BaseRun {
revision_id?: string;
child_runs?: RunCreate[];
session_name?: string;
}
interface RunUpdate {
id?: string;
name?: string;
run_type?: string;
start_time?: number | string;
end_time?: number | string;
extra?: KVMap;
tags?: string[];
error?: string;
serialized?: object;
inputs?: KVMap;
outputs?: KVMap;
parent_run_id?: string;
reference_example_id?: string;
events?: KVMap[];
session_id?: string;
session_name?: string;
trace_id?: string;
dotted_order?: string;
attachments?: Attachments;
}
interface Dataset extends BaseDataset {
id: string;
created_at: string;
modified_at: string;
example_count?: number;
session_count?: number;
last_session_start_time?: number;
}
interface BaseDataset {
name: string;
description: string;
tenant_id: string;
data_type?: DataType;
inputs_schema_definition?: KVMap;
outputs_schema_definition?: KVMap;
}
interface Example extends BaseExample {
id: string;
created_at: string;
modified_at?: string;
source_run_id?: string;
runs: Run[];
attachments?: Record<string, AttachmentInfo>;
split?: string | string[];
}
interface ExampleCreate {
id?: string;
inputs: KVMap;
outputs?: KVMap;
metadata?: KVMap;
split?: string | string[];
attachments?: Attachments;
created_at?: string;
dataset_id?: string;
dataset_name?: string;
source_run_id?: string;
use_source_run_io?: boolean;
use_source_run_attachments?: string[];
}
interface Feedback extends FeedbackBase {
id: string;
}
interface FeedbackBase {
created_at: string;
modified_at: string;
run_id: string;
key: string;
score: ScoreType;
value: ValueType;
comment: string | null;
correction: string | object | null;
feedback_source: APIFeedbackSource | ModelFeedbackSource | KVMap | null;
}
interface FeedbackConfig {
type: "continuous" | "categorical" | "freeform";
min?: number | null;
max?: number | null;
categories?: FeedbackCategory[] | null;
}
interface FeedbackCategory {
value: number;
label?: string | null;
}
interface TracerSession {
tenant_id: string;
id: string;
start_time: number;
end_time?: number;
description?: string;
name?: string;
extra?: KVMap;
reference_dataset_id?: string;
}
interface TracerSessionResult extends TracerSession {
run_count?: number;
latency_p50?: number;
latency_p99?: number;
total_tokens?: number;
prompt_tokens?: number;
completion_tokens?: number;
last_run_start_time?: number;
feedback_stats?: Record<string, unknown>;
run_facets?: KVMap[];
}
interface InvocationParamsSchema {
ls_provider?: string;
ls_model_name?: string;
ls_model_type: "chat" | "llm";
ls_temperature?: number;
ls_max_tokens?: number;
ls_stop?: string[];
ls_invocation_params?: Record<string, unknown>;
}
type KVMap = Record<string, any>;
type ScoreType = number | boolean | null;
type ValueType = number | boolean | string | object | null;
type DataType = "kv" | "llm" | "chat";
type RunType =
| "llm"
| "chain"
| "tool"
| "retriever"
| "embedding"
| "prompt"
| "parser";
type Attachments = Record<
string,
[string, AttachmentData] | AttachmentDescription
>;
type AttachmentData = Uint8Array | ArrayBuffer;
type AttachmentDescription = {
mimeType: string;
data: AttachmentData;
};
interface AttachmentInfo {
presigned_url: string;
mime_type?: string;
}
interface Prompt {
id: string;
repo_handle: string;
description: string | null;
readme: string | null;
num_likes: number;
num_downloads: number;
num_views: number;
liked_by_auth_user: boolean;
last_committed_at: string;
num_commits: number;
original_repo_id: string | null;
original_repo_full_name: string | null;
is_public: boolean;
is_archived: boolean;
tags: string[];
}
interface PromptCommit {
owner: string;
repo: string;
commit_hash: string;
manifest: Record<string, any>;
examples: any[];
}
interface ComparativeExperiment {
id: string;
name: string;
description: string;
tenant_id: string;
created_at: string;
modified_at: string;
reference_dataset_id: string;
extra?: Record<string, unknown>;
experiments_info?: Array<Record<string, unknown>>;
feedback_stats?: Record<string, unknown>;
}
interface ComparisonEvaluationResult {
key: string;
scores: Record<string, ScoreType>;
source_run_id?: string;
}
type RetrieverOutput = Array<{
page_content: string;
type: "Document";
metadata?: KVMap;
}>;
import type {
Run,
RunCreate,
Example,
Feedback,
InvocationParamsSchema,
KVMap,
} from "langsmith";
const runCreate: RunCreate = {
name: "my-chain",
run_type: "chain",
inputs: { query: "Hello" },
outputs: { response: "Hi!" },
tags: ["production"],
};
const invocationParams: InvocationParamsSchema = {
ls_provider: "openai",
ls_model_type: "chat",
ls_model_name: "gpt-4",
ls_temperature: 0.7,
ls_max_tokens: 1000,
};