Skip to content

Commit

Permalink
tweaks to support response_format for assistants
Browse files Browse the repository at this point in the history
  • Loading branch information
skyscrapr committed Aug 22, 2024
1 parent bc747da commit 5354d38
Showing 1 changed file with 25 additions and 12 deletions.
37 changes: 25 additions & 12 deletions openai/assistant.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,19 @@ func (c *Client) Assistants() *AssistantsEndpoint {
}

type Assistant struct {
Id string `json:"id"`
Object string `json:"object"` // The object type, which is always assistant.
CreatedAt int64 `json:"created_at"`
Name *string `json:"name"`
Description *string `json:"description"`
Model string `json:"model"`
Instructions *string `json:"instructions"`
Tools []AssistantTool `json:"tools,omitempty"`
ToolResources *AssistantToolResources `json:"tool_resources,omitempty"`
MetaData map[string]string `json:"metadata,omitempty"`
Temperature float64 `json:"temperature,omitempty"`
TopP float64 `json:"top_p,omitempty"`
Id string `json:"id"`
Object string `json:"object"` // The object type, which is always assistant.
CreatedAt int64 `json:"created_at"`
Name *string `json:"name"`
Description *string `json:"description"`
Model string `json:"model"`
Instructions *string `json:"instructions"`
Tools []AssistantTool `json:"tools,omitempty"`
ToolResources *AssistantToolResources `json:"tool_resources,omitempty"`
MetaData map[string]string `json:"metadata,omitempty"`
Temperature float64 `json:"temperature,omitempty"`
TopP float64 `json:"top_p,omitempty"`
ResponseFormat *AssistantResponseFormat `json:"response_format,omitempty"`
}

type Assistants struct {
Expand Down Expand Up @@ -68,6 +69,8 @@ type AssistantRequest struct {

Temperature float64 `json:"temperature,omitempty"`
TopP float64 `json:"top_p,omitempty"`

ResponseFormat *AssistantResponseFormat `json:"response_format,omitempty"`
}

type AssistantFile struct {
Expand Down Expand Up @@ -110,6 +113,16 @@ type AssistantToolResources struct {
} `json:"file_search,omitempty"`
}

type AssistantResponseFormat struct {
Type string `json:"type"`
JsonSchema *struct {
Description *string `json:"description,omitempty"`
Name string `json:"name"`
Schema map[string]interface{} `json:"schema"`
Strict bool `json:"strict,omitempty"`
} `json:"json_schema,omitempty"`
}

// Create an assistant with a model and instructions.
// [OpenAI Documentation]: https://platform.openai.com/docs/api-reference/assistants/createAssistant
func (e *AssistantsEndpoint) CreateAssistant(req *AssistantRequest) (*Assistant, error) {
Expand Down

0 comments on commit 5354d38

Please sign in to comment.