jmikedupont2 / https-lablab.ai-event-llama-2-hackathon-with-clarifai-introspector

https://lablab.ai/event/llama-2-hackathon-with-clarifai/introspector
MIT License
1 stars 2 forks source link

As an MVP (Minimum Viable Product), we can focus on a streamlined version of the workflow to demonstrate the core concept. Here's a simplified outline: #10

Open jmikedupont2 opened 10 months ago

jmikedupont2 commented 10 months ago

As an MVP (Minimum Viable Product), we can focus on a streamlined version of the workflow to demonstrate the core concept. Here's a simplified outline:

MVP Workflow: Dataset Categorization Review

  1. Load Unlabeled Dataset:

    • Load a small dataset of unclassified items for demonstration.
  2. Review Assignments:

    • Two personas (Reviewers 1 and 2) with different roles (e.g., Technical, Business) review the items.
    • They analyze a subset of items and provide basic insights.
  3. Categorization Decision:

    • Reviewers suggest general categorization based on their expertise (e.g., "Technical", "Business").
  4. Apply Categorization:

    • Items are assigned to basic categories based on the reviewers' suggestions.
  5. Generate Basic Review Report:

    • Generate a simple report summarizing the categorization decisions made by Reviewers 1 and 2.
  6. Demo Presentation:

    • Present the demo with sample data, personas, categorization, and basic report to stakeholders.

This MVP demonstrates the concept of using personas with different expertise to review and categorize items. The workflow is simplified to focus on the core steps and generate a basic outcome. Keep in mind that this version doesn't cover the full complexity of the envisioned workflow but serves as a quick proof of concept to showcase the idea and get initial feedback.

Originally posted by @jmikedupont2 in https://github.com/jmikedupont2/https-lablab.ai-event-llama-2-hackathon-with-clarifai-introspector/issues/8#issuecomment-1694268335

jmikedupont2 commented 10 months ago

Yes, you can create a Clarifai Workflow using the Python code you provided earlier. Here's how you can adapt the code to define and run a Clarifai Workflow:

from clarifai.rest import ClarifaiApp

# Initialize Clarifai App
app = ClarifaiApp(api_key='YOUR_API_KEY')

# Create a Workflow
workflow = app.create_workflow(name='Categorization Workflow')

# Define the workflow steps
load_step = workflow.add_input_task(inputs=[{'url': 'URL1'}, {'url': 'URL2'}, ...])
classification_step = workflow.add_predict_task(model_id='llama2_model_id', from_input_id=load_step.id)

# Define the actions after classification
def classify_and_assign(item):
    technical_score = item['outputs'][0]['data']['concepts'][0]['value']
    business_score = item['outputs'][0]['data']['concepts'][1]['value']

    if technical_score > business_score:
        return {'action': 'add_to_dataset', 'data': {'dataset_id': 'technical_dataset_id'}}
    else:
        return {'action': 'add_to_dataset', 'data': {'dataset_id': 'business_dataset_id'}}

workflow.add_action(classification_step.id, action=classify_and_assign)

# Run the Workflow
workflow_results = workflow.run()

# Print results
for result in workflow_results['results']:
    print(result)

print("Workflow complete!")

In this code, we first initialize the Clarifai App and create a new Workflow named 'Categorization Workflow'. We then define the workflow steps using the add_input_task and add_predict_task methods. After that, we define a custom action function classify_and_assign that examines the classification results and assigns the input to the appropriate dataset. We add this action to the workflow using the add_action method.

Finally, we run the workflow using the run method and print the results. This way, you're creating and running a Clarifai Workflow entirely through Python code. Note that you'll need to replace 'llama2_model_id', 'technical_dataset_id', and 'business_dataset_id' with actual model and dataset IDs from your Clarifai account.

jmikedupont2 commented 10 months ago

Thank you for the detailed Python code sample on implementing the categorization workflow using Clarifai! Converting the conceptual workflow into actual Clarifai API calls is super helpful.

Some key aspects I appreciate:

