> Discover all available pages from the documentation index: https://mastra.zisheng.pro/ko/llms.txt # LangSmith 수출업체 [랭스미스](https://smith.langchain.com/)LLM 응용 프로그램을 모니터링하고 평가하기 위한 LangChain의 플랫폼입니다. LangSmith 내보내기는 추적을 LangSmith로 보내 Model 성능, 디버깅 기능, 평가 Workflow에 대한 통찰력을 제공합니다. ## 설치 **npm**: ```bash npm install @mastra/langsmith@latest ``` **pnpm**: ```bash pnpm add @mastra/langsmith@latest ``` **Yarn**: ```bash yarn add @mastra/langsmith@latest ``` **Bun**: ```bash bun add @mastra/langsmith@latest ``` ## 구성 ### 전제조건 1. **랭스미스 계정**: 가입하세요[smith.langchain.com](https://smith.langchain.com) 2. **API 키**: LangSmith 설정 → API 키에서 API 키를 생성합니다. 3. **환경 변수**: 자격 증명을 설정하세요 ```bash # Required LANGSMITH_API_KEY=ls-xxxxxxxxxxxx # Optional LANGCHAIN_PROJECT=my-project # Default project for traces LANGSMITH_BASE_URL=https://api.smith.langchain.com # For self-hosted ``` ### 제로 구성 설정 환경 변수가 설정된 경우 구성 없이 내보내기를 사용합니다. ```typescript import { Mastra } from '@mastra/core' import { Observability } from '@mastra/observability' import { LangSmithExporter } from '@mastra/langsmith' export const mastra = new Mastra({ observability: new Observability({ configs: { langsmith: { serviceName: 'my-service', exporters: [new LangSmithExporter()], }, }, }), }) ``` ### 명시적 구성 자격 증명을 직접 전달할 수도 있습니다(환경 변수보다 우선 적용됨). ```typescript import { Mastra } from '@mastra/core' import { Observability } from '@mastra/observability' import { LangSmithExporter } from '@mastra/langsmith' export const mastra = new Mastra({ observability: new Observability({ configs: { langsmith: { serviceName: 'my-service', exporters: [ new LangSmithExporter({ apiKey: process.env.LANGSMITH_API_KEY, }), ], }, }, }), }) ``` ## 구성 옵션 ### 완전한 구성 ```typescript new LangSmithExporter({ // Required credentials apiKey: process.env.LANGSMITH_API_KEY!, // Optional settings apiUrl: process.env.LANGSMITH_BASE_URL, // Default: https://api.smith.langchain.com projectName: 'my-project', // Project to send traces to (overrides LANGCHAIN_PROJECT env var) callerOptions: { // HTTP client options timeout: 30000, // Request timeout in ms maxRetries: 3, // Retry attempts }, logLevel: 'info', // Diagnostic logging: debug | info | warn | error // LangSmith-specific options hideInputs: false, // Hide input data in UI hideOutputs: false, // Hide output data in UI }) ``` ### 환경변수 | 변수 | 설명 | | -------------------------------------------------------------------------------------------------- | ---------------------------------------- | | `LANGSMITH_API_KEY` | LangSmith API 키(필수) | | `LANGCHAIN_PROJECT` | Trace의 기본 프로젝트 이름(선택 사항, 기본값은 "default") | | `LANGSMITH_BASE_URL` | 자체 호스팅 인스턴스의 API URL(선택 사항) | | `projectName` 구성 옵션은 `LANGCHAIN_PROJECT` 환경 변수보다 우선하므로, 프로그래밍 방식으로 Trace를 서로 다른 프로젝트에 라우팅할 수 있습니다. | | ## 동적 구성 런타임에 `withLangsmithMetadata`를 사용하여 스팬별 LangSmith 설정을 재정의할 수 있습니다. 이는 런타임 조건(예: 고객, 환경 또는 기능)에 따라 Trace를 서로 다른 프로젝트로 라우팅할 때 유용합니다. ### 도우미 사용 LangSmith 전용 옵션을 설정하려면 `withLangsmithMetadata`를 `buildTracingOptions`와 함께 사용하세요. ```typescript import { Agent } from '@mastra/core/agent' import { buildTracingOptions } from '@mastra/observability' import { withLangsmithMetadata } from '@mastra/langsmith' export const supportAgent = new Agent({ id: 'support-agent', name: 'support-agent', instructions: 'You are a helpful support agent.', model: 'openai/gpt-5.6-sol', defaultOptions: { tracingOptions: buildTracingOptions(withLangsmithMetadata({ projectName: 'customer-support' })), }, }) ``` ### 동적 프로젝트 라우팅 런타임 조건에 따라 Trace를 서로 다른 프로젝트로 라우팅하려면 `requestContext`를 사용하세요. ```typescript import { Agent } from '@mastra/core/agent' import { buildTracingOptions } from '@mastra/observability' import { withLangsmithMetadata } from '@mastra/langsmith' export const supportAgent = new Agent({ id: 'support-agent', name: 'support-agent', instructions: 'You are a helpful support agent.', model: 'openai/gpt-5.6-sol', defaultOptions: ({ requestContext }) => { const userTier = requestContext?.get('user-tier') as string const userId = requestContext?.get('user-id') as string return { tracingOptions: buildTracingOptions( withLangsmithMetadata({ projectName: userTier === 'enterprise' ? 'enterprise-traces' : 'standard-traces', sessionId: userId, }), ), } }, }) ``` ### 사용 가능한 필드 그만큼`withLangsmithMetadata` helper accepts these fields: | 필드 | 유형 | 설명 | | ---------------------------------------------------------------------- | ------ | ------------------ | | `projectName` | string | 이 Trace의 프로젝트 재정의 | | `sessionId` | string | 관련 Trace를 세션별로 그룹화 | | `sessionName` | string | 세션의 표시 이름 | | 모든 필드는 선택 사항입니다. 도우미는 기존 메타데이터와 병합되므로 여러 번 호출하거나 다른 추적 옵션과 결합할 수 있습니다. | | | ## 관련된 - [추적 개요](https://mastra.zisheng.pro/ko/docs/observability/tracing/overview) - [LangSmith 문서](https://docs.smith.langchain.com/)