@@ -31,36 +31,36 @@ export interface AIClient {
3131 * @example
3232 * ```
3333 * const key = "welcome_prompt";
34- * const context = new LDContext( ...) ;
35- * const variables = new Record<string, string>([[" username", "John"]]) ;
36- * const defaultValue = {}} ;
34+ * const context = { ...} ;
35+ * const variables = { username: 'john} ;
36+ * const defaultValue = {};
3737 *
3838 * const result = modelConfig(key, context, defaultValue, variables);
3939 * // Output:
4040 * {
41- * modelId: "gpt-4o",
42- * temperature: 0.2,
43- * maxTokens: 4096,
44- * userDefinedKey: "myValue",
45- * prompt: [
46- * {
47- * role: "system",
48- * content: "You are an amazing GPT."
49- * },
50- * {
51- * role: "user",
52- * content: "Explain how you're an amazing GPT."
53- * }
54- * ]
41+ * modelId: "gpt-4o",
42+ * temperature: 0.2,
43+ * maxTokens: 4096,
44+ * userDefinedKey: "myValue",
45+ * prompt: [
46+ * {
47+ * role: "system",
48+ * content: "You are an amazing GPT."
49+ * },
50+ * {
51+ * role: "user",
52+ * content: "Explain how you're an amazing GPT."
53+ * }
54+ * ]
5555 * }
5656 * ```
5757 */
58- modelConfig (
58+ modelConfig < T > (
5959 key : string ,
6060 context : LDContext ,
61- defaultValue : string ,
61+ defaultValue : T ,
6262 variables ?: Record < string , unknown > ,
63- ) : Promise < LDAIConfig > ;
63+ ) : Promise < LDAIConfig | T > ;
6464}
6565
6666export class AIClientImpl implements AIClient {
@@ -74,12 +74,12 @@ export class AIClientImpl implements AIClient {
7474 return Mustache . render ( template , variables , undefined , { escape : ( item : any ) => item } ) ;
7575 }
7676
77- async modelConfig (
77+ async modelConfig < T > (
7878 key : string ,
7979 context : LDContext ,
80- defaultValue : string ,
80+ defaultValue : T ,
8181 variables ?: Record < string , unknown > ,
82- ) : Promise < LDAIConfig > {
82+ ) : Promise < LDAIConfig | T > {
8383 const detail = await this . _ldClient . variation ( key , context , defaultValue ) ;
8484
8585 const allVariables = { ldctx : context , ...variables } ;
0 commit comments