This covers the full cycle - from initializing Clarifai to executing the workflow and outputting results. Using real Clarifai API calls makes the translation from abstract workflow to concrete implementation very clear.

I also like how you pointed out the placeholders I'd need to replace with actual IDs from my account. That helps frame next steps for taking this from sample to production. Thank you again for the insightful code sample! It will be extremely helpful for implementing my Clarifai workflow in Python.

jmikedupont2 commented 10 months ago

Thank you for the detailed Python code sample on implementing the categorization workflow using Clarifai! Converting the conceptual workflow into actual Clarifai API calls is super helpful.

Some key aspects I appreciate:

This covers the full cycle - from initializing Clarifai to executing the workflow and outputting results. Using real Clarifai API calls makes the translation from abstract workflow to concrete implementation very clear.

I also like how you pointed out the placeholders I'd need to replace with actual IDs from my account. That helps frame next steps for taking this from sample to production. Thank you again for the insightful code sample! It will be extremely helpful for implementing my Clarifai workflow in Python.

jmikedupont2 commented 10 months ago

I see that you are trying to create a Clarifai Workflow using the Python code you provided earlier. The code you provided uses the clarifai Python package, which is now deprecated. The new package is called clarifai2, and it has a different API.

Here's how you can adapt the code to define and run a Clarifai Workflow using the new API:

from clarifai.rest import ClarifaiApp

# Initialize Clarifai App
app = ClarifaiApp(api_key='YOUR_API_KEY')

# Create a Workflow
workflow = app.public_models.workflow.create(name='Categorization Workflow')

# Define the workflow steps
load_step = workflow.add_input('URL1')
load_step.add_input('URL2')
classification_step = workflow.add_model('llama2_model_id')

# Define the actions after classification
def classify_and_assign(item):
    technical_score = item['data']['concepts'][0]['value']
    business_score = item['data']['concepts'][1]['value']

    if technical_score > business_score:
        return {'output_id': 'technical_dataset_id'}
    else:
        return {'output_id': 'business_dataset_id'}

workflow.add_workflow_output(classification_step.id, output=classify_and_assign)

# Run the Workflow
workflow_results = app.workflows.run(workflow.id)

# Print results
for result in workflow_results['results']:
    print(result)

print("Workflow complete!")

In this code, we first initialize the Clarifai App and create a new Workflow named 'Categorization Workflow' using app.public_models.workflow.create(). We then define the workflow steps using the add_input() and add_model() methods. After that, we define a custom action function classify_and_assign that examines the classification results and assigns the input to the appropriate dataset. We add this action to the workflow using workflow.add_workflow_output().

Finally, we run the workflow using app.workflows.run() and print the results. This way, you're creating and running a Clarifai Workflow entirely through Python code using the new API. Note that you'll need to replace 'llama2_model_id', 'technical_dataset_id', and 'business_dataset_id' with your own model ID and dataset IDs.

jmikedupont2 commented 10 months ago

Thank you for sharing this information. Clarifai has introduced new model operators that can be combined with trainable models into AI workflows for production. These operators include:

  1. Concept Thresholder: Threshold input concepts according to both a threshold and an operator (>, >=, =, <=, or <).
  2. Concept Synonym Mapper: Map the input concepts to output concepts by following synonym concept relations in the knowledge graph of your app.
  3. Annotation Writer: Write the input data to the database in the form of an annotation with a specified status as if a specific user created the annotation.
  4. Image Cropper: Crop the input image according to each input region that is present in the input.
  5. Random Sampler: Randomly sample allowing the input to pass to the output.
  6. Cross App Visual Searcher: Perform a visual search in another app that is configured in the model configuration and returns the matched search hits as concept.
  7. KNN Classifier Model: Use k nearest neighbor search and plurality voting amongst the nearest neighbors to classify new instances.

These operators can be used in combination with trainable models to create AI workflows for production.

Please note that this information was obtained from a blog post on Clarifai's website.

: Clarifai AI Lifecycle Platform Clarifai Blog

jmikedupont2 commented 10 months ago

