mirror of
https://github.com/vxcontrol/langchaingo.git
synced 2026-07-21 00:45:22 -04:00
agents: move out of exp
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
// Package agents defines the types for langchaingo Agent.
|
||||
package agent
|
||||
package agents
|
||||
|
||||
import (
|
||||
"context"
|
||||
@@ -4,4 +4,4 @@
|
||||
// a response corresponding to an “action” to take and a corresponding
|
||||
// “action input”. Alternatively the agent can return a finish with the
|
||||
// finished answer to the query.
|
||||
package agent
|
||||
package agents
|
||||
@@ -4,16 +4,16 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/tmc/langchaingo/agents"
|
||||
"github.com/tmc/langchaingo/chains"
|
||||
"github.com/tmc/langchaingo/exp/agent"
|
||||
"github.com/tmc/langchaingo/exp/tools"
|
||||
"github.com/tmc/langchaingo/memory"
|
||||
"github.com/tmc/langchaingo/schema"
|
||||
"github.com/tmc/langchaingo/tools"
|
||||
)
|
||||
|
||||
// Executor is the chain responsible for running agents.
|
||||
type Executor struct {
|
||||
Agent agent.Agent
|
||||
Agent agents.Agent
|
||||
Tools []tools.Tool
|
||||
|
||||
MaxIterations int
|
||||
@@ -23,7 +23,7 @@ var _ chains.Chain = Executor{}
|
||||
|
||||
// New creates a new agent executor with a agent, the tools the agent can use
|
||||
// and the max number of iterations.
|
||||
func New(agent agent.Agent, tools []tools.Tool, maxIterations int) Executor {
|
||||
func New(agent agents.Agent, tools []tools.Tool, maxIterations int) Executor {
|
||||
return Executor{
|
||||
Agent: agent,
|
||||
Tools: tools,
|
||||
@@ -7,11 +7,11 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
"github.com/tmc/langchaingo/agents/executor"
|
||||
"github.com/tmc/langchaingo/chains"
|
||||
"github.com/tmc/langchaingo/exp/agent/executor"
|
||||
"github.com/tmc/langchaingo/exp/tools"
|
||||
"github.com/tmc/langchaingo/exp/tools/serpapi"
|
||||
"github.com/tmc/langchaingo/llms/openai"
|
||||
"github.com/tmc/langchaingo/tools"
|
||||
"github.com/tmc/langchaingo/tools/serpapi"
|
||||
)
|
||||
|
||||
func TestMRKL(t *testing.T) {
|
||||
@@ -1,10 +1,10 @@
|
||||
package executor
|
||||
|
||||
import (
|
||||
"github.com/tmc/langchaingo/exp/agent"
|
||||
"github.com/tmc/langchaingo/exp/agent/mrkl"
|
||||
"github.com/tmc/langchaingo/exp/tools"
|
||||
"github.com/tmc/langchaingo/agents"
|
||||
"github.com/tmc/langchaingo/agents/mrkl"
|
||||
"github.com/tmc/langchaingo/llms"
|
||||
"github.com/tmc/langchaingo/tools"
|
||||
)
|
||||
|
||||
// AgentType is a string type representing the type of agent to create.
|
||||
@@ -47,7 +47,7 @@ func WithMaxIterations(maxIterations int) Option {
|
||||
|
||||
// Initialize is a function that creates a new executor with the specified LLM
|
||||
// model, tools, agent type, and options. It returns an Executor or an error
|
||||
// if there is any issue during the creation process.
|
||||
// if there is any issues during the creation process.
|
||||
func Initialize(
|
||||
llm llms.LLM,
|
||||
tools []tools.Tool,
|
||||
@@ -58,7 +58,7 @@ func Initialize(
|
||||
for _, opt := range opts {
|
||||
opt(&options)
|
||||
}
|
||||
var agent agent.Agent
|
||||
var agent agents.Agent
|
||||
|
||||
switch agentType {
|
||||
case ZeroShotReactDescription:
|
||||
@@ -8,11 +8,11 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/tmc/langchaingo/agents"
|
||||
"github.com/tmc/langchaingo/chains"
|
||||
"github.com/tmc/langchaingo/exp/agent"
|
||||
"github.com/tmc/langchaingo/exp/tools"
|
||||
"github.com/tmc/langchaingo/llms"
|
||||
"github.com/tmc/langchaingo/schema"
|
||||
"github.com/tmc/langchaingo/tools"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -46,7 +46,7 @@ type OneShotZeroAgent struct {
|
||||
OutputKey string
|
||||
}
|
||||
|
||||
var _ agent.Agent = (*OneShotZeroAgent)(nil)
|
||||
var _ agents.Agent = (*OneShotZeroAgent)(nil)
|
||||
|
||||
// OneShotZeroAgentOptions is a type alias for a map of string keys to any value,
|
||||
// representing the options for the OneShotZeroAgent.
|
||||
@@ -4,8 +4,8 @@ import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/tmc/langchaingo/exp/tools"
|
||||
"github.com/tmc/langchaingo/prompts"
|
||||
"github.com/tmc/langchaingo/tools"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -0,0 +1,3 @@
|
||||
// Package serpapi contains an implementation of the tool interface with the
|
||||
// serapi.
|
||||
package serpapi
|
||||
@@ -5,8 +5,8 @@ import (
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/tmc/langchaingo/exp/tools"
|
||||
"github.com/tmc/langchaingo/exp/tools/serpapi/internal"
|
||||
"github.com/tmc/langchaingo/tools"
|
||||
"github.com/tmc/langchaingo/tools/serpapi/internal"
|
||||
)
|
||||
|
||||
var ErrMissingToken = errors.New("missing the serpapi API key, set it in the SERPAPI_API_KEY environment variable")
|
||||
Reference in New Issue
Block a user