Skip to content

Commit 0a42130

Browse files
feat: provide vector store (sashabaranov#772)
* implement vectore store feature * fix after integration testing * fix golint error * improve test to increare code coverage * fix golint anc code coverage problem * add tool_resource in assistant response * chore: code style * feat: use pagination param * feat: use pagination param * test: use pagination param * test: rm unused code --------- Co-authored-by: Denny Depok <[email protected]> Co-authored-by: eric.p <eric.p>
1 parent 68acf22 commit 0a42130

File tree

4 files changed

+728
-18
lines changed

4 files changed

+728
-18
lines changed

assistant.go

+33-17
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,17 @@ const (
1414
)
1515

1616
type Assistant struct {
17-
ID string `json:"id"`
18-
Object string `json:"object"`
19-
CreatedAt int64 `json:"created_at"`
20-
Name *string `json:"name,omitempty"`
21-
Description *string `json:"description,omitempty"`
22-
Model string `json:"model"`
23-
Instructions *string `json:"instructions,omitempty"`
24-
Tools []AssistantTool `json:"tools"`
25-
FileIDs []string `json:"file_ids,omitempty"`
26-
Metadata map[string]any `json:"metadata,omitempty"`
17+
ID string `json:"id"`
18+
Object string `json:"object"`
19+
CreatedAt int64 `json:"created_at"`
20+
Name *string `json:"name,omitempty"`
21+
Description *string `json:"description,omitempty"`
22+
Model string `json:"model"`
23+
Instructions *string `json:"instructions,omitempty"`
24+
Tools []AssistantTool `json:"tools"`
25+
FileIDs []string `json:"file_ids,omitempty"`
26+
Metadata map[string]any `json:"metadata,omitempty"`
27+
ToolResources *AssistantToolResource `json:"tool_resources,omitempty"`
2728

2829
httpHeader
2930
}
@@ -34,26 +35,41 @@ const (
3435
AssistantToolTypeCodeInterpreter AssistantToolType = "code_interpreter"
3536
AssistantToolTypeRetrieval AssistantToolType = "retrieval"
3637
AssistantToolTypeFunction AssistantToolType = "function"
38+
AssistantToolTypeFileSearch AssistantToolType = "file_search"
3739
)
3840

3941
type AssistantTool struct {
4042
Type AssistantToolType `json:"type"`
4143
Function *FunctionDefinition `json:"function,omitempty"`
4244
}
4345

46+
type AssistantToolFileSearch struct {
47+
VectorStoreIDs []string `json:"vector_store_ids"`
48+
}
49+
50+
type AssistantToolCodeInterpreter struct {
51+
FileIDs []string `json:"file_ids"`
52+
}
53+
54+
type AssistantToolResource struct {
55+
FileSearch *AssistantToolFileSearch `json:"file_search,omitempty"`
56+
CodeInterpreter *AssistantToolCodeInterpreter `json:"code_interpreter,omitempty"`
57+
}
58+
4459
// AssistantRequest provides the assistant request parameters.
4560
// When modifying the tools the API functions as the following:
4661
// If Tools is undefined, no changes are made to the Assistant's tools.
4762
// If Tools is empty slice it will effectively delete all of the Assistant's tools.
4863
// If Tools is populated, it will replace all of the existing Assistant's tools with the provided tools.
4964
type AssistantRequest struct {
50-
Model string `json:"model"`
51-
Name *string `json:"name,omitempty"`
52-
Description *string `json:"description,omitempty"`
53-
Instructions *string `json:"instructions,omitempty"`
54-
Tools []AssistantTool `json:"-"`
55-
FileIDs []string `json:"file_ids,omitempty"`
56-
Metadata map[string]any `json:"metadata,omitempty"`
65+
Model string `json:"model"`
66+
Name *string `json:"name,omitempty"`
67+
Description *string `json:"description,omitempty"`
68+
Instructions *string `json:"instructions,omitempty"`
69+
Tools []AssistantTool `json:"-"`
70+
FileIDs []string `json:"file_ids,omitempty"`
71+
Metadata map[string]any `json:"metadata,omitempty"`
72+
ToolResources *AssistantToolResource `json:"tool_resources,omitempty"`
5773
}
5874

5975
// MarshalJSON provides a custom marshaller for the assistant request to handle the API use cases

config.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ const (
2424

2525
const AzureAPIKeyHeader = "api-key"
2626

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

2929
// ClientConfig is a configuration of a client.
3030
type ClientConfig struct {

0 commit comments

Comments
 (0)