Skip to content

Commit

Permalink
chore; add default otto agent
Browse files Browse the repository at this point in the history
  • Loading branch information
ibuildthecloud committed Oct 25, 2024
1 parent e7e8b60 commit 28d28a9
Show file tree
Hide file tree
Showing 8 changed files with 67 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ clean:

# Build the project
build:
go build -o bin/otto8 -v
CGO_ENABLED=0 go build -ldflags="-s -w" -o bin/otto8 .

dev: ui
./tools/dev.sh
Expand Down
3 changes: 2 additions & 1 deletion pkg/api/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"github.com/otto8-ai/otto8/apiclient/types"
"github.com/otto8-ai/otto8/pkg/api/authz"
"github.com/otto8-ai/otto8/pkg/storage"
"github.com/otto8-ai/otto8/pkg/system"
apierrors "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/api/meta"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down Expand Up @@ -217,7 +218,7 @@ func (r *Context) Update(obj client.Object) error {
}

func (r *Context) Namespace() string {
return "default"
return system.DefaultNamespace
}

func (r *Context) UserIsAdmin() bool {
Expand Down
6 changes: 5 additions & 1 deletion pkg/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ import (
"fmt"

"github.com/acorn-io/baaah/pkg/router"
"github.com/otto8-ai/otto8/pkg/controller/data"
"github.com/otto8-ai/otto8/pkg/controller/handlers/toolreference"
"github.com/otto8-ai/otto8/pkg/services"
// Enabled logrus logging in baaah
// Enable logrus logging in baaah
_ "github.com/acorn-io/baaah/pkg/logrus"
)

Expand All @@ -32,6 +33,9 @@ func New(ctx context.Context, services *services.Services) (*Controller, error)
}

func (c *Controller) PostStart(ctx context.Context) error {
if err := data.Data(ctx, c.services.StorageClient); err != nil {
return fmt.Errorf("failed to apply data: %w", err)
}
go c.toolRefHandler.PollRegistry(ctx, c.services.Router.Backend())
return nil
}
Expand Down
23 changes: 23 additions & 0 deletions pkg/controller/data/data.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package data

import (
"context"
_ "embed"

"github.com/acorn-io/baaah/pkg/apply"
v1 "github.com/otto8-ai/otto8/pkg/storage/apis/otto.gptscript.ai/v1"
kclient "sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/yaml"
)

//go:embed otto.yaml
var ottoData []byte

func Data(ctx context.Context, c kclient.Client) error {
var otto v1.Agent
if err := yaml.Unmarshal(ottoData, &otto); err != nil {
return err
}

return apply.Ensure(ctx, c, &otto)
}
26 changes: 26 additions & 0 deletions pkg/controller/data/otto.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
apiVersion: otto.gptscript.ai/v1
kind: Agent
metadata:
name: a1otto
namespace: default
spec:
manifest:
name: Otto
description: Default Otto
prompt: |
You are an AI assistance developed by Acorn Labs named Otto. You are described as follows:
Otto is a conversational AI assistant that can help an end user with a variety of tasks by using tools, reading/writing
files in the workspace, and querying it's knowledge database. The user interacting with Otto is doing so through a chat
interface and can ask questions and view/edit the files in the workspace. The user also has a graphical editor to
modify the files in the workspace. Otto collaborates with the user on the files in the workspace.
refName: otto
tools:
- github-bundle
- google-docs-bundle
- google-gmail-bundle
- google-search-bundle
- google-sheets-bundle
- images-bundle
- workspace-files
- time
9 changes: 5 additions & 4 deletions pkg/controller/handlers/toolreference/toolreference.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"github.com/otto8-ai/otto8/apiclient/types"
"github.com/otto8-ai/otto8/logger"
v1 "github.com/otto8-ai/otto8/pkg/storage/apis/otto.gptscript.ai/v1"
"github.com/otto8-ai/otto8/pkg/system"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/yaml"
Expand Down Expand Up @@ -75,7 +76,7 @@ func (h *Handler) toolsToToolReferences(ctx context.Context, toolType types.Tool
result = append(result, &v1.ToolReference{
ObjectMeta: metav1.ObjectMeta{
Name: normalize(name, toolName),
Namespace: "default",
Namespace: system.DefaultNamespace,
},
Spec: v1.ToolReferenceSpec{
Type: toolType,
Expand All @@ -99,7 +100,7 @@ func (h *Handler) toolsToToolReferences(ctx context.Context, toolType types.Tool
result = append(result, &v1.ToolReference{
ObjectMeta: metav1.ObjectMeta{
Name: normalize(name, toolName),
Namespace: "default",
Namespace: system.DefaultNamespace,
},
Spec: v1.ToolReferenceSpec{
Type: toolType,
Expand All @@ -113,7 +114,7 @@ func (h *Handler) toolsToToolReferences(ctx context.Context, toolType types.Tool
result = append(result, &v1.ToolReference{
ObjectMeta: metav1.ObjectMeta{
Name: name,
Namespace: "default",
Namespace: system.DefaultNamespace,
},
Spec: v1.ToolReferenceSpec{
Type: toolType,
Expand Down Expand Up @@ -179,7 +180,7 @@ func (h *Handler) PollRegistry(ctx context.Context, c client.Client) {
}

for {
if err := c.List(ctx, &v1.ToolReferenceList{}, client.InNamespace("default")); err != nil {
if err := c.List(ctx, &v1.ToolReferenceList{}, client.InNamespace(system.DefaultNamespace)); err != nil {
time.Sleep(1 * time.Second)
continue
}
Expand Down
2 changes: 2 additions & 0 deletions pkg/system/tools.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@ const (
KnowledgeDeleteTool = "knowledge-delete"
KnowledgeDeleteFileTool = "knowledge-delete-file"
KnowledgeRetrievalTool = "knowledge-retrieval"

DefaultNamespace = "default"
)
6 changes: 3 additions & 3 deletions tools/package-tools.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ for gomod in $(find otto8-tools -name go.mod); do
(
cd $(dirname $gomod)
echo Building $PWD
go build -o bin/gptscript-go-tool .
CGO_ENABLED=0 go build -ldflags="-s -w" -o bin/gptscript-go-tool .
)
done

Expand All @@ -35,11 +35,11 @@ if [ ! -e workspace-provider ]; then
fi

cd workspace-provider
go build -o bin/gptscript-go-tool .
CGO_ENABLED=0 go build -ldflags="-s -w" -o bin/gptscript-go-tool .

cd ..
if [ ! -e knowledge-tool ]; then
git clone https://github.com/gptscript-ai/knowledge knowledge-tool
git clone --depth=1 https://github.com/gptscript-ai/knowledge knowledge-tool
fi
cd knowledge-tool
make
Expand Down

0 comments on commit 28d28a9

Please sign in to comment.