Skip to content

Commit

Permalink
"Update cache only if llmResult has non-nil llm_output."
Browse files Browse the repository at this point in the history
  • Loading branch information
buhe committed Jan 21, 2024
1 parent e91e4d1 commit 27a817b
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion Sources/LangChain/llms/LLM.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ public class LLM {
}
let llmResult = try await _send(text: text, stops: stops)
if let cache = self.cache {
await cache.update(prompt: text, return_val: llmResult)
if llmResult.llm_output != nil {
await cache.update(prompt: text, return_val: llmResult)
}
}
cost = Date.now.timeIntervalSince1970 - now
if !llmResult.stream {
Expand Down

0 comments on commit 27a817b

Please sign in to comment.