dspy.JSONAdapter

dspy.JSONAdapter

이 페이지는 DSPy의 JSONAdapter를 다뤄요. 시그니처와 데모를 JSON 스키마 형식으로 변환하고, LM의 JSON 응답을 파싱해서 Prediction으로 만들어요. 구조화된 출력이 필요한 웹 API나 프로그램 간 연동 작업에서 특히 잘 맞아요.

출처: 문서

본문

JSONAdapter는 출력 필드를 JSON 스키마로 요구하고, LM이 반환한 JSON을 검증·파싱해 시그니처 필드에 매핑해요. JSON으로 출력을 강제하기 때문에 자유 형식 텍스트가 섞일 여지가 적고, 필드 타입이 명확한 결과를 얻기 좋아요. 아래는 이 클래스가 노출하는 멤버 목록이에요.

::: dspy.JSONAdapter
    handler: python
    options:
        members:
            - __call__
            - acall
            - format
            - format_assistant_message_content
            - format_conversation_history
            - format_demos
            - format_field_description
            - format_field_structure
            - format_field_with_value
            - format_finetune_data
            - format_system_message
            - format_task_description
            - format_user_message_content
            - parse
            - user_message_output_requirements
        show_source: true
        show_root_heading: true
        heading_level: 2
        docstring_style: google
        show_root_full_path: true
        show_object_full_path: false
        separate_signature: false
        inherited_members: true

더 알아보기 (Learn more)