fix(deerflow): correct ctx param of chat template (#99)

drew/english
Megumin 9 months ago committed by GitHub
parent 208c545ea7
commit 985ee36f62
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -40,7 +40,7 @@ func main() {
ctx := context.Background()
// build branch func
const randLimit = 2
branchCond := func(ctx context.Context, input map[string]any) (string, error) { // nolint: byted_all_nil_return
branchCond := func(ctx context.Context, input map[string]any) (string, error) {
if rand.Intn(randLimit) == 1 {
return "b1", nil
}
@ -110,7 +110,7 @@ func main() {
logs.Infof("in view lambda: %v", kvs)
return kvs, nil
})).
AppendBranch(compose.NewChainBranch(branchCond).AddLambda("b1", b1).AddLambda("b2", b2)). // nolint: byted_use_receiver_without_nilcheck
AppendBranch(compose.NewChainBranch(branchCond).AddLambda("b1", b1).AddLambda("b2", b2)).
AppendPassthrough().
AppendParallel(parallel).
AppendGraph(rolePlayerChain).

@ -71,7 +71,6 @@ func main() {
sr, sw := schema.Pipe[string](utf8.RuneCountInString(outStr))
// nolint: byted_goroutine_recover
go func() {
for _, field := range strings.Fields(outStr) {
sw.Send(field+" ", nil)

@ -71,7 +71,7 @@ func loadCoderMsg(ctx context.Context, name string, opts ...any) (output []*sche
"CURRENT_TIME": time.Now().Format("2006-01-02 15:04:05"),
"user_input": msg,
}
output, err = promptTemp.Format(context.Background(), variables)
output, err = promptTemp.Format(ctx, variables)
return err
})
return output, err

@ -51,7 +51,7 @@ func loadMsg(ctx context.Context, name string, opts ...any) (output []*schema.Me
"CURRENT_TIME": time.Now().Format("2006-01-02 15:04:05"),
"user_input": state.Messages,
}
output, err = promptTemp.Format(context.Background(), variables)
output, err = promptTemp.Format(ctx, variables)
return err
})
return output, err

@ -61,7 +61,7 @@ func loadPlannerMsg(ctx context.Context, name string, opts ...any) (output []*sc
"CURRENT_TIME": time.Now().Format("2006-01-02 15:04:05"),
"user_input": state.Messages,
}
output, err = promptTemp.Format(context.Background(), variables)
output, err = promptTemp.Format(ctx, variables)
return err
})
return output, err

@ -58,7 +58,7 @@ func loadReporterMsg(ctx context.Context, name string, opts ...any) (output []*s
"CURRENT_TIME": time.Now().Format("2006-01-02 15:04:05"),
"user_input": msg,
}
output, err = promptTemp.Format(context.Background(), variables)
output, err = promptTemp.Format(ctx, variables)
return err
})
return output, err

@ -73,7 +73,7 @@ func loadResearcherMsg(ctx context.Context, name string, opts ...any) (output []
"CURRENT_TIME": time.Now().Format("2006-01-02 15:04:05"),
"user_input": msg,
}
output, err = promptTemp.Format(context.Background(), variables)
output, err = promptTemp.Format(ctx, variables)
return err
})
return output, err

@ -136,7 +136,7 @@ func (cb *LoggerCallback) OnStart(ctx context.Context, info *callbacks.RunInfo,
func (cb *LoggerCallback) OnEnd(ctx context.Context, info *callbacks.RunInfo, output callbacks.CallbackOutput) context.Context {
//fmt.Println("=========[OnEnd]=========", info.Name, "|", info.Component, "|", info.Type)
//outputStr, _ := json.MarshalIndent(output, "", " ") // nolint: byted_s_returned_err_check
//outputStr, _ := json.MarshalIndent(output, "", " ")
//if len(outputStr) > 200 {
// outputStr = outputStr[:200]
//}

@ -169,14 +169,14 @@ type LoggerCallback struct {
func (cb *LoggerCallback) OnStart(ctx context.Context, info *callbacks.RunInfo, input callbacks.CallbackInput) context.Context {
fmt.Println("==================")
inputStr, _ := json.MarshalIndent(input, "", " ") // nolint: byted_s_returned_err_check
inputStr, _ := json.MarshalIndent(input, "", " ")
fmt.Printf("[OnStart] %s\n", string(inputStr))
return ctx
}
func (cb *LoggerCallback) OnEnd(ctx context.Context, info *callbacks.RunInfo, output callbacks.CallbackOutput) context.Context {
fmt.Println("=========[OnEnd]=========")
outputStr, _ := json.MarshalIndent(output, "", " ") // nolint: byted_s_returned_err_check
outputStr, _ := json.MarshalIndent(output, "", " ")
fmt.Println(string(outputStr))
return ctx
}

@ -144,7 +144,7 @@ func (rd *restaurantDatabase) GetDishesByRestaurant(ctx context.Context, restaur
return res, nil
}
func getData() map[string][]restaurantDataItem { // nolint: byted_s_too_many_lines_in_func
func getData() map[string][]restaurantDataItem {
return map[string][]restaurantDataItem{
"北京": {
{

Loading…
Cancel
Save