feat: add weather tracing and unify example system prompts
Move shared prompt constants into pkg/opt and use them across examples. Add agent, model, and tool tracing to the weather example, with tests, and update weather argument descriptions and parse-error logging. Strip timestamp and speaker markers from final ADK voice transcripts, keeping normal bracketed text and treating marker-only results as empty. Co-authored-by: TRAE CLI <traecli@bytedance.com>
This commit is contained in:
1 parent
ee8afb10db
commit
1512f0516f
15 files changed
+332
-17
No files matched your search
@@ -0,0 +1,8 @@
|
||||
package opt
|
||||
|
||||
const SYSTEM_PROMPT = `你是一个可靠、务实的对话助手。默认使用中文,回答准确、清晰、简洁。不确定时如实说明,必要时向用户澄清。涉及代码时,优先给出简单、直接、可运行的实现。`
|
||||
|
||||
const (
|
||||
MIN_TOKEN = 1024
|
||||
MAX_TOOL_ROUND = 5
|
||||
)
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"log"
|
||||
"net/http"
|
||||
"strings"
|
||||
"time"
|
||||
@@ -48,6 +49,7 @@ func (w *Weather) Definition() model.ToolDefinition {
|
||||
func (w *Weather) Execute(ctx context.Context, arguments string) (string, error) {
|
||||
var args model.WeatherArguments
|
||||
if err := json.Unmarshal([]byte(arguments), &args); err != nil {
|
||||
log.Printf("[D] unmarshal weather arguments failed, err = %v, raw = %s", err, arguments)
|
||||
return "", fmt.Errorf("天气参数无效: %w", err)
|
||||
}
|
||||
location := strings.TrimSpace(args.Location)
|
||||
|
||||
@@ -15,8 +15,8 @@ func (w *Weather) Info(ctx context.Context) (*schema.ToolInfo, error) {
|
||||
Desc: definition.Description,
|
||||
ParamsOneOf: schema.NewParamsOneOfByParams(map[string]*schema.ParameterInfo{
|
||||
"location": {Type: schema.String, Required: true, Desc: "需要查询的城市或地点,例如北京、上海"},
|
||||
"start_date": {Type: schema.String, Desc: "预报开始日期,YYYY-MM-DD;不传则查北京时间今天的预报"},
|
||||
"end_date": {Type: schema.String, Desc: "预报结束日期,YYYY-MM-DD,含当天;不传则只查开始日期,不能单独提供"},
|
||||
"start_date": {Type: schema.String, Desc: "预报开始日期,日期格式: YYYY-MM-DD"},
|
||||
"end_date": {Type: schema.String, Desc: "预报结束日期,日期格式: YYYY-MM-DD"},
|
||||
}),
|
||||
}, nil
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user