Skip to main content
LangSmith playground를 사용하면 자체 커스텀 모델을 사용할 수 있습니다. LangChain 애플리케이션을 서빙하기 위한 오픈 소스 라이브러리를 통해 모델의 API를 노출하는 모델 서버를 배포할 수 있습니다. 배후에서 playground는 모델 서버와 상호작용하여 응답을 생성합니다.

커스텀 모델 서버 배포

편의를 위해 참고용으로 사용할 수 있는 샘플 모델 서버를 제공했습니다. 샘플 모델 서버는 여기에서 찾을 수 있습니다. 샘플 모델 서버를 시작점으로 사용하는 것을 적극 권장합니다. 모델이 instruct 스타일인지 chat 스타일인지에 따라 각각 custom_model.py 또는 custom_chat_model.py를 구현해야 합니다.

구성 가능한 필드 추가

다양한 매개변수로 모델을 구성하는 것이 유용한 경우가 많습니다. 여기에는 temperature, model_name, max_tokens 등이 포함될 수 있습니다. LangSmith playground에서 모델을 구성 가능하게 만들려면 모델 서버에 구성 가능한 필드를 추가해야 합니다. 이러한 필드는 playground에서 모델 매개변수를 변경하는 데 사용할 수 있습니다. config.py 파일에서 with_configurable_fields 함수를 구현하여 구성 가능한 필드를 추가할 수 있습니다:
def with_configurable_fields(self) -> Runnable:
    """Expose fields you want to be configurable in the playground. We will automatically expose these to the
    playground. If you don't want to expose any fields, you can remove this method."""
    return self.configurable_fields(n=ConfigurableField(
        id="n",
        name="Num Characters",
        description="Number of characters to return from the input prompt.",
    ))

LangSmith Playground에서 모델 사용

모델 서버를 배포한 후 LangSmith Playground에서 사용할 수 있습니다. playground에 들어가서 chat 스타일 모델 또는 instruct 스타일 모델에 대해 ChatCustomModel 또는 CustomModel 공급자를 선택하세요. URL을 입력하세요. playground는 사용 가능한 엔드포인트와 구성 가능한 필드를 자동으로 감지합니다. 그런 다음 원하는 매개변수로 모델을 호출할 수 있습니다. ChatCustomModel in Playground 모든 것이 올바르게 설정되면 playground에서 모델의 응답과 with_configurable_fields에 지정된 구성 가능한 필드를 볼 수 있습니다. 나중에 사용하기 위해 모델 구성을 저장하는 방법은 여기를 참조하세요.
Connect these docs programmatically to Claude, VSCode, and more via MCP for real-time answers.
I