-
Notifications
You must be signed in to change notification settings - Fork 24
Fix: add model for image generation #652
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
Conversation
for usage, filters := range usageMap { | ||
for i, model := range models.Data { | ||
if model.Metadata == nil { | ||
model.Metadata = make(map[string]string) | ||
} | ||
|
||
if len(filters) == 0 { | ||
model.Metadata["usage"] = usage | ||
} else { | ||
for _, filter := range filters { | ||
if filter(model.ID) { | ||
model.Metadata["usage"] = usage | ||
break | ||
} | ||
} | ||
} | ||
models.Data[i] = 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.
The design of this could technically allow for one model to have the usage set to one thing, and then have it get overwritten by a later iteration if it matches the filters for a different usage. Do we want to do that? Or should we add something like this to the loop to skip models that already have a usage?
if model.Metadata["usage"] != "" {
continue
}
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.
yeah, not sure, I wrote this method to fix the xai model where it doesn't have its own usage. I guess we can extend to other cases. But I will add the thing you suggested for now.
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.
For xai, it doesn't have usage. So we are just grouping usage based on its own name.
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.
Yeah I was just thinking for the case of reusability, since this is in the package that the other model providers depend on
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.
Added the skip logic you suggested so that if it has usage then it will skip.
02d74dc
to
d1bd9d1
Compare
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.
It looks like this logic could be achieved with the existing RewriteAllModelsWithUsage
function. But your implementation seems simpler, so I am good with it.
if model.Metadata == nil { | ||
model.Metadata = make(map[string]string) | ||
} | ||
|
||
if model.Metadata["usage"] != "" { | ||
continue | ||
} |
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.
tiny optimization
if model.Metadata == nil { | |
model.Metadata = make(map[string]string) | |
} | |
if model.Metadata["usage"] != "" { | |
continue | |
} | |
if model.Metadata == nil { | |
model.Metadata = make(map[string]string) | |
} else if model.Metadata["usage"] != "" { | |
continue | |
} |
Signed-off-by: Daishan Peng <[email protected]>
d1bd9d1
to
d59479c
Compare
obot-platform/obot#2678
Fix xai model provider that doesn't have image-generation usage.