diff --git a/core/request_option.go b/core/request_option.go index c1baadd..b6a8cf4 100644 --- a/core/request_option.go +++ b/core/request_option.go @@ -57,8 +57,8 @@ func (r *RequestOptions) cloneHeader() http.Header { headers := r.HTTPHeader.Clone() headers.Set("X-Fern-Language", "Go") headers.Set("X-Fern-SDK-Name", "github.com/getzep/zep-go/v3") - headers.Set("X-Fern-SDK-Version", "v3.13.0") - headers.Set("User-Agent", "github.com/getzep/zep-go/3.13.0") + headers.Set("X-Fern-SDK-Version", "v3.14.0") + headers.Set("User-Agent", "github.com/getzep/zep-go/3.14.0") return headers } diff --git a/graph.go b/graph.go index 4752108..0ac7aa6 100644 --- a/graph.go +++ b/graph.go @@ -30,6 +30,9 @@ type AddDataBatchRequest struct { type AddTripleRequest struct { // The timestamp of the message CreatedAt *string `json:"created_at,omitempty" url:"-"` + // Additional attributes of the edge. Values must be scalar types (string, number, boolean, or null). + // Nested objects and arrays are not allowed. + EdgeAttributes map[string]interface{} `json:"edge_attributes,omitempty" url:"-"` // The time (if any) at which the edge expires ExpiredAt *string `json:"expired_at,omitempty" url:"-"` // The fact relating the two nodes that this edge represents @@ -41,14 +44,20 @@ type AddTripleRequest struct { GraphID *string `json:"graph_id,omitempty" url:"-"` // The time (if any) at which the fact stops being true InvalidAt *string `json:"invalid_at,omitempty" url:"-"` + // Additional attributes of the source node. Values must be scalar types (string, number, boolean, or null). + // Nested objects and arrays are not allowed. + SourceNodeAttributes map[string]interface{} `json:"source_node_attributes,omitempty" url:"-"` // The name of the source node to add - SourceNodeName string `json:"source_node_name" url:"-"` + SourceNodeName *string `json:"source_node_name,omitempty" url:"-"` // The summary of the source node to add SourceNodeSummary *string `json:"source_node_summary,omitempty" url:"-"` // The source node uuid SourceNodeUUID *string `json:"source_node_uuid,omitempty" url:"-"` + // Additional attributes of the target node. Values must be scalar types (string, number, boolean, or null). + // Nested objects and arrays are not allowed. + TargetNodeAttributes map[string]interface{} `json:"target_node_attributes,omitempty" url:"-"` // The name of the target node to add - TargetNodeName string `json:"target_node_name" url:"-"` + TargetNodeName *string `json:"target_node_name,omitempty" url:"-"` // The summary of the target node to add TargetNodeSummary *string `json:"target_node_summary,omitempty" url:"-"` // The target node uuid @@ -302,8 +311,9 @@ func (c ComparisonOperator) Ptr() *ComparisonOperator { type DateFilter struct { // Comparison operator for date filter ComparisonOperator ComparisonOperator `json:"comparison_operator" url:"comparison_operator"` - // Date to filter on - Date string `json:"date" url:"date"` + // Date to filter on. Required for non-null operators (=, <>, >, <, >=, <=). + // Should be omitted for IS NULL and IS NOT NULL operators. + Date *string `json:"date,omitempty" url:"date,omitempty"` extraProperties map[string]interface{} rawJSON json.RawMessage @@ -316,9 +326,9 @@ func (d *DateFilter) GetComparisonOperator() ComparisonOperator { return d.ComparisonOperator } -func (d *DateFilter) GetDate() string { +func (d *DateFilter) GetDate() *string { if d == nil { - return "" + return nil } return d.Date } @@ -1008,6 +1018,73 @@ func (g GraphSearchScope) Ptr() *GraphSearchScope { return &g } +type PropertyFilter struct { + // Comparison operator for property filter + ComparisonOperator ComparisonOperator `json:"comparison_operator" url:"comparison_operator"` + // Property name to filter on + PropertyName string `json:"property_name" url:"property_name"` + // Property value to match on. Accepted types: string, int, float64, bool, or nil. + // Invalid types (e.g., arrays, objects) will be rejected by validation. + // Must be non-nil for non-null operators (=, <>, >, <, >=, <=). + PropertyValue interface{} `json:"property_value,omitempty" url:"property_value,omitempty"` + + extraProperties map[string]interface{} + rawJSON json.RawMessage +} + +func (p *PropertyFilter) GetComparisonOperator() ComparisonOperator { + if p == nil { + return "" + } + return p.ComparisonOperator +} + +func (p *PropertyFilter) GetPropertyName() string { + if p == nil { + return "" + } + return p.PropertyName +} + +func (p *PropertyFilter) GetPropertyValue() interface{} { + if p == nil { + return nil + } + return p.PropertyValue +} + +func (p *PropertyFilter) GetExtraProperties() map[string]interface{} { + return p.extraProperties +} + +func (p *PropertyFilter) UnmarshalJSON(data []byte) error { + type unmarshaler PropertyFilter + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *p = PropertyFilter(value) + extraProperties, err := internal.ExtractExtraProperties(data, *p) + if err != nil { + return err + } + p.extraProperties = extraProperties + p.rawJSON = json.RawMessage(data) + return nil +} + +func (p *PropertyFilter) String() string { + if len(p.rawJSON) > 0 { + if value, err := internal.StringifyJSON(p.rawJSON); err == nil { + return value + } + } + if value, err := internal.StringifyJSON(p); err == nil { + return value + } + return fmt.Sprintf("%#v", p) +} + type Reranker string const ( @@ -1048,6 +1125,8 @@ type SearchFilters struct { CreatedAt [][]*DateFilter `json:"created_at,omitempty" url:"created_at,omitempty"` // List of edge types to filter on EdgeTypes []string `json:"edge_types,omitempty" url:"edge_types,omitempty"` + // List of edge UUIDs to filter on + EdgeUUIDs []string `json:"edge_uuids,omitempty" url:"edge_uuids,omitempty"` // List of edge types to exclude from results ExcludeEdgeTypes []string `json:"exclude_edge_types,omitempty" url:"exclude_edge_types,omitempty"` // List of node labels to exclude from results @@ -1066,6 +1145,8 @@ type SearchFilters struct { InvalidAt [][]*DateFilter `json:"invalid_at,omitempty" url:"invalid_at,omitempty"` // List of node labels to filter on NodeLabels []string `json:"node_labels,omitempty" url:"node_labels,omitempty"` + // List of property filters to apply to nodes and edges + PropertyFilters []*PropertyFilter `json:"property_filters,omitempty" url:"property_filters,omitempty"` // 2D array of date filters for the valid_at field. // The outer array elements are combined with OR logic. // The inner array elements are combined with AND logic. @@ -1091,6 +1172,13 @@ func (s *SearchFilters) GetEdgeTypes() []string { return s.EdgeTypes } +func (s *SearchFilters) GetEdgeUUIDs() []string { + if s == nil { + return nil + } + return s.EdgeUUIDs +} + func (s *SearchFilters) GetExcludeEdgeTypes() []string { if s == nil { return nil @@ -1126,6 +1214,13 @@ func (s *SearchFilters) GetNodeLabels() []string { return s.NodeLabels } +func (s *SearchFilters) GetPropertyFilters() []*PropertyFilter { + if s == nil { + return nil + } + return s.PropertyFilters +} + func (s *SearchFilters) GetValidAt() [][]*DateFilter { if s == nil { return nil diff --git a/graph/node/client.go b/graph/node/client.go index 9ac71c6..1133867 100644 --- a/graph/node/client.go +++ b/graph/node/client.go @@ -131,3 +131,21 @@ func (c *Client) Get( } return response.Body, nil } + +// Deletes a node by UUID. +func (c *Client) Delete( + ctx context.Context, + // Node UUID + uuid string, + opts ...option.RequestOption, +) (*v3.SuccessResponse, error) { + response, err := c.WithRawResponse.Delete( + ctx, + uuid, + opts..., + ) + if err != nil { + return nil, err + } + return response.Body, nil +} diff --git a/graph/node/raw_client.go b/graph/node/raw_client.go index a4eef4c..60bf734 100644 --- a/graph/node/raw_client.go +++ b/graph/node/raw_client.go @@ -323,3 +323,60 @@ func (r *RawClient) Get( Body: response, }, nil } + +func (r *RawClient) Delete( + ctx context.Context, + // Node UUID + uuid string, + opts ...option.RequestOption, +) (*core.Response[*v3.SuccessResponse], error) { + options := core.NewRequestOptions(opts...) + baseURL := internal.ResolveBaseURL( + options.BaseURL, + r.baseURL, + "https://api.getzep.com/api/v2", + ) + endpointURL := internal.EncodeURL( + baseURL+"/graph/node/%v", + uuid, + ) + headers := internal.MergeHeaders( + r.header.Clone(), + options.ToHeader(), + ) + errorCodes := internal.ErrorCodes{ + 400: func(apiError *core.APIError) error { + return &v3.BadRequestError{ + APIError: apiError, + } + }, + 500: func(apiError *core.APIError) error { + return &v3.InternalServerError{ + APIError: apiError, + } + }, + } + var response *v3.SuccessResponse + raw, err := r.caller.Call( + ctx, + &internal.CallParams{ + URL: endpointURL, + Method: http.MethodDelete, + Headers: headers, + MaxAttempts: options.MaxAttempts, + BodyProperties: options.BodyProperties, + QueryParameters: options.QueryParameters, + Client: options.HTTPClient, + Response: &response, + ErrorDecoder: internal.NewErrorDecoder(errorCodes), + }, + ) + if err != nil { + return nil, err + } + return &core.Response[*v3.SuccessResponse]{ + StatusCode: raw.StatusCode, + Header: raw.Header, + Body: response, + }, nil +} diff --git a/thread.go b/thread.go index af0446c..fa27963 100644 --- a/thread.go +++ b/thread.go @@ -25,7 +25,7 @@ type ThreadGetRequest struct { } type ThreadGetUserContextRequest struct { - // The minimum rating by which to filter relevant facts. + // Deprecated, this field will be removed in a future release. The minimum rating by which to filter relevant facts. MinRating *float64 `json:"-" url:"minRating,omitempty"` // Optional template ID to use for custom context rendering. TemplateID *string `json:"-" url:"template_id,omitempty"` diff --git a/user.go b/user.go index 7b06f31..c09cc24 100644 --- a/user.go +++ b/user.go @@ -13,7 +13,7 @@ type CreateUserRequest struct { DisableDefaultOntology *bool `json:"disable_default_ontology,omitempty" url:"-"` // The email address of the user. Email *string `json:"email,omitempty" url:"-"` - // Optional instruction to use for fact rating. + // Deprecated: this field will be removed in a future release. Optional instruction to use for fact rating. FactRatingInstruction *FactRatingInstruction `json:"fact_rating_instruction,omitempty" url:"-"` // The first name of the user. FirstName *string `json:"first_name,omitempty" url:"-"` @@ -542,7 +542,7 @@ type UpdateUserRequest struct { DisableDefaultOntology *bool `json:"disable_default_ontology,omitempty" url:"-"` // The email address of the user. Email *string `json:"email,omitempty" url:"-"` - // Optional instruction to use for fact rating. + // Deprecated: this field will be removed in a future release. Optional instruction to use for fact rating. FactRatingInstruction *FactRatingInstruction `json:"fact_rating_instruction,omitempty" url:"-"` // The first name of the user. FirstName *string `json:"first_name,omitempty" url:"-"`