Documentation Index Fetch the complete documentation index at: https://nvd-54.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
This notebook provides a quick overview for getting started with LangSmithLoader document loaders . For detailed documentation of all LangSmithLoader features and configurations head to the API reference .
集成详情
Loader features
Source Web Loader Node Envs Only LangSmithLoader✅ ❌
要访问 the LangSmith document loader,你需要install @langchain/core, create a LangSmith account and get an API key.
Sign up at langsmith.com and generate an API key. Once you’ve done this set the LANGSMITH_API_KEY environment variable:
export LANGSMITH_API_KEY = "your-api-key"
The LangSmithLoader integration lives in the @langchain/core package:
npm install @langchain/core
Create example dataset
For this example, we’ll create a new dataset which we’ll use in our document loader.
import { Client as LangSmithClient } from 'langsmith' ;
import { faker } from "@faker-js/faker" ;
const lsClient = new LangSmithClient () ;
const datasetName = "LangSmith Few Shot Datasets Notebook" ;
const exampleInputs = Array . from ( { length : 10 }, ( _ , i ) => ( {
input : faker . lorem . paragraph () ,
} )) ;
const exampleOutputs = Array . from ( { length : 10 }, ( _ , i ) => ( {
output : faker . lorem . sentence () ,
} )) ;
const exampleMetadata = Array . from ( { length : 10 }, ( _ , i ) => ( {
companyCatchPhrase : faker . company . catchPhrase () ,
} )) ;
await lsClient . deleteDataset ( {
datasetName ,
} )
const dataset = await lsClient . createDataset (datasetName) ;
const examples = await lsClient . createExamples ( {
inputs : exampleInputs ,
outputs : exampleOutputs ,
metadata : exampleMetadata ,
datasetId : dataset . id ,
} ) ;
import { LangSmithLoader } from "@langchain/core/document_loaders/langsmith"
const loader = new LangSmithLoader ( {
datasetName : "LangSmith Few Shot Datasets Notebook" ,
// Instead of a datasetName, you can alternatively provide a datasetId
// datasetId: dataset.id,
contentKey : "input" ,
limit : 5 ,
// formatContent: (content) => content,
// ... other options
} )
Load
const docs = await loader . load ()
docs[ 0 ]
{
pageContent : 'Conventus supellex aegrotatio termes. Vapulus abscido ubi vita coadunatio modi crapula comparo caecus. Acervus voluptate tergeo pariatur conor argumentum inventore vomito stella.' ,
metadata : {
id : 'f1a04800-6f7a-4232-9743-fb5d9029bf1f' ,
created_at : '2024-08-20T17:01:38.984045+00:00' ,
modified_at : '2024-08-20T17:01:38.984045+00:00' ,
name : '#f1a0 @ LangSmith Few Shot Datasets Notebook' ,
dataset_id : '9ccd66e6-e506-478c-9095-3d9e27575a89' ,
source_run_id : null ,
metadata : {
dataset_split : [Array] ,
companyCatchPhrase : 'Integrated solution-oriented secured line'
},
inputs : {
input : 'Conventus supellex aegrotatio termes. Vapulus abscido ubi vita coadunatio modi crapula comparo caecus. Acervus voluptate tergeo pariatur conor argumentum inventore vomito stella.'
},
outputs : {
output : 'Excepturi adeptio spectaculum bis volaticus accusamus.'
}
}
}
console . log (docs[ 0 ] . metadata)
{
id : 'f1a04800-6f7a-4232-9743-fb5d9029bf1f' ,
created_at : '2024-08-20T17:01:38.984045+00:00' ,
modified_at : '2024-08-20T17:01:38.984045+00:00' ,
name : '#f1a0 @ LangSmith Few Shot Datasets Notebook' ,
dataset_id : '9ccd66e6-e506-478c-9095-3d9e27575a89' ,
source_run_id : null ,
metadata : {
dataset_split : [ 'base' ] ,
companyCatchPhrase : 'Integrated solution-oriented secured line'
},
inputs : {
input : 'Conventus supellex aegrotatio termes. Vapulus abscido ubi vita coadunatio modi crapula comparo caecus. Acervus voluptate tergeo pariatur conor argumentum inventore vomito stella.'
},
outputs : { output : 'Excepturi adeptio spectaculum bis volaticus accusamus.' }
}
console . log (docs[ 0 ] . metadata . inputs)
{
input : 'Conventus supellex aegrotatio termes. Vapulus abscido ubi vita coadunatio modi crapula comparo caecus. Acervus voluptate tergeo pariatur conor argumentum inventore vomito stella.'
}
console . log (docs[ 0 ] . metadata . outputs)
{ output : 'Excepturi adeptio spectaculum bis volaticus accusamus.' }
console . log (Object . keys (docs[ 0 ] . metadata))
[
'id' ,
'created_at' ,
'modified_at' ,
'name' ,
'dataset_id' ,
'source_run_id' ,
'metadata' ,
'inputs' ,
'outputs'
]
API 参考
For detailed documentation of all LangSmithLoader features and configurations head to the API reference
将这些文档连接到 Claude、VSCode 等工具,通过 MCP 获取实时答案。