-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from gradientlabs-ai/add-resource
Add `AddResource` method
- Loading branch information
Showing
6 changed files
with
58 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package client | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"net/http" | ||
) | ||
|
||
// AddResource adds (or updates) a resource to the conversation (e.g. the | ||
// customer's order details) so the AI agent can handle customer-specific | ||
// queries. | ||
// | ||
// A resource can be any JSON document, as long it is smaller than 1MB. There | ||
// are no strict requirements on the format/structure of the document, but we | ||
// recommend making attribute names as descriptive as possible. | ||
// | ||
// Over time, the AI agent will learn the structure of your resources - so while | ||
// it's fine to add new attributes, you may want to consider using new resource | ||
// names when removing attributes or changing the structure of your resources | ||
// significantly. | ||
// | ||
// Resource names can be anything consisting of letters, numbers, or any of the | ||
// following characters: _ - + =. Names should be descriptive handles that are | ||
// the same for all conversations (e.g. "order-details" and "user-profile") not | ||
// unique identifiers. | ||
func (c *Client) AddResource(ctx context.Context, conversationID string, name string, resource any) error { | ||
rsp, err := c.makeRequest(ctx, http.MethodPut, fmt.Sprintf("conversations/%s/resources/%s", conversationID, name), resource) | ||
if err != nil { | ||
return err | ||
} | ||
defer rsp.Body.Close() | ||
|
||
if err := responseError(rsp); err != nil { | ||
return err | ||
} | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters