@@ -21,6 +21,7 @@ public struct ChatModel: Codable, Equatable, Identifiable {
2121 case azureOpenAI
2222 case openAICompatible
2323 case googleAI
24+ case ollama
2425 }
2526
2627 public struct Info : Codable , Equatable {
@@ -42,6 +43,8 @@ public struct ChatModel: Codable, Equatable, Identifiable {
4243 get { modelName }
4344 set { modelName = newValue }
4445 }
46+ @FallbackDecoding < EmptyString >
47+ public var ollamaKeepAlive : String
4548
4649 public init (
4750 apiKeyName: String = " " ,
@@ -50,7 +53,8 @@ public struct ChatModel: Codable, Equatable, Identifiable {
5053 maxTokens: Int = 4000 ,
5154 supportsFunctionCalling: Bool = true ,
5255 supportsOpenAIAPI2023_11: Bool = false ,
53- modelName: String = " "
56+ modelName: String = " " ,
57+ ollamaKeepAlive: String = " "
5458 ) {
5559 self . apiKeyName = apiKeyName
5660 self . baseURL = baseURL
@@ -59,6 +63,7 @@ public struct ChatModel: Codable, Equatable, Identifiable {
5963 self . supportsFunctionCalling = supportsFunctionCalling
6064 self . supportsOpenAIAPI2023_11 = supportsOpenAIAPI2023_11
6165 self . modelName = modelName
66+ self . ollamaKeepAlive = ollamaKeepAlive
6267 }
6368 }
6469
@@ -83,6 +88,10 @@ public struct ChatModel: Codable, Equatable, Identifiable {
8388 let baseURL = info. baseURL
8489 if baseURL. isEmpty { return " https://generativelanguage.googleapis.com/v1 " }
8590 return " \( baseURL) /v1/chat/completions "
91+ case . ollama:
92+ let baseURL = info. baseURL
93+ if baseURL. isEmpty { return " http://localhost:11434/api/chat " }
94+ return " \( baseURL) /api/chat "
8695 }
8796 }
8897}
0 commit comments