11import AIModel
2- import Toast
32import ComposableArchitecture
43import Dependencies
54import Keychain
65import OpenAIService
76import Preferences
87import SwiftUI
8+ import Toast
99
1010struct ChatModelEdit : ReducerProtocol {
1111 struct State : Equatable , Identifiable {
@@ -16,6 +16,7 @@ struct ChatModelEdit: ReducerProtocol {
1616 @BindingState var supportsFunctionCalling : Bool = true
1717 @BindingState var modelName : String = " "
1818 @BindingState var ollamaKeepAlive : String = " "
19+ @BindingState var apiVersion : String = " "
1920 var apiKeyName : String { apiKeySelection. apiKeyName }
2021 var baseURL : String { baseURLSelection. baseURL }
2122 var isFullURL : Bool { baseURLSelection. isFullURL }
@@ -47,6 +48,7 @@ struct ChatModelEdit: ReducerProtocol {
4748 toast ( $0, $1, " ChatModelEdit " )
4849 }
4950 }
51+
5052 @Dependency ( \. apiKeyKeychain) var keychain
5153
5254 var body : some ReducerProtocol < State , Action > {
@@ -77,19 +79,7 @@ struct ChatModelEdit: ReducerProtocol {
7779 case . testButtonClicked:
7880 guard !state. isTesting else { return . none }
7981 state. isTesting = true
80- let model = ChatModel (
81- id: state. id,
82- name: state. name,
83- format: state. format,
84- info: . init(
85- apiKeyName: state. apiKeyName,
86- baseURL: state. baseURL,
87- isFullURL: state. isFullURL,
88- maxTokens: state. maxTokens,
89- supportsFunctionCalling: state. supportsFunctionCalling,
90- modelName: state. modelName
91- )
92- )
82+ let model = ChatModel ( state: state)
9383 return . run { send in
9484 do {
9585 let service = ChatGPTService (
@@ -194,6 +184,7 @@ extension ChatModelEdit.State {
194184 supportsFunctionCalling: model. info. supportsFunctionCalling,
195185 modelName: model. info. modelName,
196186 ollamaKeepAlive: model. info. ollamaInfo. keepAlive,
187+ apiVersion: model. info. googleGenerativeAIInfo. apiVersion,
197188 apiKeySelection: . init(
198189 apiKeyName: model. info. apiKeyName,
199190 apiKeyManagement: . init( availableAPIKeyNames: [ model. info. apiKeyName] )
@@ -223,7 +214,8 @@ extension ChatModel {
223214 }
224215 } ( ) ,
225216 modelName: state. modelName. trimmingCharacters ( in: . whitespacesAndNewlines) ,
226- ollamaInfo: . init( keepAlive: state. ollamaKeepAlive)
217+ ollamaInfo: . init( keepAlive: state. ollamaKeepAlive) ,
218+ googleGenerativeAIInfo: . init( apiVersion: state. apiVersion)
227219 )
228220 )
229221 }
0 commit comments