@@ -3,11 +3,9 @@ function New-Assistant {
33 [OutputType ([pscustomobject ])]
44 param (
55 # Hidden param, for Set-Assistant cmdlet
6- [Parameter (DontShow, ParameterSetName = ' Assistant' , ValueFromPipeline , ValueFromPipelineByPropertyName )]
7- [PSTypeName (' PSOpenAI.Assistant' )]$Assistant ,
8-
96 [Parameter (DontShow, ParameterSetName = ' AssistantId' , ValueFromPipeline , ValueFromPipelineByPropertyName )]
107 [ValidateNotNullOrEmpty ()]
8+ [Alias (' Assistant' )]
119 [string ][UrlEncodeTransformation ()]$AssistantId ,
1210
1311 [Parameter ()]
@@ -64,15 +62,15 @@ function New-Assistant {
6462
6563 [Parameter ()]
6664 [ValidateCount (0 , 20 )]
67- [object []]$FileIdsForCodeInterpreter ,
65+ [string []]$FileIdsForCodeInterpreter ,
6866
6967 [Parameter ()]
7068 [ValidateCount (1 , 1 )] # Currently, allow only 1 vector store
71- [object []]$VectorStoresForFileSearch ,
69+ [string []]$VectorStoresForFileSearch ,
7270
7371 [Parameter ()]
7472 [ValidateCount (0 , 10000 )]
75- [object []]$FileIdsForFileSearch ,
73+ [string []]$FileIdsForFileSearch ,
7674
7775 [Parameter ()]
7876 [ValidateRange (1 , 50 )]
@@ -208,46 +206,13 @@ function New-Assistant {
208206 # region Construct tools resources
209207 $ToolResources = @ {}
210208 if ($FileIdsForCodeInterpreter.Count -gt 0 ) {
211- $list = [System.Collections.Generic.List [string ]]::new($FileIdsForCodeInterpreter.Count )
212- foreach ($item in $FileIdsForCodeInterpreter ) {
213- if ($item -is [string ]) {
214- $list.Add ($item )
215- }
216- elseif ($item.psobject.TypeNames -contains ' PSOpenAI.File' ) {
217- $list.Add ($item.id )
218- }
219- }
220- if ($list.Count -gt 0 ) {
221- $ToolResources.code_interpreter = @ {' file_ids' = $list.ToArray () }
222- }
209+ $ToolResources.code_interpreter = @ {' file_ids' = $FileIdsForCodeInterpreter }
223210 }
224211 if ($FileIdsForFileSearch.Count -gt 0 ) {
225- $list = [System.Collections.Generic.List [string ]]::new($FileIdsForFileSearch.Count )
226- foreach ($item in $FileIdsForFileSearch ) {
227- if ($item -is [string ]) {
228- $list.Add ($item )
229- }
230- elseif ($item.psobject.TypeNames -contains ' PSOpenAI.File' ) {
231- $list.Add ($item.id )
232- }
233- }
234- if ($list.Count -gt 0 ) {
235- $ToolResources.file_search = @ {' vector_stores' = @ (@ {' file_ids' = $list.ToArray () }) }
236- }
212+ $ToolResources.file_search = @ {' vector_stores' = @ (@ {' file_ids' = $FileIdsForFileSearch }) }
237213 }
238214 if ($VectorStoresForFileSearch.Count -gt 0 ) {
239- $list = [System.Collections.Generic.List [string ]]::new($FileIdsForFileSearch.Count )
240- foreach ($item in $VectorStoresForFileSearch ) {
241- if ($item -is [string ]) {
242- $list.Add ($item )
243- }
244- elseif ($item.psobject.TypeNames -contains ' PSOpenAI.VectorStore' ) {
245- $list.Add ($item.id )
246- }
247- }
248- if ($list.Count -gt 0 ) {
249- $ToolResources.file_search = @ {' vector_store_ids' = $list.ToArray () }
250- }
215+ $ToolResources.file_search = @ {' vector_store_ids' = $VectorStoresForFileSearch }
251216 }
252217 # endregion
253218
0 commit comments