Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
99 changes: 99 additions & 0 deletions apps/docs/content/docs/tools/huggingface.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
---
title: Hugging Face
description: Use Hugging Face Inference API
---

import { BlockInfoCard } from "@/components/ui/block-info-card"

<BlockInfoCard
type="huggingface"
color="#FFD21E"
icon={true}
iconSvg={`<svg className="block-icon"



viewBox='0 0 24 24'
fill='none'
xmlns='http://www.w3.org/2000/svg'
>
<path
d='M12 2C6.48 2 2 6.48 2 12C2 17.52 6.48 22 12 22C17.52 22 22 17.52 22 12C22 6.48 17.52 2 12 2ZM7 10.5C7.83 10.5 8.5 9.83 8.5 9C8.5 8.17 7.83 7.5 7 7.5C6.17 7.5 5.5 8.17 5.5 9C5.5 9.83 6.17 10.5 7 10.5ZM17 10.5C17.83 10.5 18.5 9.83 18.5 9C18.5 8.17 17.83 7.5 17 7.5C16.17 7.5 15.5 8.17 15.5 9C15.5 9.83 16.17 10.5 17 10.5ZM12 17.5C9.79 17.5 8 15.71 8 13.5H16C16 15.71 14.21 17.5 12 17.5Z'
fill='currentColor'
/>
</svg>`}
/>