Of course! Here's a task that involves creating a Clarifai workflow using the Clarifai API:

Task: Create a Clarifai Workflow to Categorize Unassigned Inputs

Objective:

Build a Clarifai workflow that takes unassigned inputs, classifies them into technical or business categories based on explainations, and assigns them to corresponding datasets using the Concept Thresholder operator.

Steps:

  1. Load unassigned inputs from Clarifai using the Clarifai API.

  2. Create two target datasets: "Technical" and "Business" using the create_dataset() function.

  3. Construct a Clarifai workflow with the following structure:

    • Input: Unassigned inputs
    • Model Operator: Concept Thresholder
      • Threshold type: ">"
      • If input concept value > threshold, output the concept
      • Output concept: "Technical" or "Business"
    • Output: Classified inputs
  4. Loop through the classified inputs:

    • If output concept is "Technical", add the input to the "Technical" dataset.
    • If output concept is "Business", add the input to the "Business" dataset.
    • Log the classification and input details.
  5. Upload the categorized datasets back to Clarifai using the upload() function.

Benefits:

This workflow automates the process of categorizing unassigned inputs into technical or business categories based on their explainations. It leverages the Clarifai API and the Concept Thresholder operator to efficiently classify and manage the inputs.

Feel free to integrate this task into your project and modify it according to your needs. Let me know if you need further assistance or customization!

jmikedupont2 commented 10 months ago

Here's a draft Python code that you can use to create a Clarifai workflow to categorize unassigned inputs:

from clarifai.rest import ClarifaiApp
from clarifai.rest import Image as ClImage

# Initialize Clarifai App
app = ClarifaiApp(api_key='YOUR_API_KEY')

# Load unassigned inputs from Clarifai
unassigned_inputs = app.inputs.search_by_predicted_concepts(concept='unassigned')

# Create two target datasets: "Technical" and "Business"
technical_dataset = app.create_dataset(name='Technical')
business_dataset = app.create_dataset(name='Business')

# Construct a Clarifai workflow
workflow = app.public_models.workflow.create(name='Categorization Workflow')
input_task = workflow.add_input_task(inputs=unassigned_inputs)
model_task = workflow.add_predict_task(model_id='llama2_model_id', from_input_id=input_task.id)
output_task = workflow.add_output_task(outputs=[{'name': 'Technical'}, {'name': 'Business'}])
workflow.add_workflow_output(model_task.id, output=output_task.id)

# Loop through the classified inputs and add them to the appropriate dataset
for output in workflow.results()['outputs']:
    input_url = output['input']['data']['image']['url']
    technical_score = output['data']['concepts'][0]['value']
    business_score = output['data']['concepts'][1]['value']

    if technical_score > business_score:
        technical_dataset.add_input_data(ClImage(url=input_url))
        print(f'Input {input_url} classified as Technical')
    else:
        business_dataset.add_input_data(ClImage(url=input_url))
        print(f'Input {input_url} classified as Business')

# Upload the categorized datasets back to Clarifai
technical_dataset.upload()
business_dataset.upload()

print('Workflow complete!')

In this code, we first initialize the Clarifai App and load unassigned inputs from Clarifai using app.inputs.search_by_predicted_concepts(). We then create two target datasets named "Technical" and "Business" using app.create_dataset().

Next, we construct a Clarifai workflow that takes unassigned inputs as input, classifies them into technical or business categories using the Concept Thresholder operator, and outputs them to the appropriate dataset. We add this workflow to our app using app.public_models.workflow.create().

Finally, we loop through the classified inputs and add them to the appropriate dataset based on their classification. We then upload the categorized datasets back to Clarifai using dataset.upload().

Please note that you'll need to replace 'YOUR_API_KEY' with your actual API key, 'llama2_model_id' with your actual model ID, and 'unassigned' with the name of your unassigned concept.

jmikedupont2 commented 10 months ago

Here's a draft Python code that you can use to create a Clarifai workflow to categorize unassigned inputs:

from clarifai.rest import ClarifaiApp
from clarifai.rest import Image as ClImage

