{"id":25918351,"url":"https://github.com/xavidop/genkitx-huggingface","last_synced_at":"2025-03-03T14:19:24.461Z","repository":{"id":279087791,"uuid":"937701392","full_name":"xavidop/genkitx-huggingface","owner":"xavidop","description":"Community Plugin for Genkit to use Hugging Face Models using Inference Providers","archived":false,"fork":false,"pushed_at":"2025-03-03T11:00:02.000Z","size":386,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-03T11:39:57.445Z","etag":null,"topics":["ai","firebase","generative-ai","genkit","genkit-plugin","genkitx","plugin"],"latest_commit_sha":null,"homepage":"https://xavidop.github.io/genkitx-huggingface/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/xavidop.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"xavidop","patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"lfx_crowdfunding":null,"polar":null,"buy_me_a_coffee":null,"thanks_dev":null,"custom":null}},"created_at":"2025-02-23T17:42:49.000Z","updated_at":"2025-03-03T11:00:05.000Z","dependencies_parsed_at":null,"dependency_job_id":"33e400cb-5404-4d4c-b3d2-9ce9950044e1","html_url":"https://github.com/xavidop/genkitx-huggingface","commit_stats":null,"previous_names":["xavidop/genkitx-huggingface"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xavidop%2Fgenkitx-huggingface","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xavidop%2Fgenkitx-huggingface/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xavidop%2Fgenkitx-huggingface/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xavidop%2Fgenkitx-huggingface/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xavidop","download_url":"https://codeload.github.com/xavidop/genkitx-huggingface/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241661397,"owners_count":19998949,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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","firebase","generative-ai","genkit","genkit-plugin","genkitx","plugin"],"created_at":"2025-03-03T14:19:23.824Z","updated_at":"2025-03-03T14:19:24.455Z","avatar_url":"https://github.com/xavidop.png","language":"TypeScript","funding_links":["https://github.com/sponsors/xavidop"],"categories":["Plugins"],"sub_categories":["JavaScript - Community"],"readme":"![Firebase Genkit + Hugging Face Models](https://github.com/xavidop/genkitx-huggingface/blob/main/assets/genkit-huggingface.png?raw=true)\n\n\u003ch1 align=\"center\"\u003e\n   Firebase Genkit \u003c\u003e Hugging Face Models Plugin\n\u003c/h1\u003e\n\n\u003ch4 align=\"center\"\u003eHugging Face Models Community Plugin for Google Firebase Genkit\u003c/h4\u003e\n\n\u003cdiv align=\"center\"\u003e\n   \u003cimg alt=\"GitHub version\" src=\"https://img.shields.io/github/v/release/xavidop/genkitx-huggingface\"\u003e\n   \u003cimg alt=\"NPM Downloads\" src=\"https://img.shields.io/npm/dw/genkitx-huggingface\"\u003e\n   \u003cimg alt=\"GitHub License\" src=\"https://img.shields.io/github/license/xavidop/genkitx-huggingface\"\u003e\n   \u003cimg alt=\"Static Badge\" src=\"https://img.shields.io/badge/yes-a?label=maintained\"\u003e\n\u003c/div\u003e\n\n\u003cdiv align=\"center\"\u003e\n   \u003cimg alt=\"GitHub Issues or Pull Requests\" src=\"https://img.shields.io/github/issues/xavidop/genkitx-huggingface?color=blue\"\u003e\n   \u003cimg alt=\"GitHub Issues or Pull Requests\" src=\"https://img.shields.io/github/issues-pr/xavidop/genkitx-huggingface?color=blue\"\u003e\n   \u003cimg alt=\"GitHub commit activity\" src=\"https://img.shields.io/github/commit-activity/m/xavidop/genkitx-huggingface\"\u003e\n\u003c/div\u003e\n\n\u003c/br\u003e\n\n**`genkitx-huggingface`** is a community plugin for using Hugging Face Models APIs with\n[Firebase Genkit](https://github.com/firebase/genkit). Built by [**Xavier Portilla Edo**](https://github.com/xavidop).\n\nThis Genkit plugin allows to use Hugging Face models through their official APIs.\n\n## Installation\n\nInstall the plugin in your project with your favorite package manager:\n\n- `npm install genkitx-huggingface`\n- `pnpm add genkitx-huggingface`    \n\n## Usage\n\n### Configuration\n\nTo use the plugin, you need to configure it with your Hugging Face Token key. You can do this by calling the `genkit` function:\n\n```typescript\nimport { genkit, z } from 'genkit';\nimport { huggingface, openAIGpt4o } from \"genkitx-huggingface\";\n\nconst ai = genkit({\n  plugins: [\n    huggingface({\n      huggingfaceToken: '\u003cmy-huggingface-token\u003e',\n    }),\n    openAIGpt4o,\n  ]\n});\n```\n\nYou can also initialize the plugin in this way if you have set the `HUGGINGFACE_TOKEN` environment variable:\n\n```typescript\nimport { genkit, z } from 'genkit';\nimport { huggingface, openAIGpt4o } from \"genkitx-huggingface\";\n\nconst ai = genkit({\n  plugins: [\n    huggingface({\n      huggingfaceToken: '\u003cmy-huggingface-token\u003e',\n    }),\n    openAIGpt4o,\n  ]\n});\n```\n\n### Basic examples\n\nThe simplest way to call the text generation model is by using the helper function `generate`:\n\n```typescript\nimport { genkit, z } from 'genkit';\nimport { huggingface, openAIGpt4o } from \"genkitx-huggingface\";\n\n// Basic usage of an LLM\nconst response = await ai.generate({\n  prompt: 'Tell me a joke.',\n});\n\nconsole.log(await response.text);\n```\n\n### Within a flow\n\n```typescript\n// ...configure Genkit (as shown above)...\n\nexport const myFlow = ai.defineFlow(\n  {\n    name: 'menuSuggestionFlow',\n    inputSchema: z.string(),\n    outputSchema: z.string(),\n  },\n  async (subject) =\u003e {\n    const llmResponse = await ai.generate({\n      prompt: `Suggest an item for the menu of a ${subject} themed restaurant`,\n    });\n\n    return llmResponse.text;\n  }\n);\n```\n\n### Tool use\n\n```typescript\n// ...configure Genkit (as shown above)...\n\nconst specialToolInputSchema = z.object({ meal: z.enum([\"breakfast\", \"lunch\", \"dinner\"]) });\nconst specialTool = ai.defineTool(\n  {\n    name: \"specialTool\",\n    description: \"Retrieves today's special for the given meal\",\n    inputSchema: specialToolInputSchema,\n    outputSchema: z.string(),\n  },\n  async ({ meal }): Promise\u003cstring\u003e =\u003e {\n    // Retrieve up-to-date information and return it. Here, we just return a\n    // fixed value.\n    return \"Baked beans on toast\";\n  }\n);\n\nconst result = ai.generate({\n  tools: [specialTool],\n  prompt: \"What's for breakfast?\",\n});\n\nconsole.log(result.then((res) =\u003e res.text));\n```\n\nFor more detailed examples and the explanation of other functionalities, refer to the [official Genkit documentation](https://firebase.google.com/docs/genkit/get-started).\n\n## Supported models\n\nThis plugin supports all currently available **Chat/Completion** and **Embeddings** models from Hugging Face Models. This plugin supports image input and multimodal models.\n\n## API Reference\n\nThis plugin supports all Hugging Face models available in the [Inference Providers on the Hub](https://huggingface.co/blog/inference-providers).\n\n## Contributing\n\nWant to contribute to the project? That's awesome! Head over to our [Contribution Guidelines](https://github.com/xavidop/genkitx-huggingface/blob/main/CONTRIBUTING.md).\n\n## Need support?\n\n\u003e [!NOTE]  \n\u003e This repository depends on Google's Firebase Genkit. For issues and questions related to Genkit, please refer to instructions available in [Genkit's repository](https://github.com/firebase/genkit).\n\nReach out by opening a discussion on [GitHub Discussions](https://github.com/xavidop/genkitx-huggingface/discussions).\n\n## Credits\n\nThis plugin is proudly maintained by Xavier Portilla Edo [**Xavier Portilla Edo**](https://github.com/xavidop).\n\nI got the inspiration, structure and patterns to create this plugin from the [Genkit Community Plugins](https://github.com/TheFireCo/genkit-plugins) repository built by the [Fire Compnay](https://github.com/TheFireCo) as well as the [ollama plugin](https://firebase.google.com/docs/genkit/plugins/ollama).\n\n## License\n\nThis project is licensed under the [Apache 2.0 License](https://github.com/xavidop/genkitx-huggingface/blob/main/LICENSE).\n\n[![License: Apache 2.0](https://img.shields.io/badge/License-Apache%202%2E0-lightgrey.svg)](https://github.com/xavidop/genkitx-huggingface/blob/main/LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxavidop%2Fgenkitx-huggingface","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxavidop%2Fgenkitx-huggingface","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxavidop%2Fgenkitx-huggingface/lists"}