# @focus-reactive/content-ai-sdk

> An easy way to enchance your project with ready to use GPT functions

Latest version **0.0.15** (published 2025-04-14) · MIT license · 0 weekly downloads

## Install

```sh
npm install @focus-reactive/content-ai-sdk
pnpm add @focus-reactive/content-ai-sdk
yarn add @focus-reactive/content-ai-sdk
bun add @focus-reactive/content-ai-sdk
```

## Health

**Score 40/100 (D)** — status: maintenance-mode.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads; pre 1.0.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.15 |
| Published | 2025-04-14 |
| First published | 2023-12-01 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 3 |
| Unpacked size | 144.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Alex Hramovich |
| Maintainers | pixelscommander, operatino, alex_hramovich, mcfrid, dogfrogfog, o8o0o8o |

## Links

- npm: https://www.npmjs.com/package/@focus-reactive/content-ai-sdk
- npm.io page: https://npm.io/package/@focus-reactive/content-ai-sdk

## Dependencies (3)

- [flat](https://npm.io/package/flat.md) ^6.0.1
- [openai](https://npm.io/package/openai.md) ^4.17.3
- [gpt-3-encoder](https://npm.io/package/gpt-3-encoder.md) ^1.1.4

## Recent versions

- 0.0.15 (latest) — 2025-04-14
- 0.0.14 — 2025-02-26
- 0.0.13 — 2025-02-20
- 0.0.12 — 2025-02-20
- 0.0.11 — 2025-02-20
- 0.0.10 — 2025-02-20
- 0.0.9 — 2025-02-20
- 0.0.8 — 2025-02-19
- 0.0.7 — 2025-02-19
- 0.0.6 — 2025-02-18
- 0.0.5 — 2025-02-17
- 0.0.4 — 2024-03-22
- 0.0.3 — 2024-03-22
- 0.0.2 — 2024-01-17
- 0.0.1 — 2023-12-01

## README

<a  href="https://focusreactive.com/"  align="center">
		<img width="25%" height="auto" src="https://cdn.sanity.io/images/vftxng62/production/25e191578a3c3d4ddfaf69c5f6f7070aead0bff4-507x168.png?auto=format"  alt="FocusReactive logo">
</a>

# Content AI SDK

## 🚀 Usage

### Install

```sh
yarn add @focus-reactive/content-ai-sdk
```

### How to use it

#### Initialisation

```javascript
// 1. Import the configration function
import { initSDK } from "@focus-reactive/content-ai-sdk";

// 2. Initialize the SDK with the OpenAI token
initSDK({ openAiToken: OPEN_AI_TOKEN });
```

## Documentation

### Translations

We implemented several features that you can use in your projects to work with localisations.

#### Function **`translate`**

**Parameters**

```typescript
interface TranslateOptions {
  targetLanguage: string;
  content: string;
  currentLanguage?: string;
  promptModifier?: string;
}
```

- `targetLanguage` string - Result language
- `content` string - Text content that should be translated to the target language.
- `currentLanguage` string - Current language of the content. If not provided, the language will be detected automatically.
- `promptModifier` string - Can be used to modify prompt.

**Usage**

```javascript
// 1. Import the function
import { translate } from "@focus-reactive/content-ai-sdk";

// 2. Call the function
const deContent = await translate({
  content: "Hey! Now I can manage german content",
  targetLanguage: "german",
});
```

#### Function **`translateJSON`**

This function is created to translate JSON objects to a different language without changing it's structure.

**Parameters**

```typescript
interface TranslateOptions {
  targetLanguage: string;
  content: object;
  promptModifier?: string;
  currentLanguage?: string;
}
```

- `targetLanguage` - Result language
- `content` - Text content that should be translated to the target language (JSON).
- `promptModifier` - Can be used to modify prompt. In some cases you may need to not translate some values or exlude some fields.
- `currentLanguage` - Current language of the content. If not provided, the language will be detected automatically.

**Usage**

```javascript
// 1. Import the function
import { translateJSON } from "@focus-reactive/content-ai-sdk";

// 2. Call the function
const deContent = await translateJSON({
  content: JSON.stringify({
    title: "Batman 2",
    description: "Superhero movie",
  }),
  targetLanguage: "german",
  promptModifier:
    "Do not translate technical fields, they starts with a _ symbol. Translate only values with more than 1 word.",
});
```

### Summarisation

#### Function **`summariseContent`**

This function is created to be able to create a sammury of a content. Works with string and JSON objects.

**Parameters**

```typescript
interface SummariseContentProps {
  content: unknown;
  contentTitle: string;
  promptModifier?: string;
}
```

- `contentTitle` - Content title. This is a required field that sets the logical context for the provided content.
- `content` JSON | string - Text content that will be summarised. (JSON | string)
- `promptModifier` - Can be used to modify prompt.

**Usage**

```typescript
// 1. Import the function
import { summariseContent } from "@focus-reactive/content-ai-sdk";

// 2. Call the function
const summary = await summariseContent({
  contentTitle: "Batman movie overview.",
  content: JSON.stringify({
    title: "Batman",
    description: "Superhero movie",
  }),
  promptModifier: "Make sure that the summary is not longer than 3 sentences.",
});
```

### Categotisation

#### Function **`applyTags`**

This function is created to logically tag content. Returns tags on order of relevance.

**Parameters**

```typescript
interface Tag {
  id: string | number;
  title: string;
  description?: string;
}

interface AppplyTagsProps {
  content: unknown;
  contentTitle: string;
  promptModifier?: string;
  resultAmount?: number;
  tags: Tag[];
}
```

- `contentTitle`- Content title. Sets the logical context for the provided content.
- `content` - Text contentf for tagging. (JSON | string)
- `promptModifier` - Can be used to modify prompt.
- `resultAmount` - Amount of tags that should be returned.
- `tags` - Array of tags that should be used for tagging.

**Usage**

```typescript
// 1. Import the function
import { applyTags } from "@focus-reactive/content-ai-sdk";

// 2. Call the function
const tags = await applyTags({
  contentTitle: "Batman movie overview.",
  content: JSON.stringify({
    title: "Batman",
    description: "Superhero movie",
  }),
  tags: [] as Tag[],
  resultAmount: 5,
  promptModifier: "Make sure that the summary is not longer than 3 sentences.",
});
```

---
_Source: https://npm.io/package/@focus-reactive/content-ai-sdk · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