Comment thread
icecrasher321 marked this conversation as resolved.
{/* MANUAL-CONTENT-START:intro */}
[HuggingFace](https://huggingface.co/) is a leading AI platform that provides access to thousands of pre-trained machine learning models and powerful inference capabilities. With its extensive model hub and robust API, HuggingFace offers comprehensive tools for both research and production AI applications.
With HuggingFace, you can:

Access pre-trained models: Utilize models for text generation, translation, image processing, and more
Generate AI completions: Create content using state-of-the-art language models through the Inference API
Natural language processing: Process and analyze text with specialized NLP models
Deploy at scale: Host and serve models for production applications
Customize models: Fine-tune existing models for specific use cases

In Sim Studio, the HuggingFace integration enables your agents to programmatically generate completions using the HuggingFace Inference API. This allows for powerful automation scenarios such as content generation, text analysis, code completion, and creative writing. Your agents can generate completions with natural language prompts, access specialized models for different tasks, and integrate AI-generated content into workflows. This integration bridges the gap between your AI workflows and machine learning capabilities, enabling seamless AI-powered automation with one of the world's most comprehensive ML platforms.
{/* MANUAL-CONTENT-END */}

## Usage Instructions

Generate completions using Hugging Face Inference API with access to various open-source models. Leverage cutting-edge AI models for chat completions, content generation, and AI-powered conversations with customizable parameters.


## Tools

### `huggingface_chat`

Generate completions using Hugging Face Inference API

#### Input

| Parameter | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
| `apiKey` | string | Yes | Hugging Face API token |
| `provider` | string | Yes | The provider to use for the API request \(e.g., novita, cerebras, etc.\) |
| `model` | string | Yes | Model to use for chat completions \(e.g., deepseek/deepseek-v3-0324\) |
| `content` | string | Yes | The user message content to send to the model |
| `systemPrompt` | string | No | System prompt to guide the model behavior |
| `maxTokens` | number | No | Maximum number of tokens to generate |
| `temperature` | number | No | Sampling temperature \(0-2\). Higher values make output more random |
| `stream` | boolean | No | Whether to stream the response |

#### Output

| Parameter | Type |
| --------- | ---- |
| `content` | string |
| `model` | string |
| `usage` | string |
| `completion_tokens` | string |
| `total_tokens` | string |



## Block Configuration

### Input

| Parameter | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
| `systemPrompt` | string | No | System Prompt - Enter system prompt to guide the model behavior... |



### Outputs

| Output | Type | Description |
| ------ | ---- | ----------- |
| `response` | object | Output from response |
| ↳ `content` | string | content of the response |
| ↳ `model` | string | model of the response |
| ↳ `usage` | json | usage of the response |


## Notes

- Category: `tools`
- Type: `huggingface`
1 change: 1 addition & 0 deletions apps/docs/content/docs/tools/meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"google_search",
"google_sheets",
"guesty",
"huggingface",
"image_generator",
"jina",
"jira",
Expand Down
125 changes: 125 additions & 0 deletions apps/sim/blocks/blocks/huggingface.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
import { HuggingFaceIcon } from '@/components/icons'
import type { HuggingFaceChatResponse } from '@/tools/huggingface/types'
import type { BlockConfig } from '../types'

export const HuggingFaceBlock: BlockConfig<HuggingFaceChatResponse> = {
type: 'huggingface',
name: 'Hugging Face',
description: 'Use Hugging Face Inference API',
longDescription:
'Generate completions using Hugging Face Inference API with access to various open-source models. Leverage cutting-edge AI models for chat completions, content generation, and AI-powered conversations with customizable parameters.',
docsLink: 'https://docs.simstudio.ai/tools/huggingface',
category: 'tools',
bgColor: '#181C1E',
icon: HuggingFaceIcon,
subBlocks: [
{
id: 'systemPrompt',
title: 'System Prompt',
type: 'long-input',
layout: 'full',
placeholder: 'Enter system prompt to guide the model behavior...',
rows: 3,
},
{
id: 'content',
title: 'User Prompt',
type: 'long-input',
layout: 'full',
placeholder: 'Enter your message here...',
rows: 3,
},
{
id: 'provider',
title: 'Provider',
type: 'dropdown',
layout: 'half',
options: [
{ label: 'Novita', id: 'novita' },
{ label: 'Cerebras', id: 'cerebras' },
{ label: 'Cohere', id: 'cohere' },
{ label: 'Fal AI', id: 'fal' },
{ label: 'Fireworks', id: 'fireworks' },
{ label: 'Hyperbolic', id: 'hyperbolic' },
{ label: 'HF Inference', id: 'hf-inference' },
{ label: 'Nebius', id: 'nebius' },
{ label: 'Nscale', id: 'nscale' },
{ label: 'Replicate', id: 'replicate' },
{ label: 'SambaNova', id: 'sambanova' },
{ label: 'Together', id: 'together' },
],
value: () => 'novita',
},
{
id: 'model',
title: 'Model',
type: 'short-input',
layout: 'full',
placeholder:
'e.g., deepseek/deepseek-v3-0324, llama3.1-8b, meta-llama/Llama-3.2-3B-Instruct-Turbo',
description: 'The model must be available for the selected provider.',
},
{
id: 'temperature',
title: 'Temperature',
type: 'slider',
layout: 'half',
min: 0,
max: 2,
value: () => '0.7',
},
{
id: 'maxTokens',
title: 'Max Tokens',
type: 'short-input',
layout: 'half',
placeholder: 'e.g., 1000',
},
{
id: 'apiKey',
title: 'API Token',
type: 'short-input',
layout: 'full',
placeholder: 'Enter your Hugging Face API token',
password: true,
},
],
tools: {
access: ['huggingface_chat'],
config: {
tool: () => 'huggingface_chat',
params: (params) => {
const toolParams = {
apiKey: params.apiKey,
provider: params.provider,
model: params.model,
content: params.content,
systemPrompt: params.systemPrompt,
temperature: params.temperature ? Number.parseFloat(params.temperature) : undefined,
maxTokens: params.maxTokens ? Number.parseInt(params.maxTokens) : undefined,
stream: false, // Always false
}

return toolParams
},
},
},
inputs: {
systemPrompt: { type: 'string', required: false },
content: { type: 'string', required: true },
provider: { type: 'string', required: true },
model: { type: 'string', required: true },
temperature: { type: 'string', required: false },
maxTokens: { type: 'string', required: false },
apiKey: { type: 'string', required: true },
},
outputs: {
response: {
type: {
content: 'string',
model: 'string',
usage: 'json',
},
},
},
}
2 changes: 2 additions & 0 deletions apps/sim/blocks/registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { GoogleCalendarBlock } from './blocks/google_calendar'
import { GoogleDocsBlock } from './blocks/google_docs'
import { GoogleDriveBlock } from './blocks/google_drive'
import { GoogleSheetsBlock } from './blocks/google_sheets'
import { HuggingFaceBlock } from './blocks/huggingface'
// import { GuestyBlock } from './blocks/guesty'
import { ImageGeneratorBlock } from './blocks/image_generator'
import { JinaBlock } from './blocks/jina'
Expand Down Expand Up @@ -124,6 +125,7 @@ export const registry: Record<string, BlockConfig> = {
whatsapp: WhatsAppBlock,
x: XBlock,
youtube: YouTubeBlock,
huggingface: HuggingFaceBlock,
}

// Helper functions to access the registry
Expand Down
43 changes: 43 additions & 0 deletions apps/sim/components/icons.tsx

Large diffs are not rendered by default.

Loading