File tree Expand file tree Collapse file tree 4 files changed +11
-25
lines changed
packages/tasks/src/snippets Expand file tree Collapse file tree 4 files changed +11
-25
lines changed Original file line number Diff line number Diff line change @@ -23,25 +23,17 @@ export function stringifyMessages(
2323
2424type PartialGenerationParameters = Partial < Pick < GenerationParameters , "temperature" | "max_tokens" | "top_p" > > ;
2525
26- export interface StringifyGenerationConfigOptions {
27- sep : string ;
28- start : string ;
29- end : string ;
30- attributeValueConnector : string ;
31- attributeKeyQuotes ?: boolean ;
32- }
33-
3426export function stringifyGenerationConfig (
3527 config : PartialGenerationParameters ,
36- opts : StringifyGenerationConfigOptions
28+ opts : {
29+ indent : string ;
30+ attributeValueConnector : string ;
31+ attributeKeyQuotes ?: boolean ;
32+ }
3733) : string {
3834 const quote = opts . attributeKeyQuotes ? `"` : "" ;
3935
40- return (
41- opts . start +
42- Object . entries ( config )
43- . map ( ( [ key , val ] ) => `${ quote } ${ key } ${ quote } ${ opts . attributeValueConnector } ${ val } ` )
44- . join ( opts . sep ) +
45- opts . end
46- ) ;
36+ return Object . entries ( config )
37+ . map ( ( [ key , val ] ) => `${ quote } ${ key } ${ quote } ${ opts . attributeValueConnector } ${ val } ` )
38+ . join ( `,${ opts . indent } ` ) ;
4739}
Original file line number Diff line number Diff line change @@ -46,9 +46,7 @@ export const snippetTextGeneration = (
4646 customContentEscaper : ( str ) => str . replace ( / ' / g, "'\\''" ) ,
4747 } ) } ,
4848 ${ stringifyGenerationConfig ( config , {
49- sep : ",\n " ,
50- start : "" ,
51- end : "" ,
49+ indent : "\n " ,
5250 attributeKeyQuotes : true ,
5351 attributeValueConnector : ": " ,
5452 } ) } ,
Original file line number Diff line number Diff line change @@ -50,9 +50,7 @@ export const snippetTextGeneration = (
5050 ...( opts ?. top_p ? { top_p : opts . top_p } : undefined ) ,
5151 } ;
5252 const configStr = stringifyGenerationConfig ( config , {
53- sep : ",\n\t" ,
54- start : "" ,
55- end : "" ,
53+ indent : "\n\t" ,
5654 attributeValueConnector : ": " ,
5755 } ) ;
5856
Original file line number Diff line number Diff line change @@ -26,9 +26,7 @@ export const snippetConversational = (
2626 ...( opts ?. top_p ? { top_p : opts . top_p } : undefined ) ,
2727 } ;
2828 const configStr = stringifyGenerationConfig ( config , {
29- sep : ",\n\t" ,
30- start : "" ,
31- end : "" ,
29+ indent : "\n\t" ,
3230 attributeValueConnector : "=" ,
3331 } ) ;
3432
You can’t perform that action at this time.
0 commit comments