1
- import prompts from "prompts " ;
1
+ import inquirer from "inquirer " ;
2
2
import { ModelConfigParams , ModelConfigQuestionsParams } from "." ;
3
- import { questionHandlers } from "../../questions/utils" ;
4
3
5
4
const ALL_AZURE_OPENAI_CHAT_MODELS : Record < string , { openAIModel : string } > = {
6
5
"gpt-35-turbo" : { openAIModel : "gpt-3.5-turbo" } ,
@@ -66,29 +65,49 @@ export async function askAzureQuestions({
66
65
} ,
67
66
} ;
68
67
68
+ if ( ! config . apiKey ) {
69
+ const { key } = await inquirer . prompt ( [
70
+ {
71
+ type : "input" ,
72
+ name : "key" ,
73
+ message :
74
+ "Please provide your Azure OpenAI API key (or leave blank to use AZURE_OPENAI_API_KEY env variable):" ,
75
+ } ,
76
+ ] ) ;
77
+ config . apiKey = key || process . env . AZURE_OPENAI_API_KEY ;
78
+ }
79
+
80
+ if ( ! config . endpoint ) {
81
+ const { endpoint } = await inquirer . prompt ( [
82
+ {
83
+ type : "input" ,
84
+ name : "endpoint" ,
85
+ message :
86
+ "Please provide your Azure OpenAI endpoint (or leave blank to use AZURE_OPENAI_ENDPOINT env variable):" ,
87
+ } ,
88
+ ] ) ;
89
+ config . endpoint = endpoint || process . env . AZURE_OPENAI_ENDPOINT ;
90
+ }
91
+
69
92
if ( askModels ) {
70
- const { model } = await prompts (
93
+ const { model } = await inquirer . prompt ( [
71
94
{
72
- type : "select " ,
95
+ type : "list " ,
73
96
name : "model" ,
74
97
message : "Which LLM model would you like to use?" ,
75
- choices : getAvailableModelChoices ( ) ,
76
- initial : 0 ,
98
+ choices : getAvailableModelChoices ( ) . map ( toChoice ) ,
77
99
} ,
78
- questionHandlers ,
79
- ) ;
100
+ ] ) ;
80
101
config . model = model ;
81
102
82
- const { embeddingModel } = await prompts (
103
+ const { embeddingModel } = await inquirer . prompt ( [
83
104
{
84
- type : "select " ,
105
+ type : "list " ,
85
106
name : "embeddingModel" ,
86
107
message : "Which embedding model would you like to use?" ,
87
- choices : getAvailableEmbeddingModelChoices ( ) ,
88
- initial : 0 ,
108
+ choices : getAvailableEmbeddingModelChoices ( ) . map ( toChoice ) ,
89
109
} ,
90
- questionHandlers ,
91
- ) ;
110
+ ] ) ;
92
111
config . embeddingModel = embeddingModel ;
93
112
config . dimensions = getDimensions ( embeddingModel ) ;
94
113
}
@@ -113,3 +132,7 @@ function getAvailableEmbeddingModelChoices() {
113
132
function getDimensions ( modelName : string ) {
114
133
return ALL_AZURE_OPENAI_EMBEDDING_MODELS [ modelName ] . dimensions ;
115
134
}
135
+
136
+ function toChoice ( item : { title : string ; value : string } ) {
137
+ return { name : item . title , value : item . value } ;
138
+ }
0 commit comments