Skip to content

Commit

Permalink
agents: move out of exp
Browse files Browse the repository at this point in the history
  • Loading branch information
FluffyKebab committed May 22, 2023
1 parent 97426d9 commit a698dde
Show file tree
Hide file tree
Showing 17 changed files with 23 additions and 20 deletions.
2 changes: 1 addition & 1 deletion exp/agent/agents.go → agents/agents.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Package agents defines the types for langchaingo Agent.
package agent
package agents

import (
"context"
Expand Down
2 changes: 1 addition & 1 deletion exp/agent/doc.go → agents/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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,
Expand All @@ -58,7 +58,7 @@ func Initialize(
for _, opt := range opts {
opt(&options)
}
var agent agent.Agent
var agent agents.Agent

switch agentType {
case ZeroShotReactDescription:
Expand Down
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions exp/agent/mrkl/mrkl.go → agents/mrkl/mrkl.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion exp/agent/mrkl/prompt.go → agents/mrkl/prompt.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"fmt"
"strings"

"github.com/tmc/langchaingo/exp/tools"
"github.com/tmc/langchaingo/prompts"
"github.com/tmc/langchaingo/tools"
)

const (
Expand Down
File renamed without changes.
File renamed without changes.
3 changes: 3 additions & 0 deletions tools/serpapi/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Package serpapi contains an implementation of the tool interface with the
// serapi.
package serpapi
File renamed without changes.
4 changes: 2 additions & 2 deletions exp/tools/serpapi/serpapi.go → tools/serpapi/serpapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
File renamed without changes.

0 comments on commit a698dde

Please sign in to comment.