@@ -36,6 +36,7 @@ private sealed class LLamaExecutorChatClient(
3636        IHistoryTransform ?  historyTransform  =  null , 
3737        ITextStreamTransform ?  outputTransform  =  null )  :  IChatClient 
3838    { 
39+         private  static   readonly  ChatClientMetadata  s_metadata  =  new ( nameof ( LLamaExecutorChatClient ) ) ; 
3940        private  static   readonly  InferenceParams  s_defaultParams  =  new ( ) ; 
4041        private  static   readonly  DefaultSamplingPipeline  s_defaultPipeline  =  new ( ) ; 
4142        private  static   readonly  string [ ]  s_antiPrompts  =  [ "User:" ,  "Assistant:" ,  "System:" ] ; 
@@ -47,21 +48,19 @@ private sealed class LLamaExecutorChatClient(
4748        private  readonly  ITextStreamTransform  _outputTransform  =  outputTransform  ?? 
4849            new  LLamaTransforms . KeywordTextOutputStreamTransform ( s_antiPrompts ) ; 
4950
50-         /// <inheritdoc/> 
51-         public  ChatClientMetadata  Metadata  {  get ;  }  =  new ( nameof ( LLamaExecutorChatClient ) ) ; 
52- 
5351        /// <inheritdoc/> 
5452        public  void  Dispose ( )  {  } 
5553
5654        /// <inheritdoc/> 
57-         public  object ?  GetService ( Type  serviceType ,  object ?  key  =  null )  => 
58-             key  is  not null  ?  null  : 
55+         public  object ?  GetService ( Type  serviceType ,  object ?  serviceKey  =  null )  => 
56+             serviceKey  is  not null  ?  null  : 
57+             serviceType  ==  typeof ( ChatClientMetadata )  ?  s_metadata  : 
5958            serviceType ? . IsInstanceOfType ( _executor )  is  true  ?  _executor  : 
6059            serviceType ? . IsInstanceOfType ( this )  is  true  ?  this  : 
6160            null ; 
6261
6362        /// <inheritdoc/> 
64-         public  async  Task < ChatCompletion >   CompleteAsync ( 
63+         public  async  Task < ChatResponse >   GetResponseAsync ( 
6564            IList < ChatMessage >  chatMessages ,  ChatOptions ?  options  =  null ,  CancellationToken  cancellationToken  =  default ) 
6665        { 
6766            var  result  =  _executor . InferAsync ( CreatePrompt ( chatMessages ) ,  CreateInferenceParams ( options ) ,  cancellationToken ) ; 
@@ -79,7 +78,7 @@ public async Task<ChatCompletion> CompleteAsync(
7978        } 
8079
8180        /// <inheritdoc/> 
82-         public  async  IAsyncEnumerable < StreamingChatCompletionUpdate >   CompleteStreamingAsync ( 
81+         public  async  IAsyncEnumerable < ChatResponseUpdate >   GetStreamingResponseAsync ( 
8382            IList < ChatMessage >  chatMessages ,  ChatOptions ?  options  =  null ,  [ EnumeratorCancellation ]  CancellationToken  cancellationToken  =  default ) 
8483        { 
8584            var  result  =  _executor . InferAsync ( CreatePrompt ( chatMessages ) ,  CreateInferenceParams ( options ) ,  cancellationToken ) ; 
@@ -142,8 +141,8 @@ private string CreatePrompt(IList<ChatMessage> messages)
142141                MaxTokens  =  options ? . MaxOutputTokens  ??  256 ,  // arbitrary upper limit 
143142                SamplingPipeline  =  new  DefaultSamplingPipeline ( ) 
144143                { 
145-                     FrequencyPenalty  =  options ? . AdditionalProperties ? . TryGetValue ( nameof ( DefaultSamplingPipeline . FrequencyPenalty ) ,   out   float   af )   is   true   ?   af   :  s_defaultPipeline . FrequencyPenalty , 
146-                     PresencePenalty  =  options ? . AdditionalProperties ? . TryGetValue ( nameof ( DefaultSamplingPipeline . PresencePenalty ) ,   out   float   ap )   is   true   ?   ap   :  s_defaultPipeline . PresencePenalty , 
144+                     FrequencyPenalty  =  options ? . FrequencyPenalty   ??  s_defaultPipeline . FrequencyPenalty , 
145+                     PresencePenalty  =  options ? . PresencePenalty   ??  s_defaultPipeline . PresencePenalty , 
147146                    PreventEOS  =  options ? . AdditionalProperties ? . TryGetValue ( nameof ( DefaultSamplingPipeline . PreventEOS ) ,  out  bool  eos )  is  true  ?  eos  :  s_defaultPipeline . PreventEOS , 
148147                    PenalizeNewline  =  options ? . AdditionalProperties ? . TryGetValue ( nameof ( DefaultSamplingPipeline . PenalizeNewline ) ,  out  bool  pnl )  is  true  ?  pnl  :  s_defaultPipeline . PenalizeNewline , 
149148                    RepeatPenalty  =  options ? . AdditionalProperties ? . TryGetValue ( nameof ( DefaultSamplingPipeline . RepeatPenalty ) ,  out  float  rp )  is  true  ?  rp  :  s_defaultPipeline . RepeatPenalty , 
@@ -152,8 +151,8 @@ private string CreatePrompt(IList<ChatMessage> messages)
152151                    MinKeep  =  options ? . AdditionalProperties ? . TryGetValue ( nameof ( DefaultSamplingPipeline . MinKeep ) ,  out  int  mk )  is  true  ?  mk  :  s_defaultPipeline . MinKeep , 
153152                    MinP  =  options ? . AdditionalProperties ? . TryGetValue ( nameof ( DefaultSamplingPipeline . MinP ) ,  out  float  mp )  is  true  ?  mp  :  s_defaultPipeline . MinP , 
154153                    Seed  =  options ? . Seed  is  long  seed  ?  ( uint ) seed  :  ( uint ) ( t_random  ??=  new ( ) ) . Next ( ) , 
155-                     Temperature  =  options ? . Temperature  ??  0 , 
156-                     TopP  =  options ? . TopP  ??  0 , 
154+                     Temperature  =  options ? . Temperature  ??  s_defaultPipeline . Temperature , 
155+                     TopP  =  options ? . TopP  ??  s_defaultPipeline . TopP , 
157156                    TopK  =  options ? . TopK  ??  s_defaultPipeline . TopK , 
158157                    TypicalP  =  options ? . AdditionalProperties ? . TryGetValue ( nameof ( DefaultSamplingPipeline . TypicalP ) ,  out  float  tp )  is  true  ?  tp  :  s_defaultPipeline . TypicalP , 
159158                } , 
0 commit comments