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

Support Tool Resources properties for Threads #760

Merged
merged 2 commits into from
Jun 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 60 additions & 7 deletions thread.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,74 @@ const (
)

type Thread struct {
ID string `json:"id"`
Object string `json:"object"`
CreatedAt int64 `json:"created_at"`
Metadata map[string]any `json:"metadata"`
ID string `json:"id"`
Object string `json:"object"`
CreatedAt int64 `json:"created_at"`
Metadata map[string]any `json:"metadata"`
ToolResources ToolResources `json:"tool_resources,omitempty"`

httpHeader
}

type ThreadRequest struct {
Messages []ThreadMessage `json:"messages,omitempty"`
Metadata map[string]any `json:"metadata,omitempty"`
Messages []ThreadMessage `json:"messages,omitempty"`
Metadata map[string]any `json:"metadata,omitempty"`
ToolResources *ToolResourcesRequest `json:"tool_resources,omitempty"`
}

type ToolResources struct {
CodeInterpreter *CodeInterpreterToolResources `json:"code_interpreter,omitempty"`
FileSearch *FileSearchToolResources `json:"file_search,omitempty"`
}

type CodeInterpreterToolResources struct {
FileIDs []string `json:"file_ids,omitempty"`
}

type FileSearchToolResources struct {
VectorStoreIDs []string `json:"vector_store_ids,omitempty"`
}

type ToolResourcesRequest struct {
CodeInterpreter *CodeInterpreterToolResourcesRequest `json:"code_interpreter,omitempty"`
FileSearch *FileSearchToolResourcesRequest `json:"file_search,omitempty"`
}

type CodeInterpreterToolResourcesRequest struct {
FileIDs []string `json:"file_ids,omitempty"`
}

type FileSearchToolResourcesRequest struct {
VectorStoreIDs []string `json:"vector_store_ids,omitempty"`
VectorStores []VectorStoreToolResources `json:"vector_stores,omitempty"`
}

type VectorStoreToolResources struct {
FileIDs []string `json:"file_ids,omitempty"`
ChunkingStrategy *ChunkingStrategy `json:"chunking_strategy,omitempty"`
Metadata map[string]any `json:"metadata,omitempty"`
}

type ChunkingStrategy struct {
Type ChunkingStrategyType `json:"type"`
Static *StaticChunkingStrategy `json:"static,omitempty"`
}

type StaticChunkingStrategy struct {
MaxChunkSizeTokens int `json:"max_chunk_size_tokens"`
ChunkOverlapTokens int `json:"chunk_overlap_tokens"`
}

type ChunkingStrategyType string

const (
ChunkingStrategyTypeAuto ChunkingStrategyType = "auto"
ChunkingStrategyTypeStatic ChunkingStrategyType = "static"
)

type ModifyThreadRequest struct {
Metadata map[string]any `json:"metadata"`
Metadata map[string]any `json:"metadata"`
ToolResources *ToolResources `json:"tool_resources,omitempty"`
}

type ThreadMessageRole string
Expand Down
Loading