PromptLayer는 prompt engineering을 위한 플랫폼입니다. 또한 요청을 시각화하고, prompt 버전을 관리하며, 사용량을 추적하는 LLM observability 기능을 제공합니다.이 가이드에서는PromptLayer는 LangChain과 직접 통합되는 LLM을 제공하지만(예:PromptLayerOpenAI), callback을 사용하는 것이PromptLayer를 LangChain과 통합하는 권장 방법입니다.
PromptLayerCallbackHandler를 설정하는 방법을 다룹니다.
자세한 내용은 PromptLayer 문서를 참조하세요.
Installation and Setup
Getting API Credentials
PromptLayer 계정이 없다면 promptlayer.com에서 계정을 생성하세요. 그런 다음 navbar의 설정 톱니바퀴를 클릭하여 API key를 받고PROMPTLAYER_API_KEY라는 환경 변수로 설정하세요.
Usage
PromptLayerCallbackHandler 시작하기는 매우 간단합니다. 두 개의 선택적 인자를 받습니다:
pl_tags- PromptLayer에서 tag로 추적될 문자열 목록(선택 사항).pl_id_callback-promptlayer_request_id를 인자로 받는 함수(선택 사항). 이 ID는 PromptLayer의 모든 추적 기능과 함께 사용하여 metadata, score, prompt 사용량을 추적할 수 있습니다.
Simple OpenAI Example
이 간단한 예제에서는ChatOpenAI와 함께 PromptLayerCallbackHandler를 사용합니다. chatopenai라는 PromptLayer tag를 추가합니다.
GPT4All Example
Full Featured Example
이 예제에서는PromptLayer의 더 많은 기능을 활용합니다.
PromptLayer를 사용하면 prompt template을 시각적으로 생성하고, 버전을 관리하며, 추적할 수 있습니다. Prompt Registry를 사용하여 example이라는 prompt template을 프로그래밍 방식으로 가져올 수 있습니다.
또한 promptlayer_request_id를 받아 score, metadata를 기록하고 사용된 prompt template을 연결하는 pl_id_callback 함수를 정의합니다. 추적에 대한 자세한 내용은 문서를 참조하세요.
Connect these docs programmatically to Claude, VSCode, and more via MCP for real-time answers.