Conversation
There was a problem hiding this comment.
Pull Request Overview
This pull request introduces asynchronous inference examples for both prediction and generation using the Clarifai client and updates the documentation accordingly.
- Adds two new Python scripts demonstrating async prediction and generation.
- Updates README.md with example code blocks to guide users on async endpoint usage.
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| models/model_predict/clarifai_llm_async_predict.py | Adds an async prediction example with a potential extra await call. |
| models/model_predict/clarifai_llm_async_generate.py | Provides an async generation example with possibly redundant await. |
| models/model_predict/README.md | Updates the docs to include async inference examples and usage tips. |
Comments suppressed due to low confidence (1)
models/model_predict/README.md:207
- [nitpick] The async_generate code snippet iterates over the response using a standard for-loop, which may be incorrect if the response is an async generator. Consider replacing the synchronous loop with an 'async for' loop to correctly handle asynchronous iteration.
for res in response:
Comment on lines
+15
to
+17
| if not os.getenv("CLARIFAI_PAT"): | ||
| print("Please set your CLARIFAI_PAT environment variable") | ||
| exit(1) |
Contributor
There was a problem hiding this comment.
Now this is unnecessary as we get the creds from context also and the error message is good to direct them in right way
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces asynchronous inference capabilities to the
models/model_predictdirectory, adding examples and documentation for async prediction and generation using the Clarifai client. It also includes new Python scripts to demonstrate these functionalities.Documentation Updates:
models/model_predict/README.md: Added visual content and examples for asynchronous prediction and generation, including code snippets for usingasync_predictandasync_generatemethods. [1] [2] [3]Code Additions:
models/model_predict/clarifai_llm_async_generate.py: Introduced a script demonstrating asynchronous generation using the Clarifai client, with support for iterating over async responses.models/model_predict/clarifai_llm_async_predict.py: Added a script showcasing asynchronous prediction, initializing the model and handling results withasync_predict.