Phase 2 seam: expose pure helpers for testing (no logic changes)
Every change here is either dropping `private` (still invisible outside the module, @testable import just needs internal-or-wider) or converting a self-independent instance method to `static func` (ChatViewModel.inferProvider/calculateCost/detectGoodbyePhrase -- none of the three ever touched `self`, and constructing a real ChatViewModel triggers a real network call in init, so static-ifying them sidesteps that entirely rather than fighting it). Call sites updated to `Self.foo(...)` where the static conversion required it. Touches: GitSyncService's URL/secret-scanning helpers, EmbeddingService's embedding (de)serialization, ContextSelectionService's importance scoring, and the request-building/response-parsing helpers on all four providers (OpenRouter, Ollama, OpenAI, Anthropic) -- the core AI request/response layer, previously 100% untested. Verified: full existing test suite (27 tests) still green, no regressions. Tests for these functions land in the next commit. Phase 2 of the test-suite rollout plan (peaceful-baking-kurzweil).
This commit is contained in:
@@ -275,7 +275,7 @@ class OllamaProvider: AIProvider {
|
||||
|
||||
// MARK: - Helpers
|
||||
|
||||
private func buildRequestBody(from request: ChatRequest, stream: Bool) -> [String: Any] {
|
||||
func buildRequestBody(from request: ChatRequest, stream: Bool) -> [String: Any] {
|
||||
var messages: [[String: Any]] = []
|
||||
|
||||
// Add system prompt as a system message
|
||||
@@ -301,7 +301,7 @@ class OllamaProvider: AIProvider {
|
||||
return body
|
||||
}
|
||||
|
||||
private func parseOllamaResponse(_ json: [String: Any], model: String) -> ChatResponse {
|
||||
func parseOllamaResponse(_ json: [String: Any], model: String) -> ChatResponse {
|
||||
let message = json["message"] as? [String: Any]
|
||||
let content = message?["content"] as? String ?? ""
|
||||
let promptTokens = json["prompt_eval_count"] as? Int ?? 0
|
||||
|
||||
Reference in New Issue
Block a user