@@ -85,7 +85,9 @@ class AssistantResource {
8585
8686 if ($this.objTypeName ) {
8787 return $this.Client.web ($this.urifragment ).data | ForEach-Object {
88- New-Object - TypeName $this.objTypeName - ArgumentList $_
88+ $result = New-Object - TypeName $this.objTypeName - ArgumentList $_
89+ $result | Add-Member - MemberType NoteProperty - Name client - Value $this.Client
90+ $result
8991 }
9092 }
9193
@@ -94,7 +96,9 @@ class AssistantResource {
9496
9597 [psobject ]get([string ]$id ) {
9698 if ($this.objTypeName ) {
97- return New-Object - TypeName $this.objTypeName - ArgumentList $this.Client.web (" $ ( $this.urifragment ) /$id " )
99+ $result = New-Object - TypeName $this.objTypeName - ArgumentList $this.Client.web (" $ ( $this.urifragment ) /$id " )
100+ $result | Add-Member - MemberType NoteProperty - Name client - Value $this.Client
101+ return $result
98102 }
99103
100104 return $this.Client.web (" $ ( $this.urifragment ) /$id " )
@@ -106,7 +110,9 @@ class AssistantResource {
106110
107111 [psobject ]create([hashtable ]$body ) {
108112 if ($this.objTypeName ) {
109- return New-Object - TypeName $this.objTypeName - ArgumentList $this.Client.web (" $ ( $this.urifragment ) " , " POST" , $body )
113+ $result = New-Object - TypeName $this.objTypeName - ArgumentList $this.Client.web (" $ ( $this.urifragment ) " , " POST" , $body )
114+ $result | Add-Member - MemberType NoteProperty - Name client - Value $this.Client
115+ return $result
110116 }
111117 return $this.Client.web (" $ ( $this.urifragment ) " , " POST" , $body )
112118 }
@@ -318,9 +324,37 @@ class AssistantObject:AssistantResourceObject {
318324
319325class ThreadObject :AssistantResourceObject {
320326 ThreadObject([psobject ]$data ):base($data ) {}
327+
328+ [psobject ]send([string ]$message ) {
329+ # send a message
330+ $obj = [AssistantResource ]::new($this.client , (" threads/{0}/messages" -f $this.id ), $null ).create(@ {
331+ role = " user"
332+ content = $message
333+ })
334+ $this | Add-Member - MemberType NoteProperty - Name last_user_message - Value $obj.id
335+ return $this
336+ }
337+
338+ [psobject ]run([string ]$assistantId ) {
339+ $obj = [AssistantResource ]::new($this.client , (" threads/{0}/runs" -f $this.id ), $null ).create(@ {assistant_id = $assistantId })
340+ $this | Add-Member - MemberType NoteProperty - Name last_run - Value $obj.id
341+ return $this
342+ }
343+
344+ [psobject ]get_last_message() {
345+ return $null
346+ }
321347}
322348class Thread :AssistantResource {
323349 Thread([OpenAIClient ]$client ): base($client , " threads" , " ThreadObject" ) {}
350+
351+ [psobject []]list() {
352+ return @ {
353+ error = " It is not implement yet, you can't get all the thread information."
354+ }
355+ }
356+
357+
324358}
325359
326360class Vector_store :AssistantResource {
0 commit comments