@@ -30,7 +30,7 @@ public async Task Assistants_AllTools()
3030 instructions : "Use functions to resolve family relations into the names of people. Use file search to "
3131 + " look up the favorite numbers of people. Use code interpreter to create graphs of lines." ,
3232 tools : tools
33- . Select ( x => new ToolsItem2 ( new AssistantToolsFunction
33+ . Select ( x => new OneOf < global :: tryAGI . OpenAI . AssistantToolsCode , global :: tryAGI . OpenAI . AssistantToolsFileSearch , global :: tryAGI . OpenAI . AssistantToolsFunction > ( new AssistantToolsFunction
3434 {
3535 Function = x . Function ,
3636 } ) )
@@ -104,51 +104,51 @@ ListMessagesResponse messages
104104 foreach ( MessageObject message in messages . Data )
105105 {
106106 Console . WriteLine ( $ "[{ message . Role . ToString ( ) . ToUpper ( ) } ]: ") ;
107- foreach ( ContentItem2 contentItem in message . Content )
107+ foreach ( global :: tryAGI . OpenAI . OneOf < global :: tryAGI . OpenAI . MessageContentImageFileObject , global :: tryAGI . OpenAI . MessageContentImageUrlObject , global :: tryAGI . OpenAI . MessageContentTextObject , global :: tryAGI . OpenAI . MessageContentRefusalObject > contentItem in message . Content )
108108 {
109- if ( contentItem . ImageFile is { } imageFile )
109+ if ( contentItem . Value1 ? . ImageFile is { } imageFile )
110110 {
111- OpenAIFile imageInfo = await api . Files . RetrieveFileAsync ( imageFile . ImageFile . FileId ) ;
112- byte [ ] imageBytes = await api . Files . DownloadFileAsync ( imageFile . ImageFile . FileId ) ;
111+ OpenAIFile imageInfo = await api . Files . RetrieveFileAsync ( imageFile . FileId ) ;
112+ byte [ ] imageBytes = await api . Files . DownloadFileAsync ( imageFile . FileId ) ;
113113
114114 FileInfo fileInfo = new ( $ "{ imageInfo . Filename } .png") ;
115115
116116 await File . WriteAllBytesAsync ( fileInfo . FullName , imageBytes ) ;
117117
118118 Console . WriteLine ( $ "<image: { new Uri ( fileInfo . FullName ) . AbsoluteUri } >") ;
119119 }
120- if ( contentItem . ImageUrl is { } imageUrl )
120+ if ( contentItem . Value2 ? . ImageUrl is { } imageUrl )
121121 {
122- Console . WriteLine ( $ " <Image URL> { imageUrl . ImageUrl . Url } ") ;
122+ Console . WriteLine ( $ " <Image URL> { imageUrl . Url } ") ;
123123 }
124- if ( contentItem . Text is { } text )
124+ if ( contentItem . Value3 ? . Text is { } text )
125125 {
126- Console . WriteLine ( $ "{ text . Text . Value } ") ;
126+ Console . WriteLine ( $ "{ text . Value } ") ;
127127
128128 // Include annotations, if any.
129- if ( text . Text . Annotations . Count > 0 )
129+ if ( text . Annotations . Count > 0 )
130130 {
131131 Console . WriteLine ( ) ;
132- foreach ( AnnotationsItem annotation in text . Text . Annotations )
132+ foreach ( global :: tryAGI . OpenAI . OneOf < global :: tryAGI . OpenAI . MessageContentTextAnnotationsFileCitationObject , global :: tryAGI . OpenAI . MessageContentTextAnnotationsFilePathObject > annotation in text . Annotations )
133133 {
134- if ( annotation . FileCitation is { } fileCitation )
134+ if ( annotation . Value1 ? . FileCitation is { } fileCitation )
135135 {
136- Console . WriteLine ( $ "* File citation, file ID: { fileCitation . FileCitation . FileId } ") ;
137- Console . WriteLine ( $ "* Text to replace: { fileCitation . Text } ") ;
138- Console . WriteLine ( $ "* Message content index range: { fileCitation . StartIndex } -{ fileCitation . EndIndex } ") ;
136+ Console . WriteLine ( $ "* File citation, file ID: { fileCitation . FileId } ") ;
137+ // Console.WriteLine($"* Text to replace: {fileCitation}");
138+ // Console.WriteLine($"* Message content index range: {fileCitation.StartIndex}-{fileCitation.EndIndex}");
139139 }
140- if ( annotation . FilePath is { } filePath )
140+ if ( annotation . Value2 ? . FilePath is { } filePath )
141141 {
142- Console . WriteLine ( $ "* File output, new file ID: { filePath . FilePath . FileId } ") ;
143- Console . WriteLine ( $ "* Text to replace: { filePath . Text } ") ;
144- Console . WriteLine ( $ "* Message content index range: { filePath . StartIndex } -{ filePath . EndIndex } ") ;
142+ Console . WriteLine ( $ "* File output, new file ID: { filePath . FileId } ") ;
143+ // Console.WriteLine($"* Text to replace: {filePath.Text}");
144+ // Console.WriteLine($"* Message content index range: {filePath.StartIndex}-{filePath.EndIndex}");
145145 }
146146 }
147147 }
148148 }
149- if ( contentItem . Refusal is { } refusal )
149+ if ( contentItem . Value4 ? . Refusal is { } refusal )
150150 {
151- Console . WriteLine ( $ "Refusal: { refusal . Refusal } ") ;
151+ Console . WriteLine ( $ "Refusal: { refusal } ") ;
152152 }
153153 }
154154 Console . WriteLine ( ) ;
@@ -163,34 +163,34 @@ ListMessagesResponse messages
163163 foreach ( RunStepObject step in runSteps . Data )
164164 {
165165 Console . WriteLine ( $ "Run step: { step . Status } ") ;
166- foreach ( var toolCall in step . StepDetails . ToolCalls ? . ToolCalls ?? [ ] )
166+ foreach ( var toolCall in step . StepDetails . Value2 ? . ToolCalls ?? [ ] )
167167 {
168- if ( toolCall . CodeInterpreter is { } codeInterpreter )
168+ if ( toolCall . Value1 ? . CodeInterpreter is { } codeInterpreter )
169169 {
170- Console . WriteLine ( $ " --> Tool call: { codeInterpreter . Type } ") ;
171- foreach ( var output in codeInterpreter . CodeInterpreter . Outputs )
170+ // Console.WriteLine($" --> Tool call: {codeInterpreter.Type}");
171+ foreach ( var output in codeInterpreter . Outputs )
172172 {
173- if ( output . Logs is { } logs )
173+ if ( output . Value1 ? . Logs is { } logs )
174174 {
175- Console . WriteLine ( $ " --> Output: { logs . Logs } ") ;
175+ Console . WriteLine ( $ " --> Output: { logs } ") ;
176176 }
177- if ( output . Image is { } image )
177+ if ( output . Value2 ? . Image is { } image )
178178 {
179- Console . WriteLine ( $ " --> Output: { image . Image . FileId } ") ;
179+ Console . WriteLine ( $ " --> Output: { image . FileId } ") ;
180180 }
181181 }
182182 }
183- if ( toolCall . FileSearch is { } fileSearch )
183+ if ( toolCall . Value2 ? . FileSearch is { } fileSearch )
184184 {
185- Console . WriteLine ( $ " --> Tool call: { fileSearch . Type } ") ;
186- foreach ( var output in fileSearch . FileSearch . Results ?? [ ] )
185+ // Console.WriteLine($" --> Tool call: {fileSearch.Type}");
186+ foreach ( var output in fileSearch . Results ?? [ ] )
187187 {
188188 Console . WriteLine ( $ " --> Output: { output . FileId } ") ;
189189 }
190190 }
191- if ( toolCall . Function is { } tool )
191+ if ( toolCall . Value3 ? . Function is { } tool )
192192 {
193- Console . WriteLine ( $ " --> Tool call: { tool . Type } ") ;
193+ // Console.WriteLine($" --> Tool call: {tool.Type}");
194194 }
195195 }
196196 }
0 commit comments