fix: 映射模型调整、chat方法调整、提示词调整

This commit is contained in:
fuzhongyun 2025-12-22 17:48:48 +08:00
parent adda03e5d8
commit 8d4f3c494e
6 changed files with 26 additions and 21 deletions

View File

@ -7,6 +7,7 @@ ollama:
base_url: "http://192.168.6.109:11434" base_url: "http://192.168.6.109:11434"
model: "qwen3-coder:480b-cloud" model: "qwen3-coder:480b-cloud"
generate_model: "qwen3-coder:480b-cloud" generate_model: "qwen3-coder:480b-cloud"
mapping_model: "deepseek-v3.2:cloud"
vl_model: "qwen2.5vl:7b" vl_model: "qwen2.5vl:7b"
timeout: "120s" timeout: "120s"
level: "info" level: "info"

View File

@ -7,6 +7,7 @@ ollama:
base_url: "http://host.docker.internal:11434" base_url: "http://host.docker.internal:11434"
model: "qwen3-coder:480b-cloud" model: "qwen3-coder:480b-cloud"
generate_model: "qwen3-coder:480b-cloud" generate_model: "qwen3-coder:480b-cloud"
mapping_model: "deepseek-v3.2:cloud"
vl_model: "gemini-3-pro-preview" vl_model: "gemini-3-pro-preview"
timeout: "120s" timeout: "120s"
level: "info" level: "info"

View File

@ -81,6 +81,7 @@ type OllamaConfig struct {
BaseURL string `mapstructure:"base_url"` BaseURL string `mapstructure:"base_url"`
Model string `mapstructure:"model"` Model string `mapstructure:"model"`
GenerateModel string `mapstructure:"generate_model"` GenerateModel string `mapstructure:"generate_model"`
MappingModel string `mapstructure:"mapping_model"`
VlModel string `mapstructure:"vl_model"` VlModel string `mapstructure:"vl_model"`
Timeout time.Duration `mapstructure:"timeout"` Timeout time.Duration `mapstructure:"timeout"`
} }

View File

@ -9,41 +9,43 @@ const (
const ( const (
SystemPrompt = ` SystemPrompt = `
#你是一个专业的商品属性提取助手你的任务是根据用户输入提取商品的属性信息 #你是一个专业的商品属性提取助手你的任务是根据用户输入提取商品的属性信息
1.最终输出格式为纯JSON字符串键值对对应目标属性和提取到的属性值 关键格式要求
2.最终输出不要携带markdown标识不要携带回车换行` 1.输出必须是一个紧凑的无任何多余空白字符的纯JSON字符串
2.确保整个JSON输出在一行内完成冒号引号括号之间均不要换行
3.最终输出不要携带任何markdown标识如json直接输出纯JSON内容`
) )
// 商品属性模板-中文 // 商品属性模板-中文
const ( const (
// 货易通商品属性模板-中文 // 货易通商品属性模板-中文
HYTProductPropertyTemplateZH = `{ HYTProductPropertyTemplateZH = `{
"条码": "string", // 商品编号 "货品编号": "string", // 商品编号
"条码": "string", // 货品编号
"分类名称": "string", // 商品分类 "分类名称": "string", // 商品分类
"货品名称": "string", // 商品名称 "货品名称": "string", // 商品名称
"货品编号": "string", // 商品编号 "商品货号": "string", // 货品编号
"商品货号": "string", // 商品编号
"品牌": "string", // 商品品牌 "品牌": "string", // 商品品牌
"单位": "string", // 商品单位,若无则使用'个' "单位": "string", // 商品单位,若无则使用'个'
"规格参数": "string", // 商品规格参数 "规格参数": "string", // 商品规格参数
"货品说明": "string", // 商品说明 "货品说明": "string", // 商品说明
"保质期": "string", // 商品保质期 "保质期": "string", // 商品保质期,无则空
"保质期单位": "string", // 商品保质期单位 "保质期单位": "string", // 商品保质期单位,无则空
"链接": "string", // 商品链接 "链接": "string", //
"货品图片": ["string"], // 商品多图,取1-2个即可 "货品图片": ["string"], // 商品多图,取2个即可
"电商销售价格": "string", // 商品电商销售价格 decimal(10,2) "电商销售价格": "string", // 商品电商销售价格 decimal(10,2)
"销售价": "string", // 商品销售价格 decimal(10,2) "销售价": "string", // 商品销售价格 decimal(10,2)
"备注": "string", // 备注 "备注": "string", // 无则空
"长": "string", // 商品长度decimal(10,2)+单位 "长": "string", // 商品长度decimal(10,2)+单位
"宽": "string", // 商品宽度decimal(10,2)+单位 "宽": "string", // 商品宽度decimal(10,2)+单位
"高": "string", // 商品高度decimal(10,2)+单位 "高": "string", // 商品高度decimal(10,2)+单位
"重量": "string", // 商品重量(kg) "重量": "string", // 商品重量decimal(10,2)+单位(kg)
"SPU名称": "string", // 商品SPU名称 "SPU名称": "string", // 商品SPU名称
"SPU编码": "string" // 编码串jd_{timestamp}_rand(1000-999) "SPU编码": "string" // 货品编号
"供应商报价": "string", // 商品供应商报价 decimal(10,2) "供应商报价": "string", //
"税率": "string", // 商品税率 x% "税率": "string", // 商品税率 x%,无则空
"利润": "string", // 商品利润 decimal(10,2) "利润": "string", //
"默认供应商": "string", // 供应商名称 "默认供应商": "string", //
"默认存放仓库": "string", // 仓库名称 "默认存放仓库": "string", //
}` }`
) )

View File

@ -90,13 +90,13 @@ func (c *Client) ChatStream(ctx context.Context, ch chan entitys.Response, messa
return 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{ req := &api.ChatRequest{
Model: c.config.Model, Model: model,
Messages: messages, Messages: messages,
Stream: new(bool), // 设置为false不使用流式响应 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 { err = c.client.Chat(ctx, req, func(resp api.ChatResponse) error {
res = resp res = resp

View File

@ -87,7 +87,7 @@ func (s *CapabilityService) ProductIngest(c *fiber.Ctx) error {
return err return err
} }
defer cleanup() defer cleanup()
res, err := client.Chat(ctx, []api.Message{ res, err := client.Chat(ctx, s.cfg.Ollama.MappingModel, []api.Message{
{ {
Role: "system", Role: "system",
Content: constants.SystemPrompt, Content: constants.SystemPrompt,