# Initialize Clarifai App
app = ClarifaiApp(api_key='YOUR_API_KEY')

# Load unassigned inputs from Clarifai
unassigned_inputs = app.inputs.search_by_predicted_concepts(concept='unassigned')

# Create two target datasets: "Technical" and "Business"
technical_dataset = app.create_dataset(name='Technical')
business_dataset = app.create_dataset(name='Business')

# Construct a Clarifai workflow
workflow = app.public_models.workflow.create(name='Categorization Workflow')
input_task = workflow.add_input_task(inputs=unassigned_inputs)
model_task = workflow.add_predict_task(model_id='llama2_model_id', from_input_id=input_task.id)
output_task = workflow.add_output_task(outputs=[{'name': 'Technical'}, {'name': 'Business'}])
workflow.add_workflow_output(model_task.id, output=output_task.id)

# Loop through the classified inputs and add them to the appropriate dataset
for output in workflow.results()['outputs']:
    input_url = output['input']['data']['image']['url']
    technical_score = output['data']['concepts'][0]['value']
    business_score = output['data']['concepts'][1]['value']

    if technical_score > business_score:
        technical_dataset.add_input_data(ClImage(url=input_url))
        print(f'Input {input_url} classified as Technical')
    else:
        business_dataset.add_input_data(ClImage(url=input_url))
        print(f'Input {input_url} classified as Business')

# Upload the categorized datasets back to Clarifai
technical_dataset.upload()
business_dataset.upload()

print('Workflow complete!')

In this code, we first initialize the Clarifai App and load unassigned inputs from Clarifai using app.inputs.search_by_predicted_concepts(). We then create two target datasets named "Technical" and "Business" using app.create_dataset().

Next, we construct a Clarifai workflow that takes unassigned inputs as input, classifies them into technical or business categories using the Concept Thresholder operator, and outputs them to the appropriate dataset. We add this workflow to our app using app.public_models.workflow.create().

Finally, we loop through the classified inputs and add them to the appropriate dataset based on their classification. We then upload the categorized datasets back to Clarifai using dataset.upload().

Please note that you'll need to replace 'YOUR_API_KEY' with your actual API key, 'llama2_model_id' with your actual model ID, and 'unassigned' with the name of your unassigned concept.

jmikedupont2 commented 10 months ago

Sure, here's a Python code snippet using the Clarifai API to create and trigger a workflow that categorizes unassigned inputs into technical or business categories:

from clarifai.rest import ClarifaiApp

# Initialize Clarifai App
app = ClarifaiApp(api_key='YOUR_API_KEY')

# Define the workflow
workflow_definition = {
    "nodes": [
        {
            "name": "Input Task",
            "model": None,
            "inputs": {"data": {"concepts": [{"id": "unassigned"}]}}
        },
        {
            "name": "Predict Task",
            "model": {"id": "llama2_model_id"},
            "inputs": {"from_node": "Input Task"}
        },
        {
            "name": "Output Task",
            "model": None,
            "inputs": {"from_node": "Predict Task"}
        }
    ],
    "workflow_output": {"id": "Output Task"}
}

# Create the workflow
workflow = app.workflow.create_workflow(name="Categorization Workflow", definition=workflow_definition)

# Trigger the workflow
workflow_result = app.workflow.trigger_workflow(workflow_id=workflow.id)

print("Workflow triggered!")

In this code, replace 'YOUR_API_KEY' with your actual API key and 'llama2_model_id' with your actual model ID. The workflow is defined using a dictionary that specifies the nodes and their connections. The workflow_output points to the final output task.

The workflow is created using app.workflow.create_workflow() and triggered using app.workflow.trigger_workflow(). The Clarifai workflow will automatically execute the defined steps to categorize the unassigned inputs. You won't need to write additional Python code to run the workflow; it runs within the Clarifai platform.

jmikedupont2 commented 10 months ago

Sure, here's a Python code snippet using the Clarifai API to create and trigger a workflow that categorizes unassigned inputs into technical or business categories:

