Skip to content

Commit

Permalink
Merge pull request #49 from ashbuilds/fix/postgres-db-table-name-issue
Browse files Browse the repository at this point in the history
fix: postgres db table/enum name issue
  • Loading branch information
ashbuilds authored Oct 1, 2024
2 parents 61f1b9c + 6972524 commit 99940a4
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 60 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ai-stack/payloadcms",
"version": "3.0.0-beta.104.3",
"version": "3.0.0-beta.104.4",
"private": false,
"bugs": "https://github.com/ashbuilds/payload-ai/issues",
"repository": "https://github.com/ashbuilds/payload-ai",
Expand Down
16 changes: 9 additions & 7 deletions src/ai/models/anthropic/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@ import { streamText } from 'ai'

import type { GenerationConfig } from '../../../types.js'

import { generateRichText } from './generateRichText.js'
import { defaultSystemPrompt } from '../../prompts.js'
import { generateRichText } from './generateRichText.js'

const MODEL_KEY = 'ANTH-C'

export const AnthropicConfig: GenerationConfig = {
models: [
{
id: 'anthropic-claude-text',
id: `${MODEL_KEY}-text`,
name: 'Anthropic Claude',
fields: ['text', 'textarea'],
handler: async (
Expand All @@ -29,11 +31,11 @@ export const AnthropicConfig: GenerationConfig = {
},
output: 'text',
settings: {
name: 'anthropic-claude-text-settings',
name: `${MODEL_KEY}-text-settings`,
type: 'group',
admin: {
condition(data) {
return data['model-id'] === 'anthropic-claude-text'
return data['model-id'] === `${MODEL_KEY}-text`
},
},
fields: [
Expand All @@ -54,19 +56,19 @@ export const AnthropicConfig: GenerationConfig = {
},
},
{
id: 'anthropic-claude-object',
id: `${MODEL_KEY}-object`,
name: 'Anthropic Claude',
fields: ['richText'],
handler: (text: string, options) => {
return generateRichText(text, options)
},
output: 'text',
settings: {
name: 'anthropic-claude-object-settings',
name: `${MODEL_KEY}-object-settings`,
type: 'group',
admin: {
condition(data) {
return data['model-id'] === 'anthropic-claude-object'
return data['model-id'] === `${MODEL_KEY}-object`
},
},
fields: [
Expand Down
8 changes: 5 additions & 3 deletions src/ai/models/elevenLabs/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,12 @@ if (voiceOptions.length) {
})
}

const MODEL_KEY = '11Labs'

export const ElevenLabsConfig: GenerationConfig = {
models: [
{
id: 'elevenlabs/multilingual-v2',
id: `${MODEL_KEY}-m-v2`,
name: 'ElevenLabs Multilingual v2',
fields: ['upload'],
handler: async (text: string, options) => {
Expand All @@ -119,11 +121,11 @@ export const ElevenLabsConfig: GenerationConfig = {
},
output: 'audio',
settings: {
name: 'elevenlabs-multilingual-v2-settings',
name: `${MODEL_KEY}-settings`,
type: 'group',
admin: {
condition: (data) => {
return data['model-id'] === 'elevenlabs/multilingual-v2'
return data['model-id'] === `${MODEL_KEY}-m-v2`
},
},
fields,
Expand Down
18 changes: 10 additions & 8 deletions src/ai/models/openai/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,19 @@ import { streamText } from 'ai'

import type { GenerationConfig } from '../../../types.js'

import { defaultSystemPrompt } from '../../prompts.js'
import { generateFileNameByPrompt } from '../../utils/generateFileNameByPrompt.js'
import { generateImage } from './generateImage.js'
import { generateRichText } from './generateRichText.js'
import { generateVoice } from './generateVoice.js'
import { defaultSystemPrompt } from '../../prompts.js'

const MODEL_KEY = 'Oai'

//TODO: Simplify this file by moving the handlers to separate files and remove duplicate code
export const OpenAIConfig: GenerationConfig = {
models: [
{
id: 'openai-gpt-text',
id: `${MODEL_KEY}-text`,
name: 'OpenAI GPT Text',
fields: ['text', 'textarea'],
handler: async (
Expand All @@ -33,11 +35,11 @@ export const OpenAIConfig: GenerationConfig = {
},
output: 'text',
settings: {
name: 'openai-gpt-text-settings',
name: `${MODEL_KEY}-text-settings`,
type: 'group',
admin: {
condition(data) {
return data['model-id'] === 'openai-gpt-text'
return data['model-id'] === `${MODEL_KEY}-text`
},
},
fields: [
Expand Down Expand Up @@ -136,7 +138,7 @@ export const OpenAIConfig: GenerationConfig = {
},
output: 'audio',
settings: {
name: 'openai-tts-settings',
name: `${MODEL_KEY}-tts-settings`,
type: 'group',
admin: {
condition(data) {
Expand Down Expand Up @@ -182,19 +184,19 @@ export const OpenAIConfig: GenerationConfig = {
},
},
{
id: 'openai-gpt-object',
id: `${MODEL_KEY}-object`,
name: 'OpenAI GPT',
fields: ['richText'],
handler: (text: string, options) => {
return generateRichText(text, options)
},
output: 'text',
settings: {
name: 'openai-gpt-object-settings',
name: `${MODEL_KEY}-object-settings`,
type: 'group',
admin: {
condition(data) {
return data['model-id'] === 'openai-gpt-object'
return data['model-id'] === `${MODEL_KEY}-object`
},
},
fields: [
Expand Down
49 changes: 8 additions & 41 deletions src/types.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
import type { Collection, Endpoint, Field, GroupField } from 'payload'
import { CSSProperties, MouseEventHandler } from 'react'
import { LexicalBaseNode } from './ai/schemas/lexical.schema.js'
import type { CSSProperties, MouseEventHandler } from 'react'

import type { LexicalBaseNode } from './ai/schemas/lexical.schema.js'

export interface PluginConfig {
collections: {
[key: string]: boolean
}
debugging?: boolean
editorConfig?: { nodes: (typeof LexicalBaseNode)[] }
fields?: Field[]
generatePromptOnInit?: boolean
globals?: string[]
interfaceName?: string
editorConfig?: { nodes: (typeof LexicalBaseNode)[] }
debugging?: boolean
generatePromptOnInit?: boolean
}

export interface GenerationModel {
Expand Down Expand Up @@ -77,44 +78,10 @@ export type BaseItemProps<T = any> = {
children?: React.ReactNode
disabled?: boolean
hideIcon?: boolean
isActive?: boolean
isMenu?: boolean
onClick: (data?: unknown) => void
onMouseEnter?: MouseEventHandler<T> | undefined
onMouseLeave?: MouseEventHandler<T> | undefined
style?: CSSProperties | undefined
isMenu?: boolean
isActive?: boolean
}

/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "plugin-ai-instructions".
*/
export interface PluginAiInstruction {
id: string
'schema-path'?: string | null
'field-type'?: ('text' | 'textarea' | 'upload' | 'richText') | null
'model-id'?: ('openai-gpt-text' | 'dall-e' | 'tts' | 'openai-gpt-object') | null
prompt?: string | null
'openai-gpt-text-settings'?: {
model?: ('gpt-4o' | 'gpt-4-turbo' | 'gpt-4o-mini' | 'gpt-3.5-turbo') | null
}
'dalle-e-settings'?: {
version?: ('dall-e-3' | 'dall-e-2') | null
size?: ('256x256' | '512x512' | '1024x1024' | '1792x1024' | '1024x1792') | null
style?: ('vivid' | 'natural') | null
'enable-prompt-optimization'?: boolean | null
}
'openai-tts-settings'?: {
voice?: ('alloy' | 'echo' | 'fable' | 'onyx' | 'nova' | 'shimmer') | null
model?: ('tts-1' | 'tts-1-hd') | null
response_format?: ('mp3' | 'opus' | 'aac' | 'flac' | 'wav' | 'pcm') | null
speed?: number | null
}
'openai-gpt-object-settings'?: {
model?: ('gpt-4o' | 'gpt-4-turbo' | 'gpt-4o-mini' | 'gpt-4o-2024-08-06') | null
system?: string | null
layout?: string | null
}
updatedAt: string
createdAt: string
}

0 comments on commit 99940a4

Please sign in to comment.