@@ -63,6 +63,7 @@ struct EmbeddingModelEditView: View {
6363 . onAppear {
6464 store. send ( . appear)
6565 }
66+ . fixedSize ( horizontal: false , vertical: true )
6667 }
6768
6869 var nameTextField : some View {
@@ -96,16 +97,29 @@ struct EmbeddingModelEditView: View {
9697 }
9798 }
9899
99- func baseURLTextField( prompt: Text ? ) -> some View {
100+ func baseURLTextField< V: View > (
101+ title: String = " Base URL " ,
102+ prompt: Text ? ,
103+ @ViewBuilder trailingContent: @escaping ( ) -> V
104+ ) -> some View {
100105 BaseURLPicker (
106+ title: title,
101107 prompt: prompt,
102108 store: store. scope (
103109 state: \. baseURLSelection,
104110 action: EmbeddingModelEdit . Action. baseURLSelection
105- )
111+ ) ,
112+ trailingContent: trailingContent
106113 )
107114 }
108115
116+ func baseURLTextField(
117+ title: String = " Base URL " ,
118+ prompt: Text ?
119+ ) -> some View {
120+ baseURLTextField ( title: title, prompt: prompt, trailingContent: { EmptyView ( ) } )
121+ }
122+
109123 struct MaxTokensTextField : Equatable {
110124 @BindingViewState var maxTokens : Int
111125 var suggestedMaxTokens : Int ?
@@ -178,7 +192,9 @@ struct EmbeddingModelEditView: View {
178192
179193 @ViewBuilder
180194 var openAI : some View {
181- baseURLTextField ( prompt: Text ( " https://api.openai.com " ) )
195+ baseURLTextField ( prompt: Text ( " https://api.openai.com " ) ) {
196+ Text ( " /v1/embeddings " )
197+ }
182198 apiKeyNamePicker
183199
184200 WithViewStore (
@@ -204,6 +220,17 @@ struct EmbeddingModelEditView: View {
204220 }
205221
206222 maxTokensTextField
223+
224+ VStack ( alignment: . leading, spacing: 8 ) {
225+ Text ( Image ( systemName: " exclamationmark.triangle.fill " ) ) + Text(
226+ " To get an API key, please visit [https://platform.openai.com/api-keys](https://platform.openai.com/api-keys) "
227+ )
228+
229+ Text ( Image ( systemName: " exclamationmark.triangle.fill " ) ) + Text(
230+ " If you don't have access to GPT-4, you may need to visit [https://platform.openai.com/account/billing/overview](https://platform.openai.com/account/billing/overview) to buy some credits. A ChatGPT Plus subscription is not enough to access GPT-4 through API. "
231+ )
232+ }
233+ . padding ( . vertical)
207234 }
208235
209236 @ViewBuilder
@@ -223,7 +250,34 @@ struct EmbeddingModelEditView: View {
223250
224251 @ViewBuilder
225252 var openAICompatible : some View {
226- baseURLTextField ( prompt: Text ( " https:// " ) )
253+ WithViewStore ( store. scope (
254+ state: \. baseURLSelection,
255+ action: EmbeddingModelEdit . Action. baseURLSelection
256+ ) , removeDuplicates: { $0. isFullURL != $1. isFullURL } ) { viewStore in
257+ Picker (
258+ selection: viewStore. $isFullURL,
259+ content: {
260+ Text ( " Base URL " ) . tag ( false )
261+ Text ( " Full URL " ) . tag ( true )
262+ } ,
263+ label: { Text ( " URL " ) }
264+ )
265+ . pickerStyle ( . segmented)
266+ }
267+
268+ WithViewStore ( store, observe: \. isFullURL) { viewStore in
269+ baseURLTextField (
270+ title: " " ,
271+ prompt: viewStore. state
272+ ? Text ( " https://api.openai.com/v1/embeddings " )
273+ : Text ( " https://api.openai.com " )
274+ ) {
275+ if !viewStore. state {
276+ Text ( " /v1/embeddings " )
277+ }
278+ }
279+ }
280+
227281 apiKeyNamePicker
228282
229283 WithViewStore (
0 commit comments