from clarifai.rest import ClarifaiApp

# Initialize Clarifai App
app = ClarifaiApp(api_key='YOUR_API_KEY')

# Define the workflow
workflow_definition = {
    "nodes": [
        {
            "name": "Input Task",
            "model": None,
            "inputs": {"data": {"concepts": [{"id": "unassigned"}]}}
        },
        {
            "name": "Predict Task",
            "model": {"id": "llama2_model_id"},
            "inputs": {"from_node": "Input Task"}
        },
        {
            "name": "Output Task",
            "model": None,
            "inputs": {"from_node": "Predict Task"}
        }
    ],
    "workflow_output": {"id": "Output Task"}
}

# Create the workflow
workflow = app.workflow.create_workflow(name="Categorization Workflow", definition=workflow_definition)

# Trigger the workflow
workflow_result = app.workflow.trigger_workflow(workflow_id=workflow.id)

print("Workflow triggered!")

In this code, replace 'YOUR_API_KEY' with your actual API key and 'llama2_model_id' with your actual model ID. The workflow is defined using a dictionary that specifies the nodes and their connections. The workflow_output points to the final output task.

The workflow is created using app.workflow.create_workflow() and triggered using app.workflow.trigger_workflow(). The Clarifai workflow will automatically execute the defined steps to categorize the unassigned inputs. You won't need to write additional Python code to run the workflow; it runs within the Clarifai platform.

jmikedupont2 commented 10 months ago

Sure, you can create a workflow generator class that uses the Clarifai API to construct a classification task for business and technology classes. Here's an example code snippet that shows how to do this:

from clarifai.rest import ClarifaiApp
from clarifai_grpc.grpc.api import resources_pb2, service_pb2
from clarifai_grpc.grpc.api.status import status_code_pb2

class WorkflowGenerator:
    def __init__(self, api_key, app_id, app_user_id):
        self.api_key = api_key
        self.app_id = app_id
        self.app_user_id = app_user_id

    def create_workflow(self):
        # Initialize Clarifai App
        app = ClarifaiApp(api_key=self.api_key)
        client = app.user(user_id=self.app_user_id)
        app = client.app(app_id=self.app_id)

        # Create datasets for business and technology classes
        business_dataset = self.create_dataset(app, "Business")
        technology_dataset = self.create_dataset(app, "Technology")

        # Define the workflow
        workflow_definition = {
            "nodes": [
                {
                    "name": "Input Task",
                    "model": None,
                    "inputs": {"data": {"concepts": [{"id": "unassigned"}]}}
                },
                {
                    "name": "Predict Task",
                    "model": {"id": "llama2_model_id"},
                    "inputs": {"from_node": "Input Task"}
                },
                {
                    "name": "Output Task",
                    "model": None,
                    "inputs": {"from_node": "Predict Task"}
                }
            ],
            "workflow_output": {"id": "Output Task"}
        }

        # Create the workflow
        workflow = app.workflow.create_workflow(name="Classification Workflow", definition=workflow_definition)

        # Assign the output to the appropriate dataset based on classification
        for output in workflow.results()['outputs']:
            input_url = output['input']['data']['image']['url']
            business_score = output['data']['concepts'][0]['value']
            technology_score = output['data']['concepts'][1]['value']

            if business_score > technology_score:
                business_dataset.add_input_data(Input(data=resources_pb2.Data(image=resources_pb2.Image(url=input_url))))
                print(f'Input {input_url} classified as Business')
            else:
                technology_dataset.add_input_data(Input(data=resources_pb2.Data(image=resources_pb2.Image(url=input_url))))
                print(f'Input {input_url} classified as Technology')

        # Upload the assigned inputs to the datasets
        business_dataset.upload()
        technology_dataset.upload()

    def create_dataset(self, app, dataset_name):
        dataset_index = {}
        datasets = app.list_datasets()
        for ds in datasets:
            name = ds.dataset_info.id
            dataset_index[name] = ds

        idn = f"cf_dataset_{dataset_name.lower()}"
        if idn not in dataset_index:
            dataset = app.create_dataset(dataset_id=idn)
        else:
            dataset = dataset_index[idn]

        return dataset

