feat(compose): add ResponseFormat type and WithResponseFormat model o… - #1146
feat(compose): add ResponseFormat type and WithResponseFormat model o…#1146N3kox wants to merge 1 commit into
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1146 +/- ##
==========================================
+ Coverage 83.29% 83.35% +0.05%
==========================================
Files 162 162
Lines 23398 23498 +100
==========================================
+ Hits 19490 19587 +97
- Misses 2639 2640 +1
- Partials 1269 1271 +2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
| @@ -0,0 +1,49 @@ | |||
| /* | |||
| * Copyright 2024 CloudWeGo Authors | |||
| import "github.com/eino-contrib/jsonschema" | ||
|
|
||
| // ResponseFormatType specifies the format the model must output. | ||
| type ResponseFormatType string |
There was a problem hiding this comment.
需要有个 text 类型吗,印象中似乎有的模型有这个枚举值?
There was a problem hiding this comment.
有这个 enum,但传与不传的效果我没测试出来差异,所以暂时没加。
| // Schema is the JSON Schema definition. | ||
| Schema *jsonschema.Schema | ||
| // Strict requires the model to strictly adhere to the schema. | ||
| Strict bool |
There was a problem hiding this comment.
大部分支持 JSONSchema 的都有这个 strict 参数是吗
| // ResponseFormatJSONSchema defines the JSON Schema for structured output. | ||
| type ResponseFormatJSONSchema struct { | ||
| // Name is a required identifier for the schema. | ||
| Name string |
There was a problem hiding this comment.
这个 Name 和 Description 在这里是怎么给到模型的?没想出来有啥用
There was a problem hiding this comment.
openai name 没有明确说,description 是会提供给模型的, 但 name 是 required,description 是 optional
- The name of the response format. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64.
- A description of what the response format is for, used by the model to determine how to respond in the format.
以 deepseek 为例,response format 就是一段 prompt
response_format_template: str = "## Response Format:\n\nYou MUST strictly adhere to the following schema to reply:\n{schema}"
| } | ||
|
|
||
| // WithResponseFormat sets the response format for the model. | ||
| // Only available for ChatModel. |
There was a problem hiding this comment.
为啥会有这句,这不就是 ModelOption 吗?是说不支持 AgenticModel?
854be50 to
66f33c6
Compare
66f33c6 to
8e3da40
Compare
…ption
What type of PR is this?
Check the PR title.
(Optional) Translate the PR title into Chinese.
(Optional) More detailed description for this PR(en: English/zh: Chinese).
en:
zh(optional):
(Optional) Which issue(s) this PR fixes:
(optional) The PR that updates user documentation: