refactor: add LLMServiceTypeDoubaoVL

This commit is contained in:
lilong.129
2025-05-22 15:34:11 +08:00
parent 269fe2de23
commit c377664518
7 changed files with 20 additions and 9 deletions
+1 -1
View File
@@ -1 +1 @@
v5.0.0-beta-2505212251 v5.0.0-beta-2505221534
+1 -1
View File
@@ -25,7 +25,7 @@ import (
// NewChat creates a new chat session // NewChat creates a new chat session
func (h *MCPHost) NewChat(ctx context.Context) (*Chat, error) { func (h *MCPHost) NewChat(ctx context.Context) (*Chat, error) {
// Get model config from environment variables // Get model config from environment variables
modelConfig, err := ai.GetModelConfig(option.LLMServiceTypeGPT) modelConfig, err := ai.GetModelConfig(option.LLMServiceTypeUITARS)
if err != nil { if err != nil {
return nil, err return nil, err
} }
+4 -1
View File
@@ -95,13 +95,16 @@ func GetModelConfig(modelType option.LLMServiceType) (*ModelConfig, error) {
"env %s missed", EnvModelName) "env %s missed", EnvModelName)
} }
temperature := float32(0.7) // https://www.volcengine.com/docs/82379/1536429
temperature := float32(0)
topP := float32(0.7)
modelConfig := &openai.ChatModelConfig{ modelConfig := &openai.ChatModelConfig{
BaseURL: openaiBaseURL, BaseURL: openaiBaseURL,
APIKey: openaiAPIKey, APIKey: openaiAPIKey,
Model: modelName, Model: modelName,
Timeout: defaultTimeout, Timeout: defaultTimeout,
Temperature: &temperature, Temperature: &temperature,
TopP: &topP,
} }
// log config info // log config info
+1 -1
View File
@@ -55,7 +55,7 @@ func NewAsserter(ctx context.Context, modelConfig *ModelConfig) (*Asserter, erro
if modelConfig.ModelType == option.LLMServiceTypeUITARS { if modelConfig.ModelType == option.LLMServiceTypeUITARS {
asserter.systemPrompt += "\n\n" + uiTarsAssertionResponseFormat asserter.systemPrompt += "\n\n" + uiTarsAssertionResponseFormat
} else if modelConfig.ModelType == option.LLMServiceTypeGPT { } else if modelConfig.ModelType == option.LLMServiceTypeDoubaoVL {
// define output format // define output format
type OutputFormat struct { type OutputFormat struct {
Thought string `json:"thought"` Thought string `json:"thought"`
+1 -1
View File
@@ -27,7 +27,7 @@ func NewLLMContentParser(modelType option.LLMServiceType) LLMContentParser {
return &UITARSContentParser{ return &UITARSContentParser{
systemPrompt: uiTarsPlanningPrompt, systemPrompt: uiTarsPlanningPrompt,
} }
case option.LLMServiceTypeGPT: case option.LLMServiceTypeDoubaoVL:
return &JSONContentParser{ return &JSONContentParser{
systemPrompt: defaultPlanningResponseJsonFormat, systemPrompt: defaultPlanningResponseJsonFormat,
} }
+8 -1
View File
@@ -30,7 +30,14 @@ finished(content='xxx') # Use escape characters \\', \\", and \\n in content par
` `
// system prompt for JSONContentParser // system prompt for JSONContentParser
const defaultPlanningResponseJsonFormat = `You are a versatile professional in software UI automation.` const defaultPlanningResponseJsonFormat = `You are a versatile professional in software UI automation.
## Output Format
` + "```" + `
Thought: ...
Action: ...
` + "```" + `
`
const defaultPlanningResponseStringFormat = ` const defaultPlanningResponseStringFormat = `
You are a helpful assistant. You are a helpful assistant.
+4 -3
View File
@@ -31,9 +31,10 @@ func WithCVService(service CVServiceType) AIServiceOption {
type LLMServiceType string type LLMServiceType string
const ( const (
LLMServiceTypeUITARS LLMServiceType = "ui-tars" LLMServiceTypeUITARS LLMServiceType = "ui-tars" // not support function calling and json response
LLMServiceTypeGPT LLMServiceType = "gpt" LLMServiceTypeDoubaoVL LLMServiceType = "doubao-vision"
LLMServiceTypeQwenVL LLMServiceType = "qwen-vl" LLMServiceTypeGPT LLMServiceType = "gpt"
LLMServiceTypeQwenVL LLMServiceType = "qwen-vl"
) )
func WithLLMService(modelType LLMServiceType) AIServiceOption { func WithLLMService(modelType LLMServiceType) AIServiceOption {