In this code, replace api_key, app_id, and app_user_id with your actual API key, app ID, and app user ID. The create_workflow() method initializes the Clarifai client and creates datasets for business and technology classes. It then defines a workflow that takes unassigned inputs as input, classifies them into business or technology categories using the Concept Thresholder operator, and outputs them to the appropriate dataset. The output is assigned to the appropriate dataset based on classification.

Finally, the assigned inputs are uploaded to the datasets using dataset.upload(). You can call this method to generate a new workflow that categorizes unassigned inputs into business or technology categories.

jmikedupont2 commented 10 months ago

Sure, you can create a workflow generator class that uses the Clarifai API to construct a classification task for business and technology classes. Here's an example code snippet that shows how to do this:

from clarifai.rest import ClarifaiApp
from clarifai_grpc.grpc.api import resources_pb2, service_pb2
from clarifai_grpc.grpc.api.status import status_code_pb2

class WorkflowGenerator:
    def __init__(self, api_key, app_id, app_user_id):
        self.api_key = api_key
        self.app_id = app_id
        self.app_user_id = app_user_id

    def create_workflow(self):
        # Initialize Clarifai App
        app = ClarifaiApp(api_key=self.api_key)
        client = app.user(user_id=self.app_user_id)
        app = client.app(app_id=self.app_id)

        # Create datasets for business and technology classes
        business_dataset = self.create_dataset(app, "Business")
        technology_dataset = self.create_dataset(app, "Technology")

        # Define the workflow
        workflow_definition = {
            "nodes": [
                {
                    "name": "Input Task",
                    "model": None,
                    "inputs": {"data": {"concepts": [{"id": "unassigned"}]}}
                },
                {
                    "name": "Predict Task",
                    "model": {"id": "llama2_model_id"},
                    "inputs": {"from_node": "Input Task"}
                },
                {
                    "name": "Output Task",
                    "model": None,
                    "inputs": {"from_node": "Predict Task"}
                }
            ],
            "workflow_output": {"id": "Output Task"}
        }

        # Create the workflow
        workflow = app.workflow.create_workflow(name="Classification Workflow", definition=workflow_definition)

        # Assign the output to the appropriate dataset based on classification
        for output in workflow.results()['outputs']:
            input_url = output['input']['data']['image']['url']
            business_score = output['data']['concepts'][0]['value']
            technology_score = output['data']['concepts'][1]['value']

            if business_score > technology_score:
                business_dataset.add_input_data(Input(data=resources_pb2.Data(image=resources_pb2.Image(url=input_url))))
                print(f'Input {input_url} classified as Business')
            else:
                technology_dataset.add_input_data(Input(data=resources_pb2.Data(image=resources_pb2.Image(url=input_url))))
                print(f'Input {input_url} classified as Technology')

        # Upload the assigned inputs to the datasets
        business_dataset.upload()
        technology_dataset.upload()

    def create_dataset(self, app, dataset_name):
        dataset_index = {}
        datasets = app.list_datasets()
        for ds in datasets:
            name = ds.dataset_info.id
            dataset_index[name] = ds

        idn = f"cf_dataset_{dataset_name.lower()}"
        if idn not in dataset_index:
            dataset = app.create_dataset(dataset_id=idn)
        else:
            dataset = dataset_index[idn]

        return dataset

In this code, replace api_key, app_id, and app_user_id with your actual API key, app ID, and app user ID. The create_workflow() method initializes the Clarifai client and creates datasets for business and technology classes. It then defines a workflow that takes unassigned inputs as input, classifies them into business or technology categories using the Concept Thresholder operator, and outputs them to the appropriate dataset. The output is assigned to the appropriate dataset based on classification.

Finally, the assigned inputs are uploaded to the datasets using dataset.upload(). You can call this method to generate a new workflow that categorizes unassigned inputs into business or technology categories.

jmikedupont2 commented 10 months ago

