@@ -14,13 +14,13 @@ import {
1414 type ModelConnectionOptions ,
1515 YAMLStringify ,
1616 deleteUndefinedValues ,
17- host ,
1817 resolveLanguageModelConfigurations ,
1918 resolveModelAlias ,
2019 resolveModelConnectionInfo ,
2120 resolveRuntimeHost ,
2221} from "@genaiscript/core" ;
2322import { buildProject } from "@genaiscript/core" ;
23+ import { resolve } from "node:path" ;
2424
2525/**
2626 * Outputs basic system information including node version, platform, architecture, and process ID.
@@ -63,7 +63,7 @@ async function resolveScriptsConnectionInfo(
6363 scripts : ModelConnectionOptions [ ] ,
6464 options ?: { token ?: boolean } ,
6565) : Promise < ModelConnectionInfo [ ] > {
66- const runtimeHost = resolveRuntimeHost ( )
66+ const runtimeHost = resolveRuntimeHost ( ) ;
6767 const models : Record < string , ModelConnectionOptions > = { } ;
6868
6969 // Deduplicate model connection options
@@ -81,7 +81,7 @@ async function resolveScriptsConnectionInfo(
8181 resolveModelConnectionInfo ( conn , {
8282 ...( options || { } ) ,
8383 defaultModel : LARGE_MODEL_ID ,
84- } ) . then ( ( res ) => res . info ) ,
84+ } ) . then ( ( r ) => r . info ) ,
8585 ) ,
8686 ) ;
8787 return res ;
@@ -93,11 +93,13 @@ async function resolveScriptsConnectionInfo(
9393 * @param script - The specific script ID or filename to filter by. If not provided, all scripts are included.
9494 * @param options - Configuration options, including whether to show tokens.
9595 */
96- export async function scriptModelInfo ( script : string , options ?: { token ?: boolean } ) {
96+ export async function scriptModelInfo (
97+ script : string ,
98+ options ?: { token ?: boolean } ,
99+ ) : Promise < void > {
97100 const prj = await buildProject ( ) ;
98101 const templates = prj . scripts . filter (
99- ( t ) =>
100- ! script || t . id === script || host . path . resolve ( t . filename ) === host . path . resolve ( script ) ,
102+ ( t ) => ! script || t . id === script || resolve ( t . filename ) === resolve ( script ) ,
101103 ) ;
102104 const info = await resolveScriptsConnectionInfo ( templates , options ) ;
103105 console . log ( YAMLStringify ( info ) ) ;
@@ -113,8 +115,8 @@ export async function scriptModelInfo(script: string, options?: { token?: boolea
113115 *
114116 * @param none This function does not require any parameters.
115117 */
116- export async function modelAliasesInfo ( ) {
117- const runtimeHost = resolveRuntimeHost ( )
118+ export async function modelAliasesInfo ( ) : Promise < void > {
119+ const runtimeHost = resolveRuntimeHost ( ) ;
118120 const res = Object . fromEntries (
119121 Object . entries ( runtimeHost . modelAliases ) . map ( ( [ k , v ] ) => [
120122 k ,
@@ -135,8 +137,8 @@ export async function modelAliasesInfo() {
135137export async function modelList (
136138 provider : string ,
137139 options ?: { error ?: boolean ; format ?: "json" | "yaml" } ,
138- ) {
139- const runtimeHost = resolveRuntimeHost ( )
140+ ) : Promise < void > {
141+ const runtimeHost = resolveRuntimeHost ( ) ;
140142 await runtimeHost . readConfig ( ) ;
141143 const providers = await resolveLanguageModelConfigurations ( provider , {
142144 ...( options || { } ) ,
@@ -147,12 +149,13 @@ export async function modelList(
147149 } ) ;
148150
149151 if ( options ?. format === "json" ) console . log ( JSON . stringify ( providers , null , 2 ) ) ;
150- else
152+ else {
151153 console . log (
152154 YAMLStringify (
153155 deleteUndefinedValues (
154156 Object . fromEntries ( providers . map ( ( p ) => [ p . provider , p . error || p . models ] ) ) ,
155157 ) ,
156158 ) ,
157159 ) ;
160+ }
158161}
0 commit comments