|  | 
|  | 1 | +use super::*; | 
|  | 2 | +use openai_api_rs::v1::assistant; | 
|  | 3 | + | 
|  | 4 | +/// A wrapper for `AssistantObject` to make pretty print. | 
|  | 5 | +#[ derive( Debug ) ] | 
|  | 6 | +pub struct AssistantObjectWrap( pub assistant::AssistantObject ); | 
|  | 7 | + | 
|  | 8 | +impl Clone for AssistantObjectWrap | 
|  | 9 | +{ | 
|  | 10 | +  fn clone( &self ) -> Self | 
|  | 11 | +  { | 
|  | 12 | +    // Manually clone each field of the wrapped AssistantObject | 
|  | 13 | +    AssistantObjectWrap( assistant::AssistantObject | 
|  | 14 | +    { | 
|  | 15 | +      id : self.0.id.clone(), | 
|  | 16 | +      object : self.0.object.clone(), | 
|  | 17 | +      created_at : self.0.created_at, | 
|  | 18 | +      name : self.0.name.clone(), | 
|  | 19 | +      description : self.0.description.clone(), | 
|  | 20 | +      model : self.0.model.clone(), | 
|  | 21 | +      instructions : self.0.instructions.clone(), | 
|  | 22 | +      tools : self.0.tools.clone(), | 
|  | 23 | +      tool_resources : self.0.tool_resources.clone(), | 
|  | 24 | +      metadata : self.0.metadata.clone(), | 
|  | 25 | +      headers : self.0.headers.clone(), | 
|  | 26 | +    } ) | 
|  | 27 | +  } | 
|  | 28 | +} | 
|  | 29 | + | 
|  | 30 | +impl TableWithFields for AssistantObjectWrap {} | 
|  | 31 | +impl Fields< &'_ str, Option< Cow< '_, str > > > | 
|  | 32 | +for AssistantObjectWrap | 
|  | 33 | +{ | 
|  | 34 | +  type Key< 'k > = &'k str; | 
|  | 35 | +  type Val< 'v > = Option< Cow< 'v, str > >; | 
|  | 36 | + | 
|  | 37 | +  fn fields( &self ) -> impl format_tools::IteratorTrait< Item = ( &'_ str, Option< Cow< '_, str > > ) > | 
|  | 38 | +  { | 
|  | 39 | +    use format_tools::ref_or_display_or_debug_multiline::field; | 
|  | 40 | +    let mut dst = Vec::new(); | 
|  | 41 | + | 
|  | 42 | +    // Use the field! macro for direct field references | 
|  | 43 | +    dst.push( field!( &self.0.id ) ); | 
|  | 44 | +    dst.push( field!( &self.0.object ) ); | 
|  | 45 | +    dst.push( field!( &self.0.model ) ); | 
|  | 46 | + | 
|  | 47 | +    // Manually handle fields that require function calls | 
|  | 48 | +    dst.push( ( "created_at", Some( Cow::Owned( self.0.created_at.to_string() ) ) ) ); | 
|  | 49 | +    dst.push( ( "name", self.0.name.as_deref().map( Cow::Borrowed ) ) ); | 
|  | 50 | +    dst.push( ( "description", self.0.description.as_deref().map( Cow::Borrowed ) ) ); | 
|  | 51 | +    dst.push( ( "instructions", self.0.instructions.as_deref().map( Cow::Borrowed ) ) ); | 
|  | 52 | + | 
|  | 53 | +    // Handle complex fields like `tools`, `tool_resources`, `metadata`, and `headers` | 
|  | 54 | +    if !self.0.tools.is_empty() | 
|  | 55 | +    { | 
|  | 56 | +      dst.push( ( "tools", Some( Cow::Borrowed( "tools present" ) ) ) ); | 
|  | 57 | +    } | 
|  | 58 | +    else | 
|  | 59 | +    { | 
|  | 60 | +      dst.push( ( "tools", Option::None ) ); | 
|  | 61 | +    } | 
|  | 62 | + | 
|  | 63 | +    if let Some( _metadata ) = &self.0.metadata | 
|  | 64 | +    { | 
|  | 65 | +      dst.push( ( "metadata", Some( Cow::Borrowed( "metadata present" ) ) ) ); | 
|  | 66 | +    } | 
|  | 67 | +    else | 
|  | 68 | +    { | 
|  | 69 | +      dst.push( ( "metadata", Option::None ) ); | 
|  | 70 | +    } | 
|  | 71 | + | 
|  | 72 | +    if let Some( _headers ) = &self.0.headers | 
|  | 73 | +    { | 
|  | 74 | +      dst.push( ( "headers", Some( Cow::Borrowed( "headers present" ) ) ) ); | 
|  | 75 | +    } | 
|  | 76 | +    else | 
|  | 77 | +    { | 
|  | 78 | +      dst.push( ( "headers", Option::None ) ); | 
|  | 79 | +    } | 
|  | 80 | + | 
|  | 81 | +    dst.into_iter() | 
|  | 82 | +  } | 
|  | 83 | +} | 
0 commit comments