{"id":26122967,"url":"https://github.com/clarifai/clarifai-python","last_synced_at":"2026-03-11T09:10:55.553Z","repository":{"id":17532161,"uuid":"20333051","full_name":"Clarifai/clarifai-python","owner":"Clarifai","description":"Experience the power of Clarifai’s AI platform with the python SDK. 🌟 Star to support our work!","archived":false,"fork":false,"pushed_at":"2025-04-07T17:05:22.000Z","size":10814,"stargazers_count":35,"open_issues_count":9,"forks_count":6,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-04-07T17:35:21.606Z","etag":null,"topics":["artifical-intelligence","clarifai","clarifai-python","computer-vision","deep-learning","image-classification","language-models","llm","machine-learning","natural-language-processing","object-detection","pretrained-models","python","rag","retrieval-augmented-generation","text-classification","text-generation","text-summarization","visual-search"],"latest_commit_sha":null,"homepage":"https://github.com/Clarifai/clarifai-python","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Clarifai.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2014-05-30T15:10:36.000Z","updated_at":"2025-04-05T02:46:37.000Z","dependencies_parsed_at":"2023-10-14T19:10:31.684Z","dependency_job_id":"76640700-2c49-4ec1-8c6c-7a3d25635f0f","html_url":"https://github.com/Clarifai/clarifai-python","commit_stats":null,"previous_names":[],"tags_count":113,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Clarifai%2Fclarifai-python","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Clarifai%2Fclarifai-python/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Clarifai%2Fclarifai-python/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Clarifai%2Fclarifai-python/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Clarifai","download_url":"https://codeload.github.com/Clarifai/clarifai-python/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247713258,"owners_count":20983683,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["artifical-intelligence","clarifai","clarifai-python","computer-vision","deep-learning","image-classification","language-models","llm","machine-learning","natural-language-processing","object-detection","pretrained-models","python","rag","retrieval-augmented-generation","text-classification","text-generation","text-summarization","visual-search"],"created_at":"2025-03-10T15:14:09.599Z","updated_at":"2026-02-13T17:12:05.913Z","avatar_url":"https://github.com/Clarifai.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003e\n  \u003ca href=\"https://www.clarifai.com/\"\u003e\u003cimg alt=\"Clarifai\" title=\"Clarifai\" src=\"https://github.com/user-attachments/assets/623b883b-7fe5-4b95-bbfa-8691f5779af4\"\u003e\u003c/a\u003e\n\u003c/h1\u003e\n\n\n\u003ch2 align=\"center\"\u003e\nClarifai Python SDK\n\u003c/h2\u003e\n\n\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://discord.gg/M32V7a7a\" target=\"_blank\"\u003e \u003cimg src=\"https://img.shields.io/discord/1145701543228735582\" alt=\"Discord\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://pypi.org/project/clarifai\" target=\"_blank\"\u003e \u003cimg src=\"https://img.shields.io/pypi/dm/clarifai\" alt=\"PyPI - Downloads\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://img.shields.io/pypi/pyversions/clarifai\" target=\"_blank\"\u003e \u003cimg src=\"https://img.shields.io/pypi/pyversions/clarifai\" alt=\"PyPI - Versions\"\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\n\n\n\nThis is the official Python client for interacting with our powerful [API](https://docs.clarifai.com). The Clarifai Python SDK offers a comprehensive set of tools to integrate Clarifai's AI platform to leverage computer vision capabilities like classification , detection ,segementation and natural language capabilities like classification , summarisation , generation , Q\u0026A ,etc into your applications. With just a few lines of code, you can leverage cutting-edge artificial intelligence to unlock valuable insights from visual and textual content.\n\n[Website](https://www.clarifai.com/) | [Schedule Demo](https://www.clarifai.com/company/schedule-demo) | [Signup for a Free Account](https://clarifai.com/signup) | [API Docs](https://docs.clarifai.com/) | [Clarifai Community](https://clarifai.com/explore) | [Python SDK Docs](https://docs.clarifai.com/resources/api-references/python) | [Examples](https://github.com/Clarifai/examples) | [Colab Notebooks](https://github.com/Clarifai/colab-notebooks) | [Discord](https://discord.gg/XAPE3Vtg)\n\nGive the repo a star ⭐\n---\n\n\n\n## Table Of Contents\n\n* **[Installation](#rocket-installation)**\n* **[Getting Started](#memo-getting-started)**\n* **[Compute Orchestration](#rocket-compute-orchestration)**\n  * [Cluster Operations](#cluster-operations)\n  * [Nodepool Operations](#nodepool-operations)\n  * [Depolyment Operations](#deployment-operations)\n* **[Interacting with Datasets](#floppy_disk-interacting-with-datasets)**\n* **[Interacting with Inputs](#floppy_disk-interacting-with-inputs)**\n  * [Input Upload](#input-upload)\n  * [Input Listing](#input-listing)\n* **[Interacting with Models](#brain-interacting-with-models)**\n  * [Model Predict](#model-predict)\n  * [Model Training](#model-training)\n  * [Model Listing](#models-listing)\n* **[Interacting with Workflows](#fire-interacting-with-workflows)**\n  * [Workflow Predict](#workflow-predict)\n  * [Workflow Listing](#workflows-listing)\n  * [Workflow Create](#workflow-create)\n  * [Workflow Export](#workflow-export)\n* **[Search](#mag-search)**\n  * [Smart Image Search](#smart-image-search)\n  * [Smart Text Search](#smart-text-search)\n  * [Filters](#filters)\n  * [Pagination](#pagination)\n* **[Retrieval Augmented Generation (RAG)](#retrieval-augmented-generation-rag)**\n* **[More Examples](#pushpin-more-examples)**\n\n\n\n\n\n\n\n## :rocket: Installation\n\n\nInstall from PyPi:\n\n```bash\npip install -U clarifai\n```\n\nInstall from Source:\n\n```bash\ngit clone https://github.com/Clarifai/clarifai-python.git\ncd clarifai-python\npython3 -m venv .venv\nsource .venv/bin/activate\npip install -e .\n```\n\n#### Linting\n\nFor developers, use the precommit hook `.pre-commit-config.yaml` to automate linting.\n\n```bash\npip install -r requirements-dev.txt\npre-commit install\n```\n\nNow every time you run `git commit` your code will be automatically linted and won't commit if it fails.\n\nYou can also manually trigger linting using:\n\n```bash\npre-commit run --all-files\n```\n\n\n## :memo: Getting started\nClarifai uses **Personal Access Tokens(PATs)** to validate requests. You can create and manage PATs under your Clarifai account security settings.\n\n* 🔗 [Create PAT:](https://docs.clarifai.com/clarifai-basics/authentication/personal-access-tokens/) ***Log into Portal \u0026rarr; Profile Icon \u0026rarr; Security Settings \u0026rarr; Create Personal Access Token \u0026rarr; Set the scopes \u0026rarr; Confirm***\n\n* 🔗 [Get User ID:](https://help.clarifai.com/hc/en-us/articles/4408131912727-How-do-I-find-my-user-id-app-id-and-PAT-) ***Log into Portal \u0026rarr; Profile Icon \u0026rarr; Account \u0026rarr; Profile \u0026rarr; User-ID***\n\nExport your PAT as an environment variable. Then, import and initialize the API Client.\n\nSet PAT as environment variable through terminal:\n\n```cmd\nexport CLARIFAI_PAT={your personal access token}\n```\n\n```python\n# Note: CLARIFAI_PAT must be set as env variable.\nfrom clarifai.client.user import User\nclient = User(user_id=\"user_id\")\n\n# Get all apps\napps_generator = client.list_apps()\napps = list(apps_generator)\n```\n\nOR \u003cbr\u003e\n\nPAT can be passed as constructor argument\n\n```python\nfrom clarifai.client.user import User\nclient = User(user_id=\"user_id\", pat=\"your personal access token\")\n```\n\n\n## :rocket: Compute Orchestration\n\nClarifai’s Compute Orchestration offers a streamlined solution for managing the infrastructure required for training, deploying, and scaling machine learning models and workflows.\n\nThis flexible system supports any compute instance — across various hardware providers and deployment methods — and provides automatic scaling to match workload demands. [More Details](https://www.clarifai.com/products/compute-orchestration)\n\n#### Cluster Operations\n```python\nfrom clarifai.client.user import User\nclient = User(user_id=\"user_id\",base_url=\"https://api.clarifai.com\")\n\n# Create a new compute cluster\ncompute_cluster = client.create_compute_cluster(compute_cluster_id=\"demo-id\",config_filepath=\"computer_cluster_config.yaml\")\n\n# List Clusters\nall_compute_clusters = list(client.list_compute_clusters())\nprint(all_compute_clusters)\n```\n##### [Example Cluster Config](https://github.com/Clarifai/examples/blob/main/ComputeOrchestration/configs/compute_cluster_config.yaml)\n\n\n\n#### Nodepool Operations\n```python\nfrom clarifai.client.compute_cluster import ComputeCluster\n\n# Initialize the ComputeCluster instance\ncompute_cluster = ComputeCluster(user_id=\"user_id\",compute_cluster_id=\"demo-id\")\n\n# Create a new nodepool\nnodepool = compute_cluster.create_nodepool(nodepool_id=\"demo-nodepool-id\",config_filepath=\"nodepool_config.yaml\")\n\n#Get a nodepool\nnodepool = compute_cluster.nodepool(nodepool_id=\"demo-nodepool-id\")\nprint(nodepool)\n\n# List nodepools\nall_nodepools = list(compute_cluster.list_nodepools())\nprint(all_nodepools)\n```\n##### [Example Nodepool config](https://github.com/Clarifai/examples/blob/main/ComputeOrchestration/configs/nodepool_config.yaml)\n\n#### Deployment Operations\n```python\nfrom clarifai.client.nodepool import Nodepool\n\n# Initialize the Nodepool instance\nnodepool = Nodepool(user_id=\"user_id\",nodepool_id=\"demo-nodepool-id\")\n\n# Create a new deployment\ndeployment = nodepool.create_deployment(deployment_id=\"demo-deployment-id\",config_filepath=\"deployment_config.yaml\")\n\n#Get a deployment\ndeployment = nodepool.deployment(nodepool_id=\"demo-deployment-id\")\nprint(deployment)\n\n# List deployments\nall_deployments = list(nodepool.list_deployments())\nprint(all_deployments)\n\n```\n##### [Example Deployment config](https://github.com/Clarifai/examples/blob/main/ComputeOrchestration/configs/deployment_config.yaml)\n\n#### Compute Orchestration CLI Operations\nRefer Here: https://github.com/Clarifai/clarifai-python/tree/master/clarifai/cli\n\n\n## :floppy_disk: Interacting with Datasets\n\nClarifai datasets help in managing datasets used for model training and evaluation. It provides functionalities like creating datasets,uploading datasets, retrying failed uploads from logs and exporting datasets as .zip files.\n\n```python\n# Note: CLARIFAI_PAT must be set as env variable.\n\n# Create app and dataset\napp = client.create_app(app_id=\"demo_app\", base_workflow=\"Universal\")\ndataset = app.create_dataset(dataset_id=\"demo_dataset\")\n\n# execute data upload to Clarifai app dataset\nfrom clarifai.datasets.upload.loaders.coco_detection import COCODetectionDataLoader\ncoco_dataloader = COCODetectionDataLoader(\"images_dir\", \"coco_annotation_filepath\")\ndataset.upload_dataset(dataloader=coco_dataloader, get_upload_status=True)\n\n\n#Try upload and record the failed outputs in log file.\nfrom clarifai.datasets.upload.utils import load_module_dataloader\ncifar_dataloader = load_module_dataloader('./image_classification/cifar10')\ndataset.upload_dataset(dataloader=cifar_dataloader,\n                       get_upload_status=True,\n                       log_warnings =True)\n\n#Retry upload from logs for `upload_dataset`\n# Set retry_duplicates to True if you want to ingest failed inputs due to duplication issues. by default it is set to 'False'.\ndataset.retry_upload_from_logs(dataloader=cifar_dataloader, log_file_path='log_file.log',\n                               retry_duplicates=True,\n                               log_warnings=True)\n\n#upload text from csv\ndataset.upload_from_csv(csv_path='csv_path', input_type='text', csv_type='raw', labels=True)\n\n#upload data from folder\ndataset.upload_from_folder(folder_path='folder_path', input_type='text', labels=True)\n\n# Export Dataset\ndataset.export(save_path='output.zip')\n```\n\n\n\n## :floppy_disk: Interacting with Inputs\n\nYou can use ***inputs()*** for adding and interacting with input data. Inputs can be uploaded directly from a URL or a file. You can also view input annotations and concepts.\n\n#### Input Upload\n```python\n# Note: CLARIFAI_PAT must be set as env variable.\nfrom clarifai.client.user import User\napp = User(user_id=\"user_id\").app(app_id=\"app_id\")\ninput_obj = app.inputs()\n\n#input upload from url\ninput_obj.upload_from_url(input_id = 'demo', image_url='https://samples.clarifai.com/metro-north.jpg')\n\n#input upload from filename\ninput_obj.upload_from_file(input_id = 'demo', video_file='demo.mp4')\n\n# text upload\ninput_obj.upload_text(input_id = 'demo', raw_text = 'This is a test')\n```\n\n#### Input Listing\n```python\n#listing inputs\ninput_generator = input_obj.list_inputs(page_no=1,per_page=10,input_type='image')\ninputs_list = list(input_generator)\n\n#listing annotations\nannotation_generator = input_obj.list_annotations(batch_input=inputs_list)\nannotations_list = list(annotation_generator)\n\n#listing concepts\nall_concepts = list(app.list_concepts())\n```\n\n#### Input Download\n```python\n#listing inputs\ninput_generator = input_obj.list_inputs(page_no=1,per_page=1,input_type='image')\ninputs_list = list(input_generator)\n\n#downloading_inputs\ninput_bytes = input_obj.download_inputs(inputs_list)\nwith open('demo.jpg','wb') as f:\n  f.write(input_bytes[0])\n```\n\n\n## :brain: Interacting with Models\n\nThe **Model** Class allows you to perform predictions using Clarifai models. You can specify which model to use by providing the model URL or ID. This gives you flexibility in choosing models. The **App** Class also allows listing of all available Clarifai models for discovery.\nFor greater control over model predictions, you can pass in an `output_config` to modify the model output as demonstrated below.\n#### Model Predict\n```python\n# Note: CLARIFAI_PAT must be set as env variable.\nfrom clarifai.client.model import Model\n\n\"\"\"\nGet Model information on details of model(description, usecases..etc) and info on training or\n# other inference parameters(eg: temperature, top_k, max_tokens..etc for LLMs)\n\"\"\"\ngpt_4_model = Model(\"https://clarifai.com/openai/chat-completion/models/GPT-4\")\nprint(gpt_4_model)\n\n\n# Model Predict\nmodel_prediction = Model(\"https://clarifai.com/anthropic/completion/models/claude-v2\").predict_by_bytes(b\"Write a tweet on future of AI\")\n\n# Customizing Model Inference Output\nmodel_prediction = gpt_4_model.predict_by_bytes(b\"Write a tweet on future of AI\", inference_params=dict(temperature=str(0.7), max_tokens=30))\n# Return predictions having prediction confidence \u003e 0.98\nmodel_prediction = model.predict_by_filepath(filepath=\"local_filepath\", output_config={\"min_value\": 0.98}) # Supports image, text, audio, video\n\n# Supports prediction by url\nmodel_prediction = model.predict_by_url(url=\"url\") # Supports image, text, audio, video\n\n# Return predictions for specified interval of video\nvideo_input_proto = [input_obj.get_input_from_url(\"Input_id\", video_url=BEER_VIDEO_URL)]\nmodel_prediction = model.predict(video_input_proto, output_config={\"sample_ms\": 2000})\n```\n#### Model Training\n```python\n# Note: CLARIFAI_PAT must be set as env variable.\nfrom clarifai.client.app import App\nfrom clarifai.client.model import Model\n\n\"\"\"\nCreate model with trainable model_type\n\"\"\"\napp = App(user_id=\"user_id\", app_id=\"app_id\")\nmodel = app.create_model(model_id=\"model_id\", model_type_id=\"visual-classifier\")\n               (or)\nmodel = Model('url')\n\n\"\"\"\nList training templates for the model_type\n\"\"\"\ntemplates = model.list_training_templates()\nprint(templates)\n\n\"\"\"\nGet parameters for the model.\n\"\"\"\nparams = model.get_params(template='classification_basemodel_v1', save_to='model_params.yaml')\n\n\"\"\"\nUpdate the model params yaml and pass it to model.train()\n\"\"\"\nmodel_version_id = model.train('model_params.yaml')\n\n\"\"\"\nTraining status and saving logs\n\"\"\"\nstatus = model.training_status(version_id=model_version_id,training_logs=True)\nprint(status)\n```\n\n#### Export your trained model\nModel Export feature enables you to package your trained model into a `model.tar` file. This file enables deploying your model within a Triton Inference Server deployment.\n\n```python\nfrom clarifai.client.model import Model\n\nmodel = Model('url')\nmodel.export('output/folder/')\n```\n\n#### Evaluate your trained model\n\nWhen your model is trained and ready, you can evaluate by the following code\n\n```python\nfrom clarifai.client.model import Model\n\nmodel = Model('url')\nmodel.evaluate(dataset_id='your-dataset-id')\n```\n\nCompare the evaluation results of your models.\n\n```python\nfrom clarifai.client.model import Model\nfrom clarifai.client.dataset import Dataset\nfrom clarifai.utils.evaluation import EvalResultCompare\n\nmodels = ['model url1', 'model url2'] # or [Model(url1), Model(url2)]\ndataset = 'dataset url' # or Dataset(dataset_url)\n\ncompare = EvalResultCompare(\n  models=models,\n  datasets=dataset,\n  attempt_evaluate=True # attempt evaluate when the model is not evaluated with the dataset\n  )\ncompare.all('output/folder/')\n```\n\n#### Models Listing\n```python\n# Note: CLARIFAI_PAT must be set as env variable.\n\n# List all model versions\nall_model_versions = list(model.list_versions())\n\n# Go to specific model version\nmodel_v1 = client.app(\"app_id\").model(model_id=\"model_id\", model_version_id=\"model_version_id\")\n\n# List all models in an app\nall_models = list(app.list_models())\n\n# List all models in community filtered by model_type, description\nall_llm_community_models = App().list_models(filter_by={\"query\": \"LLM\",\n                                                        \"model_type_id\": \"text-to-text\"}, only_in_app=False)\nall_llm_community_models = list(all_llm_community_models)\n```\n\n\n## :fire: Interacting with Workflows\n\nWorkflows offer a versatile framework for constructing the inference pipeline, simplifying the integration of diverse models. You can use the **Workflow** class to create and manage workflows using **YAML** configuration.\nFor starting or making quick adjustments to existing Clarifai community workflows using an initial YAML configuration, the SDK provides an export feature.\n\n#### Workflow Predict\n```python\n# Note: CLARIFAI_PAT must be set as env variable.\nfrom clarifai.client.workflow import Workflow\n\n# Workflow Predict\nworkflow = Workflow(\"workflow_url\") # Example: https://clarifai.com/clarifai/main/workflows/Face-Sentiment\nworkflow_prediction = workflow.predict_by_url(url=\"url\") # Supports image, text, audio, video\n\n# Customizing Workflow Inference Output\nworkflow = Workflow(user_id=\"user_id\", app_id=\"app_id\", workflow_id=\"workflow_id\",\n                  output_config={\"min_value\": 0.98}) # Return predictions having prediction confidence \u003e 0.98\nworkflow_prediction = workflow.predict_by_filepath(filepath=\"local_filepath\") # Supports image, text, audio, video\n```\n\n#### Workflows Listing\n```python\n# Note: CLARIFAI_PAT must be set as env variable.\n\n# List all workflow versions\nall_workflow_versions = list(workflow.list_versions())\n\n# Go to specific workflow version\nworkflow_v1 = Workflow(workflow_id=\"workflow_id\", workflow_version=dict(id=\"workflow_version_id\"), app_id=\"app_id\", user_id=\"user_id\")\n\n# List all workflow in an app\nall_workflow = list(app.list_workflow())\n\n# List all workflow in community filtered by description\nall_face_community_workflows = App().list_workflows(filter_by={\"query\": \"face\"}, only_in_app=False) # Get all face related workflows\nall_face_community_workflows = list(all_face_community_workflows)\n```\n#### Workflow Create\nCreate a new workflow specified by a yaml config file.\n```python\n# Note: CLARIFAI_PAT must be set as env variable.\nfrom clarifai.client.app import App\napp = App(app_id=\"app_id\", user_id=\"user_id\")\nworkflow = app.create_workflow(config_filepath=\"config.yml\")\n```\n\n#### Workflow Export\nExport an existing workflow from Clarifai as a local yaml file.\n```python\n# Note: CLARIFAI_PAT must be set as env variable.\nfrom clarifai.client.workflow import Workflow\nworkflow = Workflow(\"https://clarifai.com/clarifai/main/workflows/Demographics\")\nworkflow.export('demographics_workflow.yml')\n```\n\n## :mag: Search\n\n#### Smart Image Search\nClarifai's Smart Search feature leverages vector search capabilities to power the search experience. Vector search is a type of search engine that uses vectors to search and retrieve text, images, and videos.\n\nInstead of traditional keyword-based search, where exact matches are sought, vector search allows for searching based on visual and/or semantic similarity by calculating distances between vector embedding representations of the data.\n\nHere is an example of how to use vector search to find similar images:\n\n```python\n# Note: CLARIFAI_PAT must be set as env variable.\nfrom clarifai.client.search import Search\nsearch = Search(user_id=\"user_id\", app_id=\"app_id\", top_k=1, metric=\"cosine\")\n\n# Search by image url\nresults = search.query(ranks=[{\"image_url\": \"https://samples.clarifai.com/metro-north.jpg\"}])\n\nfor data in results:\n  print(data.hits[0].input.data.image.url)\n```\n\n#### Smart Text Search\nSmart Text Search is our proprietary feature that uses deep learning techniques to sort, rank, and retrieve text data based on their content and semantic similarity.\n\nHere is an example of how to use Smart Text Search to find similar text:\n\n```python\n# Note: CLARIFAI_PAT must be set as env variable.\n\n# Search by text\nresults = search.query(ranks=[{\"text_raw\": \"I love my dog\"}])\n```\n\n#### Filters\n\nYou can use filters to narrow down your search results. Filters can be used to filter by concepts, metadata, and Geo Point.\n\nIt is possible to add together multiple search parameters to expand your search. You can even combine negated search terms for more advanced tasks.\n\nFor example, you can combine two concepts as below.\n\n```python\n# query for images that contain concept \"deer\" or \"dog\"\nresults = search.query(ranks=[{\"image_url\": \"https://samples.clarifai.com/metro-north.jpg\"}],\n                        filters=[{\"concepts\": [{\"name\": \"deer\", \"value\":1},\n                                              {\"name\": \"dog\", \"value\":1}]}])\n\n# query for images that contain concepts \"deer\" and \"dog\"\nresults = search.query(ranks=[{\"image_url\": \"https://samples.clarifai.com/metro-north.jpg\"}],\n                        filters=[{\"concepts\": [{\"name\": \"deer\", \"value\":1}],\n                                  \"concepts\": [{\"name\": \"dog\", \"value\":1}]}])\n```\n\nInput filters allows to filter by input_type, status of inputs and by inputs_dataset_id\n\n```python\nresults = search.query(filters=[{'input_types': ['image', 'text']}])\n```\n\n#### Pagination\n\nBelow is an example of using Search with Pagination.\n\n```python\n# Note: CLARIFAI_PAT must be set as env variable.\nfrom clarifai.client.search import Search\nsearch = Search(user_id=\"user_id\", app_id=\"app_id\", metric=\"cosine\", pagination=True)\n\n# Search by image url\nresults = search.query(ranks=[{\"image_url\": \"https://samples.clarifai.com/metro-north.jpg\"}],page_no=2,per_page=5)\n\nfor data in results:\n  print(data.hits[0].input.data.image.url)\n```\n\n## Retrieval Augmented Generation (RAG)\n\nYou can setup and start your RAG pipeline in 4 lines of code. The setup method automatically creates a new app and the necessary components under the hood. By default it uses the [mistral-7B-Instruct](https://clarifai.com/mistralai/completion/models/mistral-7B-Instruct) model.\n\n```python\nfrom clarifai.rag import RAG\n\nrag_agent = RAG.setup(user_id=\"USER_ID\")\nrag_agent.upload(folder_path=\"~/docs\")\nrag_agent.chat(messages=[{\"role\":\"human\", \"content\":\"What is Clarifai\"}])\n```\n\nIf you have previously run the setup method, you can instantiate the RAG class with the prompter workflow URL:\n\n```python\nfrom clarifai.rag import RAG\n\nrag_agent = RAG(workflow_url=\"WORKFLOW_URL\")\n```\n\n## :pushpin: More Examples\n\nSee many more code examples in this [repo](https://github.com/Clarifai/examples).\nAlso see the official [Python SDK docs](https://clarifai-python.readthedocs.io/en/latest/index.html)\n\n## :open_file_folder: Model Upload\n\nExamples for uploading models and runners have been moved to this [repo](https://github.com/Clarifai/runners-examples).\nFind our official documentation at [docs.clarifai.com/compute/models/upload](https://docs.clarifai.com/compute/models/upload).\n\n## Versioning\n\nThis project uses [CalVer](https://calver.org/) with the format **`YY.MM.PATCH`**:\n- **YY** — Clarifai year, counting from the company's founding (e.g. `12` for the 12th year)\n- **MM** — month number, not zero-padded (e.g. `1` for January, `12` for December)\n- **PATCH** — incremental release within that month, starting at `0`\n\nGit tags use the same format without a `v` prefix (e.g. `12.2.0`). The version is defined in `clarifai/__init__.py`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fclarifai%2Fclarifai-python","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fclarifai%2Fclarifai-python","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fclarifai%2Fclarifai-python/lists"}