Skip to content

Commit

Permalink
remove jsonscheme helper
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianliechti committed Sep 17, 2024
1 parent 73d513e commit 79cbb19
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 123 deletions.
18 changes: 9 additions & 9 deletions examples/custom-tool/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"os/exec"
"strings"

"github.com/adrianliechti/llama/pkg/jsonschema"
"github.com/adrianliechti/llama/pkg/tool/custom"

"google.golang.org/grpc"
Expand Down Expand Up @@ -38,19 +37,20 @@ func (s *server) Info(context.Context, *custom.InfoRequest) (*custom.Definition,
name := "kubectl"
description := "invoke the Kubernetes CLI kubectl with the given arguments"

schema, _ := json.Marshal(jsonschema.Definition{
Type: "object",
schema, _ := json.Marshal(map[string]any{
"type": "object",

Properties: map[string]jsonschema.Definition{
"args": {
Type: "array",
Items: &jsonschema.Definition{
Type: "string",
"properties": map[string]any{
"args": map[string]any{
"type": "array",

"itmes": map[string]any{
"type": "string",
},
},
},

Required: []string{"args"},
"required": []string{"args"},
})

return &custom.Definition{
Expand Down
70 changes: 0 additions & 70 deletions pkg/jsonschema/jsonschema.go

This file was deleted.

15 changes: 7 additions & 8 deletions pkg/tool/bing/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"net/http"
"net/url"

"github.com/adrianliechti/llama/pkg/jsonschema"
"github.com/adrianliechti/llama/pkg/tool"
)

Expand Down Expand Up @@ -46,17 +45,17 @@ func (t *Tool) Description() string {
}

func (*Tool) Parameters() any {
return jsonschema.Definition{
Type: jsonschema.DataTypeObject,
return map[string]any{
"type": "object",

Properties: map[string]jsonschema.Definition{
"query": {
Type: jsonschema.DataTypeString,
Description: "the text to search online to get the necessary information",
"properties": map[string]any{
"query": map[string]any{
"type": "string",
"description": "the text to search online to get the necessary information",
},
},

Required: []string{"query"},
"required": []string{"query"},
}
}

Expand Down
7 changes: 3 additions & 4 deletions pkg/tool/custom/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"errors"
"strings"

"github.com/adrianliechti/llama/pkg/jsonschema"
"github.com/adrianliechti/llama/pkg/tool"

"google.golang.org/grpc"
Expand Down Expand Up @@ -77,13 +76,13 @@ func (c *Client) Parameters() any {
data, err := c.client.Info(context.Background(), &InfoRequest{})

if err != nil {
return jsonschema.Definition{}
return nil
}

var result jsonschema.Definition
var result map[string]any

if err := json.Unmarshal([]byte(data.Schema), &result); err != nil {
return jsonschema.Definition{}
return nil
}

return result
Expand Down
15 changes: 7 additions & 8 deletions pkg/tool/draw/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"io"
"net/http"

"github.com/adrianliechti/llama/pkg/jsonschema"
"github.com/adrianliechti/llama/pkg/provider"
"github.com/adrianliechti/llama/pkg/tool"
)
Expand Down Expand Up @@ -40,17 +39,17 @@ func (t *Tool) Description() string {
}

func (*Tool) Parameters() any {
return jsonschema.Definition{
Type: jsonschema.DataTypeObject,
return map[string]any{
"type": "object",

Properties: map[string]jsonschema.Definition{
"prompt": {
Type: jsonschema.DataTypeString,
Description: "The prompt to create the image based from. Must be in English - Translate to English if needed.",
"properties": map[string]any{
"prompt": map[string]any{
"type": "string",
"description": "the prompt to create the image based from. must be in english - translate to english if needed.",
},
},

Required: []string{"prompt"},
"required": []string{"prompt"},
}
}

Expand Down
15 changes: 7 additions & 8 deletions pkg/tool/duckduckgo/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"regexp"
"strings"

"github.com/adrianliechti/llama/pkg/jsonschema"
"github.com/adrianliechti/llama/pkg/text"
"github.com/adrianliechti/llama/pkg/tool"
)
Expand Down Expand Up @@ -41,17 +40,17 @@ func (t *Tool) Description() string {
}

func (*Tool) Parameters() any {
return jsonschema.Definition{
Type: jsonschema.DataTypeObject,
return map[string]any{
"type": "object",

Properties: map[string]jsonschema.Definition{
"query": {
Type: jsonschema.DataTypeString,
Description: "the text to search online to get the necessary information",
"properties": map[string]any{
"query": map[string]any{
"type": "string",
"description": "the text to search online to get the necessary information",
},
},

Required: []string{"query"},
"required": []string{"query"},
}
}

Expand Down
15 changes: 7 additions & 8 deletions pkg/tool/searxng/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"net/http"
"net/url"

"github.com/adrianliechti/llama/pkg/jsonschema"
"github.com/adrianliechti/llama/pkg/tool"
)

Expand Down Expand Up @@ -42,17 +41,17 @@ func (t *Tool) Description() string {
}

func (*Tool) Parameters() any {
return jsonschema.Definition{
Type: jsonschema.DataTypeObject,
return map[string]any{
"type": "object",

Properties: map[string]jsonschema.Definition{
"query": {
Type: jsonschema.DataTypeString,
Description: "the text to search online to get the necessary information",
"properties": map[string]any{
"query": map[string]any{
"type": "string",
"description": "the text to search online to get the necessary information",
},
},

Required: []string{"query"},
"required": []string{"query"},
}
}

Expand Down
15 changes: 7 additions & 8 deletions pkg/tool/tavily/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"net/http"
"net/url"

"github.com/adrianliechti/llama/pkg/jsonschema"
"github.com/adrianliechti/llama/pkg/tool"
)

Expand Down Expand Up @@ -48,17 +47,17 @@ func (t *Tool) Description() string {
}

func (*Tool) Parameters() any {
return jsonschema.Definition{
Type: jsonschema.DataTypeObject,
return map[string]any{
"type": "object",

Properties: map[string]jsonschema.Definition{
"query": {
Type: jsonschema.DataTypeString,
Description: "the text to search online to get the necessary information",
"properties": map[string]any{
"query": map[string]any{
"type": "string",
"description": "the text to search online to get the necessary information",
},
},

Required: []string{"query"},
"required": []string{"query"},
}
}

Expand Down

0 comments on commit 79cbb19

Please sign in to comment.