-
-
Notifications
You must be signed in to change notification settings - Fork 61
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
fix: refactor Supabase AI API #273
Conversation
d8f44ea
to
9b856a9
Compare
esm_entry_point = "ext:sb_ai/ai.js", | ||
esm = ["ai.js",] | ||
); | ||
|
||
fn run_gte(state: &mut OpState, prompt: String) -> Result<Vec<f32>, Error> { | ||
fn init_gte(state: &mut OpState) -> Result<(), Error> { |
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 would be interesting if we can make this op async
and have the whole logic of initialization (if it's heavy) on a different thread. (I'm thinking especially because models can be large)
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.
@andreespirela Thanks for the suggestion! Refactored the init to run on a tokio task (ie. green thread)
examples/gte-small-ort/index.ts
Outdated
Deno.serve(async (req: Request) => { | ||
const params = new URL(req.url).searchParams; | ||
const input = params.get('text'); | ||
const output = Supabase_UNSTABLE.ai.runModel('gte', input); | ||
const output = model.run(input); |
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.
Also wonder if the run
op should be async...
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.
Updated
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.
Lgtm!
🎉 This PR is included in version 1.36.5 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
What kind of change does this PR introduce?
Modified to initialize session once and reuse internal session/tokenizer.