# Text Summarization — Hugging Face

> This task is well known to summarize longer text into shorter text. Be careful, some models have a maximum length of input. That means that the summary cannot handle full books for instance. Be careful when choosing your model. See the…

- Key: `hugging_face-text-summarization`
- Type: Action (Read-only)
- Version: 0.0.2
- App: Hugging Face (`hugging_face`) — https://pipedream.com/apps/hugging-face.md
- This page (HTML): https://pipedream.com/apps/hugging-face/actions/text-summarization
- Hints: read-only · open-world
- Source: https://github.com/PipedreamHQ/pipedream/blob/master/components/hugging_face/actions/text-summarization/text-summarization.mjs

## Description

This task is well known to summarize longer text into shorter text. Be careful, some models have a maximum length of input. That means that the summary cannot handle full books for instance. Be careful when choosing your model. [See the docs](https://huggingface.co/docs/huggingface.js/inference/classes/HfInference#summarization).

## Props

| Prop | Type | Required | Description |
|---|---|---|---|
| `modelId` | `string` | Yes | The model to use for inference. Options are loaded from the connected account. |
| `text` | `string` | Yes | The text to use for summarization. |
| `maxLength` | `integer` | No | The maximum length of the summary. |
| `minLength` | `integer` | No | The minimum length of the summary. |
| `maxTime` | `integer` | No | The maximum time in seconds to spend on the generation. |
| `repetitionPenalty` | `string` | No | The parameter for repetition penalty. 1.0 means no penalty. See this paper for more details. |
| `temperature` | `string` | No | The value used to module the next token probabilities. Must be strictly positive. See this paper for more details. |
| `topK` | `integer` | No | The number of highest probability vocabulary tokens to keep for top-k-filtering. |
| `topP` | `string` | No | If set to float < 1, only the most probable tokens with probabilities that add up to top_p or higher are kept for generation. |
| `requestTimeout` | `integer` | No | The maximum time in milliseconds to wait for a response from the API. |

## Run it

**MCP**

```ts
import { Client } from "@modelcontextprotocol/sdk/client/index.js"
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js"
import { PipedreamClient } from "@pipedream/sdk"

const pd = new PipedreamClient({
  projectId: process.env.PIPEDREAM_PROJECT_ID!,
  clientId: process.env.PIPEDREAM_CLIENT_ID!,
  clientSecret: process.env.PIPEDREAM_CLIENT_SECRET!,
  projectEnvironment: "production",
})

const accessToken = await pd.rawAccessToken

const transport = new StreamableHTTPClientTransport(
  new URL("https://remote.mcp.pipedream.net/v3"),
  {
    requestInit: {
      headers: {
        Authorization: `Bearer ${accessToken}`,
        "x-pd-project-id": process.env.PIPEDREAM_PROJECT_ID!,
        "x-pd-environment": "production",
        "x-pd-external-user-id": "{external_user_id}", // any stable ID for this user in your system
        "x-pd-app-slug": "hugging_face",
      },
    },
  },
)

const mcp = new Client({ name: "my-agent", version: "1.0.0" })
await mcp.connect(transport)

const { tools } = await mcp.listTools()

// listTools() hands your model this tool's input schema, so it can
// fill the arguments itself:
const result = await mcp.callTool({
  name: "hugging_face-text-summarization",
  arguments: {
    modelId: "Model ID",
    text: "Text",
  },
})
```

**TypeScript**

```ts
import { PipedreamClient } from "@pipedream/sdk"

const pd = new PipedreamClient({
  projectId: process.env.PIPEDREAM_PROJECT_ID!,
  clientId: process.env.PIPEDREAM_CLIENT_ID!,
  clientSecret: process.env.PIPEDREAM_CLIENT_SECRET!,
  projectEnvironment: "production",
})

const result = await pd.actions.run({
  id: "hugging_face-text-summarization",
  externalUserId: "{external_user_id}", // any stable ID for this user in your system
  configuredProps: {
    hugging_face: { authProvisionId: "apn_xxxxxxx" },
    modelId: "Model ID",
    text: "Text",
  },
})

console.log(result)
```

**cURL**

```bash
curl -X POST https://api.pipedream.com/v1/connect/{project_id}/actions/run \
  -H "Content-Type: application/json" \
  -H "X-PD-Environment: production" \
  -H "Authorization: Bearer {access_token}" \
  -d '{
    "external_user_id": "{external_user_id}",
    "id": "hugging_face-text-summarization",
    "configured_props": {
      "hugging_face": { "authProvisionId": "apn_xxxxxxx" },
      "modelId": "Model ID",
      "text": "Text"
    }
  }'
```

---

- App: https://pipedream.com/apps/hugging-face.md · All apps: https://pipedream.com/apps
