Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Next #3

Merged
merged 2 commits into from
Jul 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
- [x] Voice generation with ElevenLabs
- [x] Image generation with OpenAI
- [x] Field level prompt customization
- [ ] Analyse documents
- [ ] Automation of content creation workflows
- [ ] Internationalization support

## 📋 Table of Contents
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@ashbuilds/payload-ai",
"name": "payload-plugin-ai",
"version": "1.0.0",
"private": false,
"bugs": "https://github.com/ashbuilds/payload-ai/issues",
Expand Down
15 changes: 3 additions & 12 deletions src/defaults.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,3 @@
export const defaults = {
description: {
maxLength: 150,
minLength: 100,
},
title: {
maxLength: 60,
minLength: 50,
},
}

export const PLUGIN_NAME = 'ai-plugin'
export const PLUGIN_NAME = 'plugin-ai'
export const PLUGIN_INSTRUCTIONS_TABLE = 'instructions'
export const PLUGIN_INSTRUCTIONS_MAP_GLOBAL = 'ai-plugin__instructions_map'
2 changes: 1 addition & 1 deletion src/exports/types.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export type { payloadAiPlugin } from '../plugin.ts'
export type { payloadPluginAI } from '../plugin.ts'
export type { PluginConfig } from '../types.ts'
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export { payloadAiPlugin } from './plugin.js'
export { payloadPluginAI } from './plugin.js'
8 changes: 5 additions & 3 deletions src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { InstructionsProvider } from './providers/InstructionsProvider/Instructi
import { translations } from './translations/index.js'
import { updateFieldsConfig } from './utilities/updateFieldsConfig.js'

const payloadAiPlugin =
const payloadPluginAI =
(pluginConfig: PluginConfig) =>
async (incomingConfig: Config): Promise<Config> => {
const collections = [...(incomingConfig.collections ?? []), Instructions]
Expand Down Expand Up @@ -68,10 +68,12 @@ const payloadAiPlugin =
updatedConfig.onInit = async (payload) => {
if (incomingConfig.onInit) await incomingConfig.onInit(payload)

init(payload, collectionsFieldPathMap)
init(payload, collectionsFieldPathMap).catch((error) => {
payload.logger.error(`— AI Plugin: Initialization Error: ${error}`)
})
}

return updatedConfig
}

export { payloadAiPlugin }
export { payloadPluginAI }
5 changes: 2 additions & 3 deletions src/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import type { DocumentInfoContext } from '@payloadcms/ui'
import type { Config, Endpoint, Field, GroupField } from 'payload'
import type { Endpoint, Field, GroupField } from 'payload'

export interface PluginConfig {
collections?: string[]
Expand Down Expand Up @@ -68,7 +67,7 @@ export type UseMenuEvents = {
}

export type BaseItemProps = {
children?: React.ReactNode
hideIcon?: boolean
onClick: () => void
children?: React.ReactNode
}
Loading