-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
LLM standardisation #320
LLM standardisation #320
Conversation
Note, this is failing linting due to a non-inherited context. I wanted to get a quick review on this. Is what I'm doing sane? |
seems sane so far,
|
Agreed. This has been designed so that we can replace all of the stuff in gateway with this too so that it's a unified implementation. All we need to do is refactor the tools to this (simpler IMO) format and we're good to go
I think that's outside the scope of this library, but you can see how I've done it in
We can change the granularity as required for each use-case |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the overall approach and left some more detailed technical comments below.
If this works out as a model we could consider splitting it out into its own dedicated OSS project and make some promotional activities around it to see if there's interest from others.
// Capture data from the LLM | ||
rates := run.GetRateLimitHeaders() | ||
span.SetAttributes( | ||
attribute.String("ovm.openai.model", run.Model), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
todo: review if there is overlap to metrics from anthropic we'd like to share attribute names (ovm.llm.*
?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only overlap is:
span.SetAttributes(
attribute.Int64("ovm.anthropic.usage.inputTokens", response.Usage.InputTokens),
attribute.Int64("ovm.anthropic.usage.outputTokens", response.Usage.OutputTokens),
attribute.String("ovm.anthropic.model", response.Model),
)
I decided to use anthropic
in the name so that we didn't get overlap as I thought it could be confusing, but I used the same names otherwise i.e. InputTokens etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👨🍳 💋
This is a pretty substantial piece of work that aims to standardise the methods we use to call out to LLMs everywhere in the product.
Why?
How?
This has been achieved by creating a new interface for an assistant conversation, and for tools, that allows the actual LLM provider to be pluggable without changing anything else. The three interfaces that matter here are:
Provider
: This represents the actual LLM, I have created providers for OpenAI and AnthropicConversation
: This represents a back and forth conversation with one of the providers. This interface stores state which means that it not only simplifies the way we need to interact with it, but abstracts over some of the differences between OpenAI and Anthropic. Like for example the fact that Anthropic doesn't really do server-side storage of conversations, however there is prompt caching which seems kind of similar...?ToolImplementation
: This is the one I'm the most proud of. It allows anyone to use theTool
struct with nothing but a name, description and a function. The JSON schema is automatically determined from the data type, which uses generics. Very nice.