| 2846 | |
| 2847 | |
| 2848 | class ChatCompletionResponseFormat(BaseModel): |
| 2849 | model_config = ConfigDict(extra="ignore", populate_by_name=True) |
| 2850 | |
| 2851 | type: Literal["text", "json_object", "json_schema"] |
| 2852 | schema_: Optional[Dict[str, Any]] = Field(default=None, alias="schema") |
| 2853 | json_schema: Optional[ChatCompletionResponseFormatJsonSchema] = None |
| 2854 | |
| 2855 | def to_template_response_format(self) -> ChatTemplateResponseFormat: |
| 2856 | response_format: ChatTemplateResponseFormat = {"type": self.type} |
| 2857 | if self.schema_ is not None: |
| 2858 | response_format["schema"] = self.schema_ |
| 2859 | if self.json_schema is not None: |
| 2860 | response_format["json_schema"] = self.json_schema.to_template_json_schema() |
| 2861 | return response_format |
| 2862 | |
| 2863 | |
| 2864 | class CreateChatCompletionRequest(BaseModel): |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…