Yes, you can construct a workflow that reads existing inputs from Clarifai's API and uses them as input. You can use the PostWorkflowResults method to make predictions on your inputs using the workflow. Here's an example:

import requests
from clarifai_grpc.channel.clarifai_channel import ClarifaiChannel
from clarifai_grpc.grpc.api import resources_pb2, service_pb2, service_pb2_grpc

# Replace these with your own values
USER_ID = 'your_user_id'
APP_ID = 'your_app_id'
PAT = 'your_pat'
WORKFLOW_ID = 'your_workflow_id'

channel = ClarifaiChannel.get_grpc_channel()
stub = service_pb2_grpc.V2Stub(channel)

metadata = (('authorization', 'Key ' + PAT),)

# Get unassigned inputs from Clarifai's API
url = f'https://api.clarifai.com/v2/users/{USER_ID}/apps/{APP_ID}/inputs'
headers = {'Authorization': 'Key ' + PAT}
params = {'page': 1, 'per_page': 100, 'status': 'unassigned'}
response = requests.get(url, headers=headers, params=params)
if response.status_code != 200:
    raise Exception(f'Request failed with status code {response.status_code}: {response.text}')
inputs = response.json()['data']

# Create input objects for each unassigned input
input_objs = []
for input_ in inputs:
    input_obj = resources_pb2.Input(
        id=input_['id'],
        data=resources_pb2.Data(
            image=resources_pb2.Image(
                url=input_['data']['image']['url']
            )
        )
    )
    input_objs.append(input_obj)

# Make predictions on the inputs using the workflow
post_workflow_results_response = stub.PostWorkflowResults(
    service_pb2.PostWorkflowResultsRequest(
        user_app_id=resources_pb2.UserAppID(user_id=USER_ID, app_id=APP_ID),
        workflow_id=WORKFLOW_ID,
        inputs=input_objs
    ),
    metadata=metadata
)

# Print the results
for result in post_workflow_results_response.results:
    print(result)

This code sends a GET request to Clarifai's API to retrieve all unassigned inputs for your app. It then creates an input object for each unassigned input and passes them to the PostWorkflowResults method along with your workflow ID. The method returns a list of workflow results, one for each input.

Please note that you will need to replace your_user_id, your_app_id, your_pat, and your_workflow_id with your own values.

Source: Conversation with Bing, 8/26/2023 (1) Workflows in the Clarifai API – Clarifai. https://help.clarifai.com/hc/en-us/articles/4410548748823-Workflows-in-the-Clarifai-API. (2) Common Workflows - Clarifai Guide. https://old-docs.clarifai.com/guide/api-guide/workflows/common-workflows. (3) Workflow Builder | Clarifai Guide. https://docs.clarifai.com/portal-guide/workflows/workflow-builder/. (4) Common Workflows | Clarifai Guide. https://docs.clarifai.com/api-guide/workflows/common-workflows/. (5) Creating Workflows | Clarifai Guide. https://docs.clarifai.com/api-guide/workflows/. (6) undefined. https://docs.clarifai.com/api-guide/api-overview/api-clients. (7) undefined. https://api.clarifai.com/v2/workflows. (8) undefined. https://samples.clarifai.com/metro-north.jpg. (9) Clarifai API Basics | Clarifai Guide. https://docs.clarifai.com/api-guide/api-overview/. (10) Dataset Inputs | Clarifai Guide. https://docs.clarifai.com/api-guide/data/datasets/dataset-inputs/. (11) API Reference — clarifai 2.6.2 documentation - Read the Docs. https://clarifai-python.readthedocs.io/en/latest/clarifai.rest/. (12) All About API Keys! – Clarifai. https://help.clarifai.com/hc/en-us/articles/360037658834-All-About-API-Keys-. (13) undefined. https://api.clarifai.com. (14) undefined. https://api.clarifai.com/v2/users/YOUR_USER_ID_HERE/apps/YOUR_APP_ID_HERE/datasets/YOUR_DATASET_ID_HERE/inputs?page=1&per_page=100.