1package openai
2
3import (
4 "slices"
5
6 "charm.land/fantasy"
7)
8
9type ResponsesReasoningMetadata struct {
10 ItemID string `json:"item_id"`
11 EncryptedContent *string `json:"encrypted_content"`
12 Summary []string `json:"summary"`
13}
14
15func (*ResponsesReasoningMetadata) Options() {}
16
17type IncludeType string
18
19const (
20 IncludeReasoningEncryptedContent IncludeType = "reasoning.encrypted_content"
21 IncludeFileSearchCallResults IncludeType = "file_search_call.results"
22 IncludeMessageOutputTextLogprobs IncludeType = "message.output_text.logprobs"
23)
24
25type ServiceTier string
26
27const (
28 ServiceTierAuto ServiceTier = "auto"
29 ServiceTierFlex ServiceTier = "flex"
30 ServiceTierPriority ServiceTier = "priority"
31)
32
33type TextVerbosity string
34
35const (
36 TextVerbosityLow TextVerbosity = "low"
37 TextVerbosityMedium TextVerbosity = "medium"
38 TextVerbosityHigh TextVerbosity = "high"
39)
40
41type ResponsesProviderOptions struct {
42 Include []IncludeType `json:"include"`
43 Instructions *string `json:"instructions"`
44 Logprobs any `json:"logprobs"`
45 MaxToolCalls *int64 `json:"max_tool_calls"`
46 Metadata map[string]any `json:"metadata"`
47 ParallelToolCalls *bool `json:"parallel_tool_calls"`
48 PromptCacheKey *string `json:"prompt_cache_key"`
49 ReasoningEffort *ReasoningEffort `json:"reasoning_effort"`
50 ReasoningSummary *string `json:"reasoning_summary"`
51 SafetyIdentifier *string `json:"safety_identifier"`
52 ServiceTier *ServiceTier `json:"service_tier"`
53 StrictJSONSchema *bool `json:"strict_json_schema"`
54 TextVerbosity *TextVerbosity `json:"text_verbosity"`
55 User *string `json:"user"`
56}
57
58var responsesReasoningModelIds = []string{
59 "o1",
60 "o1-2024-12-17",
61 "o3-mini",
62 "o3-mini-2025-01-31",
63 "o3",
64 "o3-2025-04-16",
65 "o4-mini",
66 "o4-mini-2025-04-16",
67 "codex-mini-latest",
68 "gpt-5",
69 "gpt-5-2025-08-07",
70 "gpt-5-mini",
71 "gpt-5-mini-2025-08-07",
72 "gpt-5-nano",
73 "gpt-5-nano-2025-08-07",
74 "gpt-5-codex",
75}
76
77var responsesModelIds = append([]string{
78 "gpt-4.1",
79 "gpt-4.1-2025-04-14",
80 "gpt-4.1-mini",
81 "gpt-4.1-mini-2025-04-14",
82 "gpt-4.1-nano",
83 "gpt-4.1-nano-2025-04-14",
84 "gpt-4o",
85 "gpt-4o-2024-05-13",
86 "gpt-4o-2024-08-06",
87 "gpt-4o-2024-11-20",
88 "gpt-4o-mini",
89 "gpt-4o-mini-2024-07-18",
90 "gpt-4-turbo",
91 "gpt-4-turbo-2024-04-09",
92 "gpt-4-turbo-preview",
93 "gpt-4-0125-preview",
94 "gpt-4-1106-preview",
95 "gpt-4",
96 "gpt-4-0613",
97 "gpt-4.5-preview",
98 "gpt-4.5-preview-2025-02-27",
99 "gpt-3.5-turbo-0125",
100 "gpt-3.5-turbo",
101 "gpt-3.5-turbo-1106",
102 "chatgpt-4o-latest",
103 "gpt-5-chat-latest",
104}, responsesReasoningModelIds...)
105
106func (*ResponsesProviderOptions) Options() {}
107
108func NewResponsesProviderOptions(opts *ResponsesProviderOptions) fantasy.ProviderOptions {
109 return fantasy.ProviderOptions{
110 Name: opts,
111 }
112}
113
114func ParseResponsesOptions(data map[string]any) (*ResponsesProviderOptions, error) {
115 var options ResponsesProviderOptions
116 if err := fantasy.ParseOptions(data, &options); err != nil {
117 return nil, err
118 }
119 return &options, nil
120}
121
122func IsResponsesModel(modelID string) bool {
123 return slices.Contains(responsesModelIds, modelID)
124}
125
126func IsResponsesReasoningModel(modelID string) bool {
127 return slices.Contains(responsesReasoningModelIds, modelID)
128}