Skip to content

Latest commit

 

History

History
67 lines (42 loc) · 1.58 KB

README.md

File metadata and controls

67 lines (42 loc) · 1.58 KB

gpt-emoji

npm version test coverage

Get the emoji(s) that best represent the given text/concept.

Uses OpenAI's GPT-3.5 gpt-3.5-turbo API.

Table of contents

Setup

Install it:

npm i gpt-emoji

Set your OpenAI key:

export OPENAI_API_KEY=sk-...

API

getEmojis()

Parameter Type Description
text string or string[] The string(s) to get emojis for.
options object Optional options for the function.
options.count number The number of emojis to represent the text with. Default: The AI chooses how many are needed.

Returns a string array of emojis that best represent the given text, or a nested array of strings if multiple texts are given.

Note that this function is non-deterministic and could return different emojis each time.

Usage

A single string:

import { getEmojis } from 'gpt-emoji';

getEmojis('japanese cherry blossom festival');

// ['🌸', '🇯🇵, '🎎']

Multiple strings and a custom count:

import { getEmojis } from 'gpt-emoji';

getEmojis(['atomic clock', 'machine learning'], { count: 2 });

// [ [ '⏰', '☢️' ], [ '🤖', '🧠' ] ]