Skip to content

Commit

Permalink
Patch up ContextualLogger (#785)
Browse files Browse the repository at this point in the history
* Ollama logging uses the current Langchain.logger.level
* ContextualLogger outputs everything passed in
  • Loading branch information
andreibondarev authored Sep 18, 2024
1 parent bbb9510 commit 77a8229
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions lib/langchain/contextual_logger.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ def method_missing(method, *args, **kwargs, &block)
"[#{for_class_name}]:"
end
log_line_parts << colorize(args.first, MESSAGE_COLOR_OPTIONS[method])
log_line_parts << kwargs if !!kwargs && kwargs.any?
log_line_parts << block.call if block
log_line = log_line_parts.compact.join(" ")

@logger.send(
Expand Down
2 changes: 1 addition & 1 deletion lib/langchain/llm/ollama.rb
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ def client
conn.request :json
conn.response :json
conn.response :raise_error
conn.response :logger, nil, {headers: true, bodies: true, errors: true}
conn.response :logger, Langchain.logger, {headers: true, bodies: true, errors: true}
end
end

Expand Down

0 comments on commit 77a8229

Please sign in to comment.