{"id":12610609,"url":"https://github.com/polyfact/polyfire-js","last_synced_at":"2026-01-28T10:16:37.183Z","repository":{"id":180196744,"uuid":"662963848","full_name":"polyfact/polyfire-js","owner":"polyfact","description":"🔥 React library of AI components 🔥","archived":false,"fork":false,"pushed_at":"2024-09-02T13:28:38.000Z","size":5823,"stargazers_count":141,"open_issues_count":3,"forks_count":11,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-11-12T13:07:05.569Z","etag":null,"topics":["ai","ai-models","ai-tool","llm","npm","package","sdk"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/polyfire-js","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/polyfact.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-07-06T09:05:27.000Z","updated_at":"2025-11-03T16:15:54.000Z","dependencies_parsed_at":"2023-10-13T05:24:34.496Z","dependency_job_id":"d79a2043-d037-434c-8146-6027008735d6","html_url":"https://github.com/polyfact/polyfire-js","commit_stats":null,"previous_names":["polyfact/polyfact-node","polyfact/polyfire-js"],"tags_count":72,"template":false,"template_full_name":null,"purl":"pkg:github/polyfact/polyfire-js","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/polyfact%2Fpolyfire-js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/polyfact%2Fpolyfire-js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/polyfact%2Fpolyfire-js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/polyfact%2Fpolyfire-js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/polyfact","download_url":"https://codeload.github.com/polyfact/polyfire-js/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/polyfact%2Fpolyfire-js/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28844011,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-28T07:39:25.367Z","status":"ssl_error","status_checked_at":"2026-01-28T07:39:24.487Z","response_time":57,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ai","ai-models","ai-tool","llm","npm","package","sdk"],"created_at":"2024-07-15T07:06:44.121Z","updated_at":"2026-01-28T10:16:37.159Z","avatar_url":"https://github.com/polyfact.png","language":"JavaScript","funding_links":[],"categories":["Usage"],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003e🔥 polyfire\u003c/h1\u003e\n\n\u003ch4 align=\"center\"\u003e\n    \u003ca href=\"https://www.polyfire.com/discord\"\u003eDiscord\u003c/a\u003e |  \u003ca href=\"https://beta.polyfire.com\"\u003eDashboard\u003c/a\u003e\n\u003c/h4\u003e\n\n\u003cp align=\"center\"\u003e⚡ An all-in-one managed backend for AI apps. Build AI apps from the frontend, very fast. 🪶\u003c/p\u003e\n\nWhy use Polyfire?\n\n-   Just code from the frontend, no backend needed\n-   If you already have backend, less code to write\n-   Most backend services you'd need in a couple lines of code\n\nWe **manage your AI backend** so you don't have to.\n\n![Demo Gif](https://files.readme.io/7442014-demo.gif)\n\n### React\n\n```js\nimport { useState, useEffect } from \"react\";\nimport { createRoot } from \"react-dom/client\";\nimport { TextGenerated, Login } from \"polyfire-js/components\";\n\nfunction App() {\n    return (\n        \u003cLogin\u003e\n            \u003ch2\u003eHere's a little auto-generated haiku for you:\u003c/h2\u003e\n            \u003cTextGenerated prompt=\"Generate a hello world haiku\" /\u003e\n        \u003c/Login\u003e\n    );\n}\n\ndocument.body.innerHTML = '\u003cdiv id=\"app\"\u003e\u003c/div\u003e';\nconst root = createRoot(document.getElementById(\"app\"));\nroot.render(\n    \u003cPolyfireProvider project=\"your_project_id\"\u003e\n        \u003cApp /\u003e\n    \u003c/PolyfireProvider\u003e,\n);\n```\n\n\u003e Don't forget to change the **your_project_id** by your project ID you will have got on https://beta.polyfire.com\n\n### Vanilla JS\n\n```html\n\u003cscript src=\"https://github.com/polyfire-ai/polyfire-js/releases/download/0.2.7/polyfire-min-0.2.7.js\"\u003e\u003c/script\u003e\n\u003cscript\u003e\n    (async () =\u003e {\n        const polyfire = window.PolyfireClientBuilder({ project: \"your_project_id\" });\n\n        const isAuthenticated = await polyfire.auth.init();\n        if (!isAuthenticated) {\n            await polyfire.auth.login(\"github\");\n        }\n\n        const helloWorld = await polyfire.models.generate(\"Write me a hello world haiku\");\n        console.log(helloWorld);\n    })();\n\u003c/script\u003e\n```\n\n\u003e Don't forget to change the **your_project_id** by your project ID you will have got on https://beta.polyfire.com\n\n## 🔗 Links\n\n-   Website: [polyfire.com](https://www.polyfire.com)\n-   Dashboard: [beta.polyfire.com](https://beta.polyfire.com)\n-   Discord: [polyfire.com/discord](https://www.polyfire.com/discord)\n-   Javascript SDK: [github.com/polyfact/polyfire-js](https://www.github.com/polyfact/polyfire-js)\n-   Open Source API (your managed backend!): [github.com/polyfact/polyfire-api](https://github.com/polyfact/polyfire-api)\n\nWe're open source! Make a good PR to the JS SDK or the API and we'll merge it.\n\n\n# SDK Documentation\n\n## Overview\n\nThis SDK provides functionalities for text generation, transcription, memory management, image generation, and data loading. Below is a guide on how to use these features.\n\n### Installation\n\nTo install the SDK, use the following command:\n\n```bash\nnpm install polyfire-js\n```\n\n### Importing the SDK\n\nTo use the SDK, import the necessary functions and classes:\n\n```typescript\nimport {\n    generate,\n    generateWithType,\n    transcribe,\n    Chat,\n    createMemory,\n    updateMemory,\n    getAllMemories,\n    generateImage,\n    TextFileLoader,\n    StringLoader,\n    AudioLoader,\n    kv,\n    usage,\n    t\n} from \"polyfire-js\";\nimport PolyfireClientBuilder from \"polyfire-js\";\n```\n\n## Features\n\n### Text Generation\n\n- **generate**: Generate text based on input.\n- **generateWithType**: Generate text with probabilistic types.\n\n```typescript\nconst options: GenerationOptions = { /* Generation options */ };\nconst result = await generate(\"Your input text\", options);\n```\n\n### Transcription\n\n- **transcribe**: Transcribe audio to text.\n\n```typescript\nconst transcription = await transcribe(audioFile);\n```\n\n### Chat\n\n- **Chat**: Class for handling chat functionalities.\n\n```typescript\nconst chat = new Chat();\nchat.sendMessage(\"Hello!\");\n```\n\n### Memory Management\n\n- **createMemory**: Create embeddings for memory.\n- **updateMemory**: Update existing embeddings.\n- **getAllMemories**: Retrieve all embeddings.\n\n```typescript\nconst memory = createMemory(data);\nconst updatedMemory = updateMemory(memoryId, newData);\nconst allMemories = getAllMemories();\n```\n\n### Image Generation\n\n- **generateImage**: Generate images based on input.\n\n```typescript\nconst image = await generateImage(\"A beautiful sunset\");\n```\n\n### Data Loaders\n\n- **TextFileLoader**: Load text files.\n- **StringLoader**: Load strings.\n- **AudioLoader**: Load audio files.\n\n```typescript\nconst textLoader = new TextFileLoader(filePath);\nconst stringLoader = new StringLoader(stringData);\nconst audioLoader = new AudioLoader(audioFile);\n```\n\n### Key-Value Store Operations\n\n- **kv.get**: Retrieve a value by key.\n- **kv.set**: Store a value by key.\n- **kv.del**: Delete a value by key.\n- **kv.all**: Retrieve all key-value pairs.\n\n```typescript\nconst value = await kv.get(\"key\");\nawait kv.set(\"key\", \"value\");\nawait kv.del(\"key\");\nconst allValues = await kv.all();\n```\n\n### Usage Tracking\n\n- **usage**: Track usage of the SDK.\n\n```typescript\nconst usageData = await usage();\n```\n\n### Type Validation\n\n- **t**: Type validation using `polyfact-io-ts`.\n\n```typescript\nconst isValid = t.validate(data, schema);\n```\n\n### Client Builder\n\n- **PolyfireClientBuilder**: Build the client.\n\n```typescript\nconst client = new PolyfireClientBuilder({ apiKey: \"your-api-key\" });\n```\n\n## Example Usage\n\nHere is a complete example of using the SDK:\n\n```typescript\nimport {\n    generate,\n    transcribe,\n    createMemory,\n    generateImage,\n    kv,\n    usage\n} from \"polyfire-js\";\nimport PolyfireClientBuilder from \"polyfire-js\";\n\nasync function main() {\n    // Text generation\n    const text = await generate(\"Hello, world!\");\n\n    // Transcription\n    const transcription = await transcribe(\"path/to/audio/file\");\n\n    // Memory management\n    const memory = createMemory(\"Some data\");\n\n    // Image generation\n    const image = await generateImage(\"A beautiful sunset\");\n\n    // Key-Value operations\n    await kv.set(\"key\", \"value\");\n    const value = await kv.get(\"key\");\n\n    // Usage tracking\n    const usageData = await usage();\n\n    // Client builder\n    const client = new PolyfireClientBuilder({ apiKey: \"your-api-key\" });\n}\n\nmain();\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpolyfact%2Fpolyfire-js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpolyfact%2Fpolyfire-js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpolyfact%2Fpolyfire-js/lists"}