Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: provide vector store #772

Merged
merged 14 commits into from
Jun 19, 2024
50 changes: 33 additions & 17 deletions assistant.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,17 @@ const (
)

type Assistant struct {
ID string `json:"id"`
Object string `json:"object"`
CreatedAt int64 `json:"created_at"`
Name *string `json:"name,omitempty"`
Description *string `json:"description,omitempty"`
Model string `json:"model"`
Instructions *string `json:"instructions,omitempty"`
Tools []AssistantTool `json:"tools"`
FileIDs []string `json:"file_ids,omitempty"`
Metadata map[string]any `json:"metadata,omitempty"`
ID string `json:"id"`
Object string `json:"object"`
CreatedAt int64 `json:"created_at"`
Name *string `json:"name,omitempty"`
Description *string `json:"description,omitempty"`
Model string `json:"model"`
Instructions *string `json:"instructions,omitempty"`
Tools []AssistantTool `json:"tools"`
FileIDs []string `json:"file_ids,omitempty"`
Metadata map[string]any `json:"metadata,omitempty"`
ToolResources *AssistantToolResource `json:"tool_resources,omitempty"`

httpHeader
}
Expand All @@ -34,26 +35,41 @@ const (
AssistantToolTypeCodeInterpreter AssistantToolType = "code_interpreter"
AssistantToolTypeRetrieval AssistantToolType = "retrieval"
AssistantToolTypeFunction AssistantToolType = "function"
AssistantToolTypeFileSearch AssistantToolType = "file_search"
)

type AssistantTool struct {
Type AssistantToolType `json:"type"`
Function *FunctionDefinition `json:"function,omitempty"`
}

type AssistantToolFileSearch struct {
VectorStoreIDs []string `json:"vector_store_ids"`
}

type AssistantToolCodeInterpreter struct {
FileIDs []string `json:"file_ids"`
}

type AssistantToolResource struct {
FileSearch *AssistantToolFileSearch `json:"file_search,omitempty"`
CodeInterpreter *AssistantToolCodeInterpreter `json:"code_interpreter,omitempty"`
}

// AssistantRequest provides the assistant request parameters.
// When modifying the tools the API functions as the following:
// If Tools is undefined, no changes are made to the Assistant's tools.
// If Tools is empty slice it will effectively delete all of the Assistant's tools.
// If Tools is populated, it will replace all of the existing Assistant's tools with the provided tools.
type AssistantRequest struct {
Model string `json:"model"`
Name *string `json:"name,omitempty"`
Description *string `json:"description,omitempty"`
Instructions *string `json:"instructions,omitempty"`
Tools []AssistantTool `json:"-"`
FileIDs []string `json:"file_ids,omitempty"`
Metadata map[string]any `json:"metadata,omitempty"`
Model string `json:"model"`
Name *string `json:"name,omitempty"`
Description *string `json:"description,omitempty"`
Instructions *string `json:"instructions,omitempty"`
Tools []AssistantTool `json:"-"`
FileIDs []string `json:"file_ids,omitempty"`
Metadata map[string]any `json:"metadata,omitempty"`
ToolResources *AssistantToolResource `json:"tool_resources,omitempty"`
}

// MarshalJSON provides a custom marshaller for the assistant request to handle the API use cases
Expand Down
2 changes: 1 addition & 1 deletion config.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const (

const AzureAPIKeyHeader = "api-key"

const defaultAssistantVersion = "v1" // This will be deprecated by the end of 2024.
const defaultAssistantVersion = "v2" // upgrade to v2 to support vector store

// ClientConfig is a configuration of a client.
type ClientConfig struct {
Expand Down
Loading
Loading