Many of the AI provider ChatModels prematurely construct an Observation.Context when ChatModel Observations may not even be enabled (as defined by Micrometer in ObservationDocumentation and Observation).

  • Simplify and polish code in OpenAI using the API with Spring constructs and Builders.
  • Simplify common code expressions used in AI provider ChatModels with ValueUtils.
  • Apply whitespace to improve readability.

Comment From: markpollack

I'm a bit nervous to get this in before Nov 11, but nevertheless do want to know about best practices here - there are many it seems that are a bit opaque to me. How expensive is it to create an ObservationContext? @ThomasVitale @jonatan-ivanov ?

Comment From: jxblum

@markpollack

I'm a bit nervous to get this in before Nov 11, but nevertheless do want to know about best practices here - there are many it seems that are a bit opaque to me. How expensive is it to create an ObservationContext? @ThomasVitale @jonatan-ivanov ?

Always your call, of course, but I'd hope that most concerns were covered by tests, which I always run in entirety after each change I make (PR I submit), in addition to adding additional test coverage where needed. :)