{"id":15739663,"url":"https://github.com/alessiogr/payload-plugin-ai","last_synced_at":"2025-04-01T14:32:13.671Z","repository":{"id":150880653,"uuid":"623612490","full_name":"AlessioGr/payload-plugin-ai","owner":"AlessioGr","description":"Currently just does embeddings!","archived":false,"fork":false,"pushed_at":"2023-04-18T14:40:55.000Z","size":549,"stargazers_count":15,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-01T08:03:07.596Z","etag":null,"topics":["ai","embeddings","openai","payload","payload-plugin","payloadcms"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/AlessioGr.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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-04-04T18:11:32.000Z","updated_at":"2024-11-20T00:29:56.000Z","dependencies_parsed_at":"2023-05-27T15:00:32.954Z","dependency_job_id":null,"html_url":"https://github.com/AlessioGr/payload-plugin-ai","commit_stats":{"total_commits":25,"total_committers":2,"mean_commits":12.5,"dds":0.12,"last_synced_commit":"d87f698d461a8c75a092c0a360b3c002f0449ba9"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlessioGr%2Fpayload-plugin-ai","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlessioGr%2Fpayload-plugin-ai/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlessioGr%2Fpayload-plugin-ai/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlessioGr%2Fpayload-plugin-ai/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AlessioGr","download_url":"https://codeload.github.com/AlessioGr/payload-plugin-ai/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246655063,"owners_count":20812577,"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","embeddings","openai","payload","payload-plugin","payloadcms"],"created_at":"2024-10-04T02:05:37.381Z","updated_at":"2025-04-01T14:32:13.321Z","avatar_url":"https://github.com/AlessioGr.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Payload AI plugin\n\n[![npm version](https://badge.fury.io/js/payload-plugin-ai.svg)](https://badge.fury.io/js/payload-plugin-ai)\n\nATTENTION: This plugin currently requires a custom fork of payload to work (replace `payload` with `yarn add alessiogr/payload#production-with-custom`). This is because this plugins depends on two PRs which haven't been merged into payload yet:\n\n- [PR 1 (custom property)](https://github.com/payloadcms/payload/pull/2436)\n- [PR 2 (hasMany numbers)](https://github.com/payloadcms/payload/pull/2517)\n\nIn this repository I will add a bunch of AI stuff! Currently, it can just generate embeddings for fields using the OpenAI API. Expect things to break with updates without notice.\n\n## Installation\n\n`yarn add payload-plugin-ai`\n\nAdd this to your payload.config.ts:\n```ts\nimport { ai } from 'payload-plugin-ai';\n\n...\n\nplugins: [\n    ai({\n      OPENAI_SECRET: process.env.OPENAI_SECRET,\n      NLPCLOUD_API_KEY: process.env.NLP_CLOUD_API_KEY,\n      embeddings: {\n        provider: \"nlpcloud\", // Nlpcloud is recommended\n      },\n    }),\n]\n```\n\n## Embeddings\n\n![Embeddings generated in the Admin UI](https://user-images.githubusercontent.com/70709113/229883550-5cec9ab9-dc53-4e00-9b47-f3509beb1705.jpg)\n\nTo enable embeddings on a field, simply add this property to the field:\n\n```ts\nimport { genEmbeddings } from 'payload-plugin-ai';\n\n...\n\nyourField: {\n  ...\n  custom: {\n        ...genEmbeddings({ visible: true }),\n  },\n}\n```\n\nNow, every time you save the collection, embeddings for that field will be generated.\n\n## Search through embeddings\n\nYou can use MongoDB atlas search to search through embeddings. In MongoDB Atlas, create a search index which looks like this:\n\n```json\n{\n  \"mappings\": {\n    \"fields\": {\n      \"textArea_embeddings\": [\n        {\n          \"dimensions\": 768,\n          \"similarity\": \"euclidean\",\n          \"type\": \"knnVector\"\n        }\n      ]\n    }\n  }\n}\n```\n\nReplace `textArea_embeddings` with the name of the embeddings field generated by this plugins.\n\nOnce the index is created, you can search through your documents using something like mongoose. There's an example in the payload.config.ts in the demo folder (make sure you adjust the `index` name and the `path`).\n\n## Other\n\nProject structure inspired by [payload-plugin-cloud-storage](https://github.com/payloadcms/plugin-cloud-storage) and [pcms-backpop](https://github.com/TimHal/pcms-backpop)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falessiogr%2Fpayload-plugin-ai","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falessiogr%2Fpayload-plugin-ai","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falessiogr%2Fpayload-plugin-ai/lists"}