Skip to content

Commit

Permalink
Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
hupe1980 committed Jul 30, 2023
1 parent da4621e commit 4c78367
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions agent/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func NewExecutor(agent schema.Agent, tools []schema.Tool) (*Executor, error) {

// Call executes the AgentExecutor chain with the given context and inputs.
// It returns the outputs of the chain or an error, if any.
func (e Executor) Call(ctx context.Context, values schema.ChainValues, optFns ...func(o *schema.CallOptions)) (schema.ChainValues, error) {
func (e Executor) Call(ctx context.Context, inputs schema.ChainValues, optFns ...func(o *schema.CallOptions)) (schema.ChainValues, error) {
opts := schema.CallOptions{
CallbackManger: &callback.NoopManager{},
}
Expand All @@ -60,7 +60,7 @@ func (e Executor) Call(ctx context.Context, values schema.ChainValues, optFns ..
fn(&opts)
}

inputs, err := inputsToString(values)
strInputs, err := inputsToString(inputs)
if err != nil {
return nil, err
}
Expand All @@ -72,7 +72,7 @@ func (e Executor) Call(ctx context.Context, values schema.ChainValues, optFns ..
case <-ctx.Done():
return nil, ctx.Err()
default:
actions, finish, err := e.agent.Plan(ctx, steps, inputs)
actions, finish, err := e.agent.Plan(ctx, steps, strInputs)
if err != nil {
return nil, err
}
Expand Down
6 changes: 3 additions & 3 deletions evaluation/context_qa_eval_chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,14 @@ func NewContextQAEvalChain(llm schema.LLM, optFns ...func(o *ContextQAEvalChainO
}

func (eval *ContextQAEvalChain) Evaluate(ctx context.Context, examples, predictions []map[string]string) ([]schema.ChainValues, error) {
inputs := []schema.ChainValues{}
inputs := make([]schema.ChainValues, len(examples))

for i, example := range examples {
inputs = append(inputs, schema.ChainValues{
inputs[i] = schema.ChainValues{
"query": example[eval.questionKey],
"context": example[eval.contextKey],
"result": predictions[i][eval.predictionKey],
})
}
}

return golc.BatchCall(ctx, eval.llmChain, inputs)
Expand Down
6 changes: 3 additions & 3 deletions evaluation/qa_eval_chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,14 @@ func NewQAEvalChain(llm schema.LLM, optFns ...func(o *QAEvalChainOptions)) (*QAE
}

func (eval *QAEvalChain) Evaluate(ctx context.Context, examples, predictions []map[string]string) ([]schema.ChainValues, error) {
inputs := []schema.ChainValues{}
inputs := make([]schema.ChainValues, len(examples))

for i, example := range examples {
inputs = append(inputs, schema.ChainValues{
inputs[i] = schema.ChainValues{
"query": example[eval.questionKey],
"answer": example[eval.answerKey],
"result": predictions[i][eval.predictionKey],
})
}
}

return golc.BatchCall(ctx, eval.llmChain, inputs)
Expand Down

0 comments on commit 4c78367

Please sign in to comment.