Skip to content

Commit 68acf22

Browse files
authored
Support Tool Resources properties for Threads (#760)
* Support Tool Resources properties for Threads * Add Chunking Strategy for Threads vector stores
1 parent 99cc170 commit 68acf22

File tree

1 file changed

+60
-7
lines changed

1 file changed

+60
-7
lines changed

thread.go

+60-7
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,74 @@ const (
1010
)
1111

1212
type Thread struct {
13-
ID string `json:"id"`
14-
Object string `json:"object"`
15-
CreatedAt int64 `json:"created_at"`
16-
Metadata map[string]any `json:"metadata"`
13+
ID string `json:"id"`
14+
Object string `json:"object"`
15+
CreatedAt int64 `json:"created_at"`
16+
Metadata map[string]any `json:"metadata"`
17+
ToolResources ToolResources `json:"tool_resources,omitempty"`
1718

1819
httpHeader
1920
}
2021

2122
type ThreadRequest struct {
22-
Messages []ThreadMessage `json:"messages,omitempty"`
23-
Metadata map[string]any `json:"metadata,omitempty"`
23+
Messages []ThreadMessage `json:"messages,omitempty"`
24+
Metadata map[string]any `json:"metadata,omitempty"`
25+
ToolResources *ToolResourcesRequest `json:"tool_resources,omitempty"`
2426
}
2527

28+
type ToolResources struct {
29+
CodeInterpreter *CodeInterpreterToolResources `json:"code_interpreter,omitempty"`
30+
FileSearch *FileSearchToolResources `json:"file_search,omitempty"`
31+
}
32+
33+
type CodeInterpreterToolResources struct {
34+
FileIDs []string `json:"file_ids,omitempty"`
35+
}
36+
37+
type FileSearchToolResources struct {
38+
VectorStoreIDs []string `json:"vector_store_ids,omitempty"`
39+
}
40+
41+
type ToolResourcesRequest struct {
42+
CodeInterpreter *CodeInterpreterToolResourcesRequest `json:"code_interpreter,omitempty"`
43+
FileSearch *FileSearchToolResourcesRequest `json:"file_search,omitempty"`
44+
}
45+
46+
type CodeInterpreterToolResourcesRequest struct {
47+
FileIDs []string `json:"file_ids,omitempty"`
48+
}
49+
50+
type FileSearchToolResourcesRequest struct {
51+
VectorStoreIDs []string `json:"vector_store_ids,omitempty"`
52+
VectorStores []VectorStoreToolResources `json:"vector_stores,omitempty"`
53+
}
54+
55+
type VectorStoreToolResources struct {
56+
FileIDs []string `json:"file_ids,omitempty"`
57+
ChunkingStrategy *ChunkingStrategy `json:"chunking_strategy,omitempty"`
58+
Metadata map[string]any `json:"metadata,omitempty"`
59+
}
60+
61+
type ChunkingStrategy struct {
62+
Type ChunkingStrategyType `json:"type"`
63+
Static *StaticChunkingStrategy `json:"static,omitempty"`
64+
}
65+
66+
type StaticChunkingStrategy struct {
67+
MaxChunkSizeTokens int `json:"max_chunk_size_tokens"`
68+
ChunkOverlapTokens int `json:"chunk_overlap_tokens"`
69+
}
70+
71+
type ChunkingStrategyType string
72+
73+
const (
74+
ChunkingStrategyTypeAuto ChunkingStrategyType = "auto"
75+
ChunkingStrategyTypeStatic ChunkingStrategyType = "static"
76+
)
77+
2678
type ModifyThreadRequest struct {
27-
Metadata map[string]any `json:"metadata"`
79+
Metadata map[string]any `json:"metadata"`
80+
ToolResources *ToolResources `json:"tool_resources,omitempty"`
2881
}
2982

3083
type ThreadMessageRole string

0 commit comments

Comments
 (0)