-
Notifications
You must be signed in to change notification settings - Fork 65
Enhance Image Search Example - Live Update #459
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: main
Are you sure you want to change the base?
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.
For get_image_caption
, we can consider enable cache:
https://cocoindex.io/docs/core/custom_function#parameters-for-custom-functions
print("[LiveUpdater] Thread starting...") | ||
asyncio.run(updater_coroutine()) | ||
print("[LiveUpdater] Thread finished.") | ||
thread = threading.Thread(target=run_updater, daemon=True) |
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.
We don't need to create a separate thread. I think this is sufficient:
app.state.live_updater = cocoindex.FlowLiveUpdater(image_object_embedding_flow)
It will use a background thread (with Rust runtime) to watch changes automatically
(You can call app.state.live_updater.abort()
to stop it, but usually not necessary for a long-running process)
With this change, the
|
Enhances Image Search Example by adding Live Update