Skip to content

Commit

Permalink
switch toolreferences to tool-references
Browse files Browse the repository at this point in the history
  • Loading branch information
ibuildthecloud committed Oct 18, 2024
1 parent f4337e0 commit d25842b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
14 changes: 7 additions & 7 deletions apiclient/toolref.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ type ListToolReferencesOptions struct {
}

func (c *Client) GetToolReference(ctx context.Context, id string) (result *types.ToolReference, _ error) {
_, resp, err := c.doRequest(ctx, "GET", fmt.Sprintf("/toolreferences/%s", id), nil)
_, resp, err := c.doRequest(ctx, "GET", fmt.Sprintf("/tool-references/%s", id), nil)
if err != nil {
return nil, err
}
Expand All @@ -22,9 +22,9 @@ func (c *Client) GetToolReference(ctx context.Context, id string) (result *types
}

func (c *Client) ListToolReferences(ctx context.Context, opts ListToolReferencesOptions) (result types.ToolReferenceList, _ error) {
path := "/toolreferences"
path := "/tool-references"
if opts.ToolType != "" {
path = fmt.Sprintf("/toolreferences?type=%s", opts.ToolType)
path = fmt.Sprintf("/tool-references?type=%s", opts.ToolType)
}
_, resp, err := c.doRequest(ctx, "GET", path, nil)
if err != nil {
Expand All @@ -37,7 +37,7 @@ func (c *Client) ListToolReferences(ctx context.Context, opts ListToolReferences
}

func (c *Client) UpdateToolReference(ctx context.Context, id, reference string) (*types.ToolReference, error) {
_, resp, err := c.putJSON(ctx, fmt.Sprintf("/toolreferences/%s", id), map[string]string{
_, resp, err := c.putJSON(ctx, fmt.Sprintf("/tool-references/%s", id), map[string]string{
"reference": reference,
})
if err != nil {
Expand All @@ -49,9 +49,9 @@ func (c *Client) UpdateToolReference(ctx context.Context, id, reference string)
}

func (c *Client) DeleteToolReference(ctx context.Context, id string, toolType types.ToolReferenceType) error {
path := fmt.Sprintf("/toolreferences/%s", id)
path := fmt.Sprintf("/tool-references/%s", id)
if toolType != "" {
path = fmt.Sprintf("/toolreferences/%s?type=%s", id, toolType)
path = fmt.Sprintf("/tool-references/%s?type=%s", id, toolType)
}
_, resp, err := c.doRequest(ctx, "DELETE", path, nil)
if err != nil {
Expand All @@ -62,7 +62,7 @@ func (c *Client) DeleteToolReference(ctx context.Context, id string, toolType ty
}

func (c *Client) CreateToolReference(ctx context.Context, manifest types.ToolReferenceManifest) (*types.ToolReference, error) {
_, resp, err := c.postJSON(ctx, fmt.Sprintf("/toolreferences"), &manifest)
_, resp, err := c.postJSON(ctx, fmt.Sprintf("/tool-references"), &manifest)
if err != nil {
return nil, err
}
Expand Down
7 changes: 7 additions & 0 deletions pkg/api/router/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,13 @@ func Router(services *services.Services) (http.Handler, error) {
mux.HandleFunc("DELETE /api/threads/{id}/knowledge/{file...}", threads.DeleteKnowledge)

// ToolRefs
mux.HandleFunc("GET /api/tool-references", toolRefs.List)
mux.HandleFunc("GET /api/tool-references/{id}", toolRefs.ByID)
mux.HandleFunc("POST /api/tool-references", toolRefs.Create)
mux.HandleFunc("DELETE /api/tool-references/{id}", toolRefs.Delete)
mux.HandleFunc("PUT /api/tool-references/{id}", toolRefs.Update)

// Deprecated routes
mux.HandleFunc("GET /api/toolreferences", toolRefs.List)
mux.HandleFunc("GET /api/toolreferences/{id}", toolRefs.ByID)
mux.HandleFunc("POST /api/toolreferences", toolRefs.Create)
Expand Down
4 changes: 2 additions & 2 deletions ui/admin/app/lib/routers/apiRoutes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ export const ApiRoutes = {
},
toolReferences: {
base: (params?: { type?: ToolReferenceType }) =>
buildUrl("/toolreferences", params),
buildUrl("/tool-references", params),
getById: (toolReferenceId: string) =>
buildUrl(`/toolreferences/${toolReferenceId}`),
buildUrl(`/tool-references/${toolReferenceId}`),
},
users: {
base: () => buildUrl("/users"),
Expand Down

0 comments on commit d25842b

Please sign in to comment.