Skip to main content

HuggingFace Inference integration for Vision Agents

Project description

HuggingFace Plugin for Vision Agents

HuggingFace Inference integration for Vision Agents. Supports both text-only LLM and vision language models (VLM) through HuggingFace's Inference Providers API.

Installation

uv add vision-agents[huggingface]

Configuration

Set your HuggingFace API token:

export HF_TOKEN=your_huggingface_token

Usage

Text-only LLM

from vision_agents.plugins import huggingface

llm = huggingface.LLM(
    model="meta-llama/Meta-Llama-3-8B-Instruct",
    provider="together",  # optional: use "auto" or omit to let HuggingFace auto-select based on your settings
)

response = await llm.simple_response("Hello, how are you?")
print(response.text)

Vision Language Model (VLM)

from vision_agents.plugins import huggingface

vlm = huggingface.VLM(
    model="Qwen/Qwen2-VL-7B-Instruct",
    fps=1,
    frame_buffer_seconds=10,
)

# VLM automatically buffers video frames when used with an Agent
response = await vlm.simple_response("What do you see?")
print(response.text)

With Function Calling

from vision_agents.plugins import huggingface

llm = huggingface.LLM(model="meta-llama/Meta-Llama-3-8B-Instruct")

@llm.register_function()
def get_weather(city: str) -> str:
    """Get the current weather for a city."""
    return f"The weather in {city} is sunny."

response = await llm.simple_response("What's the weather in Paris?")

Supported Providers

HuggingFace's Inference Providers API supports multiple backends:

  • Together AI
  • Groq
  • Cerebras
  • Replicate
  • Fireworks
  • And more

Specify a provider explicitly or let HuggingFace auto-select:

llm = huggingface.LLM(
    model="meta-llama/Meta-Llama-3-8B-Instruct",
    provider="groq",
)

API Reference

huggingface.LLM

Text-only language model integration.

Parameters:

  • model (str): HuggingFace model ID
  • api_key (str, optional): HuggingFace API token (defaults to HF_TOKEN env var)
  • provider (str, optional): Inference provider name

huggingface.VLM

Vision language model integration with video frame buffering.

Parameters:

  • model (str): HuggingFace model ID
  • api_key (str, optional): HuggingFace API token (defaults to HF_TOKEN env var)
  • provider (str, optional): Inference provider name
  • fps (int): Frames per second to buffer (default: 1)
  • frame_buffer_seconds (int): Seconds of video to buffer (default: 10)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

vision_agents_plugins_huggingface-0.3.3.tar.gz (8.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file vision_agents_plugins_huggingface-0.3.3.tar.gz.

File metadata

File hashes

Hashes for vision_agents_plugins_huggingface-0.3.3.tar.gz
Algorithm Hash digest
SHA256 86a8ccf8ca25ef6abd60977e1cdeb5be2aec61a8967bf586f029034ebc088ecc
MD5 99b690389bfc1da3f3655ab3a53a2b9d
BLAKE2b-256 5b8add5a51ae931a172cdb316d11fddbaea3d040fc913e98fd88c189953ecdae

See more details on using hashes here.

File details

Details for the file vision_agents_plugins_huggingface-0.3.3-py3-none-any.whl.

File metadata

File hashes

Hashes for vision_agents_plugins_huggingface-0.3.3-py3-none-any.whl
Algorithm Hash digest
SHA256 e366de9f40ada06d279d152360997f12904642e812abd1d518423c9ee741eb87
MD5 62473243d3bc6700fa71664d757e18c6
BLAKE2b-256 c73986b2b55ed28795fb57cccfe8a126a709dca8aed31ef5e8933e824baf1660

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page