Skip to content

added async endpoint examples#151

Merged
mogith-pn merged 2 commits intomainfrom
async-examples
Jul 31, 2025
Merged

added async endpoint examples#151
mogith-pn merged 2 commits intomainfrom
async-examples

Conversation

@mogith-pn
Copy link
Copy Markdown
Contributor

This pull request introduces asynchronous inference capabilities to the models/model_predict directory, 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 using async_predict and async_generate methods. [1] [2] [3]

Code Additions:

@mogith-pn mogith-pn requested review from Copilot and luv-bansal June 17, 2025 16:33
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now this is unnecessary as we get the creds from context also and the error message is good to direct them in right way

Copy link
Copy Markdown
Contributor

@srikanthbachala20 srikanthbachala20 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mogith-pn mogith-pn merged commit acc64ec into main Jul 31, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants