-
Notifications
You must be signed in to change notification settings - Fork 227
KG-437 Use structured ModelInfo instead of 'provider:model' string #893
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
base: develop
Are you sure you want to change the base?
KG-437 Use structured ModelInfo instead of 'provider:model' string #893
Conversation
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.
Thank you, @fazlerahmanejazi
I have Couple of notes, but in general looks good to me
* Backwards compatibility: provides the same string format as current eventString | ||
* Format: "provider:model" | ||
*/ | ||
public val eventString: String get() = "$provider:$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.
Since it's use-case specific, wouldn't it be better to move it to an extension function in the events module? Or let's not mention "events" use case here (rename)
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 will be deprecated, keeping it for backwards compatibility(improved docs and added deprecation warnings).
|
||
@Test | ||
fun `test fromString with invalid format`() { | ||
val modelInfo = ModelInfo.fromString("invalid-format") |
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.
Should we create such malformed ModelInfos, or isn't it better to throw a ParseException. We may define a static constant ModelInfo.UNDEFINED
for undefined usecases
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.
Good point! Added ModelInfo.UNDEFINED
The ModelInfo might be reused for #633 |
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.
Thank you for your contribution. I have several comments about naming and deprecation. It would be nice to fix them. Other than that LGTM!
* Backwards compatibility: provides the same string format as current eventString | ||
* Format: "provider:model" | ||
*/ | ||
public val eventString: String get() = "$provider:$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.
Let's deprecate this as well. I think we need to drop it in the next release in favour of a new format string: provider/model_id
below.
* Human-readable display name for the model | ||
* Falls back to "provider/model" if displayName is not provided | ||
*/ | ||
public val humanReadableName: String get() = displayName ?: "$provider/$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.
Maybe name it modelIdentifierName
or modelIdentifierString
?
* @deprecated Use model.eventString instead | ||
*/ | ||
@Deprecated("Use model.eventString instead", ReplaceWith("model.eventString")) | ||
public val modelString: String get() = model.eventString |
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.
Maybe also add a deprecated constructor to keep backward compatibility:
/**
* @deprecated Use constructor with model parameter of type [ModelInfo]:
* LLMCallStartingEvent(runId, prompt, model, tools, eventId, timestamp)
*/
@Deprecated(
message = "Please use constructor with model parameter of type [ModelInfo]: LLMCallStartingEvent(runId, prompt, model, tools, eventId, timestamp)",
replaceWith = ReplaceWith("LLMCallStartingEvent(runId, prompt, model, tools, eventId, timestamp)")
)
public constructor(
runId: String,
prompt: Prompt,
model: String,
tools: List<String>,
eventId: String = LLMCallStartingEvent::class.simpleName!!,
timestamp: Long = Clock.System.now().toEpochMilliseconds()
) : this(runId, prompt, ModelInfo.fromString(model), tools, eventId, timestamp)
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.
Good suggestion, done!
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.
Thank you for fixes. Approve!
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.
Thank you, @fazlerahmanejazi
*/ | ||
@Deprecated( | ||
message = "Please use constructor with model parameter of type [ModelInfo]: LLMCallStartingEvent(runId, prompt, model, tools, eventId, timestamp)", | ||
replaceWith = ReplaceWith("LLMCallStartingEvent(runId, prompt, model, tools, eventId, timestamp)") |
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.
eventId was removed from method signature. ReplaceWith and docs need an update
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.
031e1ee
to
f619567
Compare
88621f4
to
0511f31
Compare
b31feb5
to
6b845fc
Compare
Motivation and Context
KG-437
Breaking Changes
Type of the changes
Checklist
develop
as the base branchAdditional steps for pull requests adding a new feature