fix: 映射模型调整、chat方法调整、提示词调整
This commit is contained in:
parent
adda03e5d8
commit
8d4f3c494e
|
|
@ -7,6 +7,7 @@ ollama:
|
|||
base_url: "http://192.168.6.109:11434"
|
||||
model: "qwen3-coder:480b-cloud"
|
||||
generate_model: "qwen3-coder:480b-cloud"
|
||||
mapping_model: "deepseek-v3.2:cloud"
|
||||
vl_model: "qwen2.5vl:7b"
|
||||
timeout: "120s"
|
||||
level: "info"
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ ollama:
|
|||
base_url: "http://host.docker.internal:11434"
|
||||
model: "qwen3-coder:480b-cloud"
|
||||
generate_model: "qwen3-coder:480b-cloud"
|
||||
mapping_model: "deepseek-v3.2:cloud"
|
||||
vl_model: "gemini-3-pro-preview"
|
||||
timeout: "120s"
|
||||
level: "info"
|
||||
|
|
|
|||
|
|
@ -81,6 +81,7 @@ type OllamaConfig struct {
|
|||
BaseURL string `mapstructure:"base_url"`
|
||||
Model string `mapstructure:"model"`
|
||||
GenerateModel string `mapstructure:"generate_model"`
|
||||
MappingModel string `mapstructure:"mapping_model"`
|
||||
VlModel string `mapstructure:"vl_model"`
|
||||
Timeout time.Duration `mapstructure:"timeout"`
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,41 +9,43 @@ const (
|
|||
const (
|
||||
SystemPrompt = `
|
||||
#你是一个专业的商品属性提取助手,你的任务是根据用户输入提取商品的属性信息。
|
||||
1.最终输出格式为纯JSON字符串,键值对对应目标属性和提取到的属性值。
|
||||
2.最终输出不要携带markdown标识,不要携带回车换行`
|
||||
关键格式要求:
|
||||
1.输出必须是一个紧凑的、无任何多余空白字符的纯JSON字符串。
|
||||
2.确保整个JSON输出在一行内完成,键、值、冒号、引号、括号之间均不要换行。
|
||||
3.最终输出不要携带任何markdown标识(如json),直接输出纯JSON内容。`
|
||||
)
|
||||
|
||||
// 商品属性模板-中文
|
||||
const (
|
||||
// 货易通商品属性模板-中文
|
||||
HYTProductPropertyTemplateZH = `{
|
||||
"条码": "string", // 商品编号
|
||||
"货品编号": "string", // 商品编号
|
||||
"条码": "string", // 货品编号
|
||||
"分类名称": "string", // 商品分类
|
||||
"货品名称": "string", // 商品名称
|
||||
"货品编号": "string", // 商品编号
|
||||
"商品货号": "string", // 商品编号
|
||||
"商品货号": "string", // 货品编号
|
||||
"品牌": "string", // 商品品牌
|
||||
"单位": "string", // 商品单位,若无则使用'个'
|
||||
"规格参数": "string", // 商品规格参数
|
||||
"货品说明": "string", // 商品说明
|
||||
"保质期": "string", // 商品保质期
|
||||
"保质期单位": "string", // 商品保质期单位
|
||||
"链接": "string", // 商品链接
|
||||
"货品图片": ["string"], // 商品多图,取1-2个即可
|
||||
"保质期": "string", // 商品保质期,无则空
|
||||
"保质期单位": "string", // 商品保质期单位,无则空
|
||||
"链接": "string", // 空
|
||||
"货品图片": ["string"], // 商品多图,取前2个即可
|
||||
"电商销售价格": "string", // 商品电商销售价格 decimal(10,2)
|
||||
"销售价": "string", // 商品销售价格 decimal(10,2)
|
||||
"备注": "string", // 备注
|
||||
"备注": "string", // 无则空
|
||||
"长": "string", // 商品长度,decimal(10,2)+单位
|
||||
"宽": "string", // 商品宽度,decimal(10,2)+单位
|
||||
"高": "string", // 商品高度,decimal(10,2)+单位
|
||||
"重量": "string", // 商品重量(kg)
|
||||
"重量": "string", // 商品重量,decimal(10,2)+单位(kg)
|
||||
"SPU名称": "string", // 商品SPU名称
|
||||
"SPU编码": "string" // 编码串,jd_{timestamp}_rand(1000-999)
|
||||
"供应商报价": "string", // 商品供应商报价 decimal(10,2)
|
||||
"税率": "string", // 商品税率 x%
|
||||
"利润": "string", // 商品利润 decimal(10,2)
|
||||
"默认供应商": "string", // 供应商名称
|
||||
"默认存放仓库": "string", // 仓库名称
|
||||
"SPU编码": "string" // 货品编号
|
||||
"供应商报价": "string", // 空
|
||||
"税率": "string", // 商品税率 x%,无则空
|
||||
"利润": "string", // 空
|
||||
"默认供应商": "string", // 空
|
||||
"默认存放仓库": "string", // 空
|
||||
}`
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -90,13 +90,13 @@ func (c *Client) ChatStream(ctx context.Context, ch chan entitys.Response, messa
|
|||
return
|
||||
}
|
||||
|
||||
func (c *Client) Chat(ctx context.Context, messages []api.Message) (res api.ChatResponse, err error) {
|
||||
func (c *Client) Chat(ctx context.Context, model string, messages []api.Message) (res api.ChatResponse, err error) {
|
||||
// 构建聊天请求
|
||||
req := &api.ChatRequest{
|
||||
Model: c.config.Model,
|
||||
Model: model,
|
||||
Messages: messages,
|
||||
Stream: new(bool), // 设置为false,不使用流式响应
|
||||
Think: &api.ThinkValue{Value: true},
|
||||
Think: &api.ThinkValue{Value: false},
|
||||
}
|
||||
err = c.client.Chat(ctx, req, func(resp api.ChatResponse) error {
|
||||
res = resp
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@ func (s *CapabilityService) ProductIngest(c *fiber.Ctx) error {
|
|||
return err
|
||||
}
|
||||
defer cleanup()
|
||||
res, err := client.Chat(ctx, []api.Message{
|
||||
res, err := client.Chat(ctx, s.cfg.Ollama.MappingModel, []api.Message{
|
||||
{
|
||||
Role: "system",
|
||||
Content: constants.SystemPrompt,
|
||||
|
|
|
|||
Loading…
Reference in New Issue