diff --git a/dist/types/src/index.d.ts b/dist/types/src/index.d.ts new file mode 100644 index 00000000..74d5bd86 --- /dev/null +++ b/dist/types/src/index.d.ts @@ -0,0 +1,16 @@ +import aiplatform from '@google-cloud/aiplatform'; +export { aiplatform }; +import * as openai from 'openai'; +export type { ChatCompletionChunk, ChatCompletion } from 'openai/resources/chat'; +export { Stream } from 'openai/streaming'; +export { openai }; +export * from './lib/types/vertexaiTypes'; +export * from './lib/types/openaiTypes'; +export { OpenAI } from './lib/openai'; +export { VertexAI } from './lib/vertexai'; +export { translate } from './lib/translate'; +export { generatePrompt } from './lib/genPrompt'; +export { SkeetAI, type SkeetAIOptions } from './lib/skeetai'; +export type { AIPrompt, AIType, AIExample } from './lib/genPrompt'; +export type { Example, InputOutput, MODEL_PATH } from './lib/types/skeetaiTypes'; +export { NamingEnum } from './lib/types/skeetaiTypes'; diff --git a/dist/types/src/lib/genPrompt.d.ts b/dist/types/src/lib/genPrompt.d.ts new file mode 100644 index 00000000..ef07ecde --- /dev/null +++ b/dist/types/src/lib/genPrompt.d.ts @@ -0,0 +1,46 @@ +import { OpenAIPromptParams, VertexPromptParams } from './types'; +/** + * Represents the AI platforms supported by the generatePrompt function. + */ +export type AIType = 'VertexAI' | 'OpenAI'; +/** + * Represents an example consisting of input and output content. + */ +export type AIExample = { + /** + * The input content for the AI platform. + */ + input: string; + /** + * The expected output content from the AI platform. + */ + output: string; +}; +/** + * Represents the structure of the AI prompt which includes context and examples. + */ +export interface AIPrompt { + /** + * The context or background information for the AI prompt. + */ + context: string; + /** + * An array of examples, each consisting of input and output pairs. + */ + examples: AIExample[]; +} +export declare function generatePrompt(context: string, examples: AIExample[], content: string, ai: AIType): VertexPromptParams | OpenAIPromptParams; +export declare const migrationPrompt: { + context: string; + examples: { + input: string; + output: string; + }[]; +}; +export declare const namingPrompt: { + context: string; + examples: { + input: string; + output: string; + }[]; +}; diff --git a/dist/types/src/lib/openai/exapmle.d.ts b/dist/types/src/lib/openai/exapmle.d.ts new file mode 100644 index 00000000..cb0ff5c3 --- /dev/null +++ b/dist/types/src/lib/openai/exapmle.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/dist/types/src/lib/openai/exapmleFileUpload.d.ts b/dist/types/src/lib/openai/exapmleFileUpload.d.ts new file mode 100644 index 00000000..cb0ff5c3 --- /dev/null +++ b/dist/types/src/lib/openai/exapmleFileUpload.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/dist/types/src/lib/openai/exapmleStream.d.ts b/dist/types/src/lib/openai/exapmleStream.d.ts new file mode 100644 index 00000000..cb0ff5c3 --- /dev/null +++ b/dist/types/src/lib/openai/exapmleStream.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/dist/types/src/lib/openai/index.d.ts b/dist/types/src/lib/openai/index.d.ts new file mode 100644 index 00000000..61af01fa --- /dev/null +++ b/dist/types/src/lib/openai/index.d.ts @@ -0,0 +1 @@ +export * from './openAi'; diff --git a/dist/types/src/lib/openai/openAi.d.ts b/dist/types/src/lib/openai/openAi.d.ts new file mode 100644 index 00000000..13b98a4b --- /dev/null +++ b/dist/types/src/lib/openai/openAi.d.ts @@ -0,0 +1,16 @@ +import { OpenAI as OpenAIApi } from 'openai'; +import { OpenAIOptions, OpenAIPromptParams } from '@/lib/types/openaiTypes'; +import { AIPromptable } from '@/lib/skeetai'; +import { Stream } from 'openai/streaming'; +export declare class OpenAI implements AIPromptable { + private options; + aiInstance: OpenAIApi; + constructor(options?: OpenAIOptions); + prompt(promptParams: any): Promise; + chat(content: string): Promise; + generateTitle(content: string): Promise; + promptStream(prompt: OpenAIPromptParams): Promise>; + uploadFile(filePath: string): Promise; + createFineTuningJob(fileId: string, model?: string): Promise; + showFineTuningJob(jobId: string): Promise; +} diff --git a/dist/types/src/lib/openai/randomChat.d.ts b/dist/types/src/lib/openai/randomChat.d.ts new file mode 100644 index 00000000..52510540 --- /dev/null +++ b/dist/types/src/lib/openai/randomChat.d.ts @@ -0,0 +1,2 @@ +import { OpenAIPromptParams } from '@/lib/types/openaiTypes'; +export declare const randomChat: (content: string) => OpenAIPromptParams; diff --git a/dist/types/src/lib/openai/sytemContexts.d.ts b/dist/types/src/lib/openai/sytemContexts.d.ts new file mode 100644 index 00000000..f653db4e --- /dev/null +++ b/dist/types/src/lib/openai/sytemContexts.d.ts @@ -0,0 +1,2 @@ +export declare const systemContentEN = "### Instructions ###\nGive a title to the content of the message coming from the user. The maximum number of characters for the title is 50 characters. Please make the title as short and descriptive as possible. Do not ask users questions in interrogative sentences. Be sure to respond with only the title. Don't answer questions from users.\nHere are some examples: Never answer user questions.\nExample 1: User's question: [Question] I want to start learning Javascript.\nAnswer: How to start learning Javascript\nExample 2: User's question: [Question] Can you write the code to create the file in Javascript?\nAnswer: How to create a file with JavaScript\nPreferred response format: [content] \n:"; +export declare const systemContentJA = "### \u6307\u793A ###\n\u30E6\u30FC\u30B6\u30FC\u304B\u3089\u6765\u308B\u30E1\u30C3\u30BB\u30FC\u30B8\u306E\u5185\u5BB9\u306B\u30BF\u30A4\u30C8\u30EB\u3092\u3064\u3051\u307E\u3059\u3002\u30BF\u30A4\u30C8\u30EB\u306E\u6587\u5B57\u6570\u306F\u6700\u5927\u306750\u6587\u5B57\u3067\u3059\u3002\u3067\u304D\u308B\u3060\u3051\u77ED\u304F\u308F\u304B\u308A\u3084\u3059\u3044\u30BF\u30A4\u30C8\u30EB\u3092\u3064\u3051\u3066\u304F\u3060\u3055\u3044\u3002\u7591\u554F\u6587\u3067\u30E6\u30FC\u30B6\u30FC\u306B\u306F\u8CEA\u554F\u3057\u306A\u3044\u3067\u304F\u3060\u3055\u3044\u3002\u5FC5\u305A\u30BF\u30A4\u30C8\u30EB\u306E\u307F\u3092\u30EC\u30B9\u30DD\u30F3\u30B9\u3057\u3066\u304F\u3060\u3055\u3044\u3002\u30E6\u30FC\u30B6\u30FC\u304B\u3089\u6765\u308B\u8CEA\u554F\u306B\u306F\u7B54\u3048\u3066\u306F\u3044\u3051\u307E\u305B\u3093\u3002\n\u4EE5\u4E0B\u306B\u3044\u304F\u3064\u304B\u306E\u4F8B\u3092\u793A\u3057\u307E\u3059\u3002\u7D76\u5BFE\u306B\u30E6\u30FC\u30B6\u30FC\u306E\u8CEA\u554F\u306B\u7B54\u3048\u3066\u306F\u3044\u3051\u307E\u305B\u3093\u3002\u3059\u3079\u3066\u82F1\u8A9E\u3067\u30E1\u30C3\u30BB\u30FC\u30B8\u304C\u6765\u305F\u5834\u5408\u306F\u82F1\u8A9E\u306E\u30BF\u30A4\u30C8\u30EB\u3092\u4ED8\u3051\u3066\u304F\u3060\u3055\u3044\u3002\n<\u91CD\u8981>\u30EC\u30B9\u30DD\u30F3\u30B9\u306F\u30BF\u30A4\u30C8\u30EB\u306E\u307F\u3092\u8FD4\u3057\u3066\u304F\u3060\u3055\u3044\u3002\n\u4F8B1: \u30E6\u30FC\u30B6\u30FC\u304B\u3089\u306E\u8CEA\u554F: [\u8CEA\u554F]Javascript\u306E\u52C9\u5F37\u3092\u59CB\u3081\u305F\u3044\u306E\u3067\u3059\u304C\u3001\u3069\u3046\u3059\u308C\u3070\u3044\u3044\u3067\u3059\u304B?\n \u7B54\u3048\uFF1A Javascript\u306E\u52C9\u5F37\u306E\u59CB\u3081\u65B9\n\u4F8B2: \u30E6\u30FC\u30B6\u30FC\u304B\u3089\u306E\u8CEA\u554F: [\u8CEA\u554F]Javascript\u3067\u30D5\u30A1\u30A4\u30EB\u3092\u4F5C\u6210\u3059\u308B\u30B3\u30FC\u30C9\u3092\u66F8\u3044\u3066\u304F\u308C\u307E\u3059\u304B?\n \u7B54\u3048\uFF1A JavaScript\u3067\u30D5\u30A1\u30A4\u30EB\u3092\u4F5C\u6210\u3059\u308B\u65B9\u6CD5\n\u4F8B2: \u30E6\u30FC\u30B6\u30FC\u304B\u3089\u306E\u8CEA\u554F: \u4ECA\u65E5\u30821\u65E5\u304C\u3093\u3070\u308B\u305E!\n \u7B54\u3048\uFF1A \u6C17\u5408\u8868\u660E\n\u4F8B3: \u30E6\u30FC\u30B6\u30FC\u304B\u3089\u306E\u8CEA\u554F: \u3042\u306A\u305F\u306E\u4ECA\u65E5\u306E\u4E88\u5B9A\u306F\uFF1F\n \u7B54\u3048\uFF1A \u4ECA\u65E5\u306E\u4E88\u5B9A\n\u671B\u307E\u3057\u3044\u56DE\u7B54\u30D5\u30A9\u30FC\u30DE\u30C3\u30C8\uFF1A<\u6587\u7AE0\u3092\u8981\u7D04\u3057\u305F\u30BF\u30A4\u30C8\u30EB>\n<\u8CEA\u554F>:"; diff --git a/dist/types/src/lib/skeetai/debug/example1.d.ts b/dist/types/src/lib/skeetai/debug/example1.d.ts new file mode 100644 index 00000000..e97b36f9 --- /dev/null +++ b/dist/types/src/lib/skeetai/debug/example1.d.ts @@ -0,0 +1 @@ +export declare const example1: () => string; diff --git a/dist/types/src/lib/skeetai/debug/index.d.ts b/dist/types/src/lib/skeetai/debug/index.d.ts new file mode 100644 index 00000000..d22a2555 --- /dev/null +++ b/dist/types/src/lib/skeetai/debug/index.d.ts @@ -0,0 +1,4 @@ +import { AIType } from '@/lib/genPrompt'; +import { VertexAI } from '@/lib/vertexai'; +import { OpenAI } from '@/lib/openai'; +export declare const skeetDebug: (content: string, thisAi: AIType, thisAiInstance: VertexAI | OpenAI, debugFile: string) => Promise; diff --git a/dist/types/src/lib/skeetai/debug/prompt.d.ts b/dist/types/src/lib/skeetai/debug/prompt.d.ts new file mode 100644 index 00000000..2c2b8fb5 --- /dev/null +++ b/dist/types/src/lib/skeetai/debug/prompt.d.ts @@ -0,0 +1,7 @@ +export declare const debugPrompt: (tsconfigJson: string, packageJson: string, debugFile: string) => { + context: string; + examples: { + input: string; + output: string; + }[]; +}; diff --git a/dist/types/src/lib/skeetai/fineTune/createFineTuningJob.d.ts b/dist/types/src/lib/skeetai/fineTune/createFineTuningJob.d.ts new file mode 100644 index 00000000..e3397b2b --- /dev/null +++ b/dist/types/src/lib/skeetai/fineTune/createFineTuningJob.d.ts @@ -0,0 +1,4 @@ +import { AIType } from '@/lib/genPrompt'; +import { OpenAI } from '@/lib/openai'; +import { VertexAI } from '@/lib/vertexai'; +export declare const createFineTuningJob: (uploadFileId: string, model: string | undefined, thisAi: AIType, thisAiInstance: VertexAI | OpenAI) => Promise; diff --git a/dist/types/src/lib/skeetai/fineTune/index.d.ts b/dist/types/src/lib/skeetai/fineTune/index.d.ts new file mode 100644 index 00000000..fff7d72f --- /dev/null +++ b/dist/types/src/lib/skeetai/fineTune/index.d.ts @@ -0,0 +1,3 @@ +export * from './uploadFile'; +export * from './createFineTuningJob'; +export * from './showFineTuningJob'; diff --git a/dist/types/src/lib/skeetai/fineTune/showFineTuningJob.d.ts b/dist/types/src/lib/skeetai/fineTune/showFineTuningJob.d.ts new file mode 100644 index 00000000..db810c47 --- /dev/null +++ b/dist/types/src/lib/skeetai/fineTune/showFineTuningJob.d.ts @@ -0,0 +1,4 @@ +import { AIType } from '@/lib/genPrompt'; +import { OpenAI } from '@/lib/openai'; +import { VertexAI } from '@/lib/vertexai'; +export declare const showFineTuningJob: (jobId: string, thisAi: AIType, thisAiInstance: VertexAI | OpenAI) => Promise; diff --git a/dist/types/src/lib/skeetai/fineTune/uploadFile.d.ts b/dist/types/src/lib/skeetai/fineTune/uploadFile.d.ts new file mode 100644 index 00000000..ad38706c --- /dev/null +++ b/dist/types/src/lib/skeetai/fineTune/uploadFile.d.ts @@ -0,0 +1,4 @@ +import { AIType } from '@/lib/genPrompt'; +import { OpenAI } from '@/lib/openai'; +import { VertexAI } from '@/lib/vertexai'; +export declare const uploadJsonlFile: (filePath: string, thisAi: AIType, thisAiInstance: VertexAI | OpenAI) => Promise; diff --git a/dist/types/src/lib/skeetai/firestore/index.d.ts b/dist/types/src/lib/skeetai/firestore/index.d.ts new file mode 100644 index 00000000..9815a3b5 --- /dev/null +++ b/dist/types/src/lib/skeetai/firestore/index.d.ts @@ -0,0 +1,4 @@ +import { AIType } from '@/lib/genPrompt'; +import { VertexAI } from '@/lib/vertexai'; +import { OpenAI } from '@/lib/openai'; +export declare const skeetFirestore: (content: string, thisAi: AIType, thisAiInstance: VertexAI | OpenAI) => Promise; diff --git a/dist/types/src/lib/skeetai/firestore/prompt.d.ts b/dist/types/src/lib/skeetai/firestore/prompt.d.ts new file mode 100644 index 00000000..252b0d94 --- /dev/null +++ b/dist/types/src/lib/skeetai/firestore/prompt.d.ts @@ -0,0 +1,2 @@ +import { AIPrompt } from '@/lib/genPrompt'; +export declare const firestorePrompt: () => AIPrompt; diff --git a/dist/types/src/lib/skeetai/index.d.ts b/dist/types/src/lib/skeetai/index.d.ts new file mode 100644 index 00000000..e6fba63e --- /dev/null +++ b/dist/types/src/lib/skeetai/index.d.ts @@ -0,0 +1,69 @@ +import { OpenAI } from '../openai'; +import { VertexAI } from '../vertexai'; +import { NamingEnum } from '../types/skeetaiTypes'; +/** + * Configuration options for initializing a SkeetAI instance. + */ +export interface SkeetAIOptions { + /** + * AI platform type (either 'VertexAI' or 'OpenAI'). Default is 'VertexAI'. + */ + ai?: 'VertexAI' | 'OpenAI'; + /** + * Model name to be used by the chosen AI platform. Defaults are 'chat-bison@001' for VertexAI and 'gpt-4' for OpenAI. + */ + model?: string; + /** + * Maximum number of tokens to be returned in the response. Default is 1000. + */ + maxTokens?: number; + /** + * Temperature parameter for the AI platform. Default is 0.2. + * @see https://beta.openai.com/docs/api-reference/completions/create#temperature + */ + temperature?: number; +} +export interface AIPromptable { + prompt(input: string): Promise; +} +/** + * The main SkeetAI class for handling AI interactions. + */ +export declare class SkeetAI { + ai: 'VertexAI' | 'OpenAI'; + model: string; + maxTokens: number; + temperature: number; + private _initOptions; + static readonly PRISMA_SCHEMA_PATH: string; + aiInstance: VertexAI | OpenAI; + /** + * Creates an instance of SkeetAI. + * @param options - Configuration options for initializing the SkeetAI. + * @example + * ```typescript + * // Using default settings: + * const defaultSkeet = new SkeetAI(); + * + * // Specifying the AI platform and model: + * const customSkeet = new SkeetAI({ + * ai: 'OpenAI', + * model: 'gpt-4', + * maxTokens: 500 + * }); + * ``` + */ + constructor(options?: SkeetAIOptions); + get initOptions(): SkeetAIOptions; + prisma(content: string): Promise; + skeet(content: string): Promise; + uploadFile(filePath: string): Promise; + createFineTuningJob(fileId: string, model?: string): Promise; + showFineTuningJob(jobId: string): Promise; + typedoc(content: string): Promise; + naming(content: string, namingEnum?: NamingEnum): Promise; + translates(paths: string[], langFrom?: string, langTo?: string): Promise; + firestore(content: string): Promise; + private handleError; +} +export default SkeetAI; diff --git a/dist/types/src/lib/skeetai/naming/index.d.ts b/dist/types/src/lib/skeetai/naming/index.d.ts new file mode 100644 index 00000000..fbc4a40c --- /dev/null +++ b/dist/types/src/lib/skeetai/naming/index.d.ts @@ -0,0 +1,5 @@ +import { AIType } from '@/lib/genPrompt'; +import { VertexAI } from '@/lib/vertexai'; +import { OpenAI } from '@/lib/openai'; +import { NamingEnum } from '../../../lib/types/skeetaiTypes'; +export declare const skeetNaming: (content: string, thisAi: AIType, thisAiInstance: VertexAI | OpenAI, namingEnum: NamingEnum) => Promise; diff --git a/dist/types/src/lib/skeetai/naming/prompt.d.ts b/dist/types/src/lib/skeetai/naming/prompt.d.ts new file mode 100644 index 00000000..64bbd12e --- /dev/null +++ b/dist/types/src/lib/skeetai/naming/prompt.d.ts @@ -0,0 +1,21 @@ +export declare const migrationNamingPrompt: { + context: string; + examples: { + input: string; + output: string; + }[]; +}; +export declare const functionNamingPrompt: { + context: string; + examples: { + input: string; + output: string; + }[]; +}; +export declare const modelNamingPrompt: { + context: string; + examples: { + input: string; + output: string; + }[]; +}; diff --git a/dist/types/src/lib/skeetai/prisma/prisma.d.ts b/dist/types/src/lib/skeetai/prisma/prisma.d.ts new file mode 100644 index 00000000..cde7f27f --- /dev/null +++ b/dist/types/src/lib/skeetai/prisma/prisma.d.ts @@ -0,0 +1,4 @@ +import { OpenAI } from '@/lib/openai'; +import { VertexAI } from '@/lib/vertexai'; +import { AIType } from '@/lib/genPrompt'; +export declare const skeetAiPrisma: (content: string, thisAi: AIType, thisAiInstance: VertexAI | OpenAI) => Promise; diff --git a/dist/types/src/lib/skeetai/prisma/prompt.d.ts b/dist/types/src/lib/skeetai/prisma/prompt.d.ts new file mode 100644 index 00000000..f78047c0 --- /dev/null +++ b/dist/types/src/lib/skeetai/prisma/prompt.d.ts @@ -0,0 +1,2 @@ +import { AIPrompt } from '@/lib/genPrompt'; +export declare const prismaPrompt: () => AIPrompt; diff --git a/dist/types/src/lib/skeetai/skeet/examples/skeet.d.ts b/dist/types/src/lib/skeetai/skeet/examples/skeet.d.ts new file mode 100644 index 00000000..b6cf00a6 --- /dev/null +++ b/dist/types/src/lib/skeetai/skeet/examples/skeet.d.ts @@ -0,0 +1,15 @@ +export declare const skeetPromptVertex: (content: string) => { + context: string; + examples: { + input: { + content: string; + }; + output: { + content: string; + }; + }[]; + messages: { + author: string; + content: string; + }[]; +}; diff --git a/dist/types/src/lib/skeetai/skeet/index.d.ts b/dist/types/src/lib/skeetai/skeet/index.d.ts new file mode 100644 index 00000000..b16db6c2 --- /dev/null +++ b/dist/types/src/lib/skeetai/skeet/index.d.ts @@ -0,0 +1,4 @@ +import { AIType } from '@/lib/genPrompt'; +import { VertexAI } from '@/lib/vertexai'; +import { OpenAI } from '@/lib/openai'; +export declare const skeetPrompt: (content: string, thisAi: AIType, thisAiInstance: VertexAI | OpenAI) => Promise; diff --git a/dist/types/src/lib/skeetai/tranlsate/extractSectionsFromMd.d.ts b/dist/types/src/lib/skeetai/tranlsate/extractSectionsFromMd.d.ts new file mode 100644 index 00000000..c6f530b9 --- /dev/null +++ b/dist/types/src/lib/skeetai/tranlsate/extractSectionsFromMd.d.ts @@ -0,0 +1 @@ +export declare const extractSectionsFromMd: (path: string) => string[]; diff --git a/dist/types/src/lib/skeetai/tranlsate/index.d.ts b/dist/types/src/lib/skeetai/tranlsate/index.d.ts new file mode 100644 index 00000000..343140fc --- /dev/null +++ b/dist/types/src/lib/skeetai/tranlsate/index.d.ts @@ -0,0 +1,4 @@ +import { AIType } from '@/lib/genPrompt'; +import { VertexAI } from '@/lib/vertexai'; +import { OpenAI } from '@/lib/openai'; +export declare const skeetAiTranslates: (paths: string[], langFrom: string, langTo: string, thisAi: AIType, thisAiInstance: VertexAI | OpenAI) => Promise; diff --git a/dist/types/src/lib/skeetai/tranlsate/organizePaths.d.ts b/dist/types/src/lib/skeetai/tranlsate/organizePaths.d.ts new file mode 100644 index 00000000..71cb8d01 --- /dev/null +++ b/dist/types/src/lib/skeetai/tranlsate/organizePaths.d.ts @@ -0,0 +1,5 @@ +export type Paths = { + mdFiles: string[]; + jsonFiles: string[]; +}; +export declare const organizeFilesByExtension: (paths: string[]) => Paths; diff --git a/dist/types/src/lib/skeetai/tranlsate/prompt.d.ts b/dist/types/src/lib/skeetai/tranlsate/prompt.d.ts new file mode 100644 index 00000000..e8d27cc5 --- /dev/null +++ b/dist/types/src/lib/skeetai/tranlsate/prompt.d.ts @@ -0,0 +1,14 @@ +export declare const markdownTranslatePrompt: (langFrom?: string, langTo?: string) => { + context: string; + examples: { + input: string; + output: string; + }[]; +}; +export declare const jsonTranslatePrompt: (langFrom?: string, langTo?: string) => { + context: string; + examples: { + input: string; + output: string; + }[]; +}; diff --git a/dist/types/src/lib/skeetai/tranlsate/translateDocument.d.ts b/dist/types/src/lib/skeetai/tranlsate/translateDocument.d.ts new file mode 100644 index 00000000..f1d61b91 --- /dev/null +++ b/dist/types/src/lib/skeetai/tranlsate/translateDocument.d.ts @@ -0,0 +1,4 @@ +import { AIType } from '@/lib/genPrompt'; +import { VertexAI } from '@/lib/vertexai'; +import { OpenAI } from '@/lib/openai'; +export declare const translateDocument: (content: string, thisAi: AIType, thisAiInstance: VertexAI | OpenAI, mode: 'markdown' | 'json', langFrom?: string, langTo?: string) => Promise; diff --git a/dist/types/src/lib/skeetai/tranlsate/translateJsonDocuments.d.ts b/dist/types/src/lib/skeetai/tranlsate/translateJsonDocuments.d.ts new file mode 100644 index 00000000..2f231088 --- /dev/null +++ b/dist/types/src/lib/skeetai/tranlsate/translateJsonDocuments.d.ts @@ -0,0 +1,5 @@ +import { AIType } from '@/lib/genPrompt'; +import { VertexAI } from '@/lib/vertexai'; +import { OpenAI } from '@/lib/openai'; +export declare const splitContentIntoChunks: (content: string, linesPerChunk: number) => string[]; +export declare const translateJsonDocuments: (paths: string[], langFrom: string | undefined, langTo: string | undefined, ai: AIType, aiInstance: VertexAI | OpenAI) => Promise; diff --git a/dist/types/src/lib/skeetai/typedoc/examples/eslintrc.json.d.ts b/dist/types/src/lib/skeetai/typedoc/examples/eslintrc.json.d.ts new file mode 100644 index 00000000..a636f16e --- /dev/null +++ b/dist/types/src/lib/skeetai/typedoc/examples/eslintrc.json.d.ts @@ -0,0 +1 @@ +export declare const eslintrc: () => string; diff --git a/dist/types/src/lib/skeetai/typedoc/examples/prettierrc.d.ts b/dist/types/src/lib/skeetai/typedoc/examples/prettierrc.d.ts new file mode 100644 index 00000000..fd995f69 --- /dev/null +++ b/dist/types/src/lib/skeetai/typedoc/examples/prettierrc.d.ts @@ -0,0 +1 @@ +export declare const prettierrc: () => string; diff --git a/dist/types/src/lib/skeetai/typedoc/examples/tsconfig.json.d.ts b/dist/types/src/lib/skeetai/typedoc/examples/tsconfig.json.d.ts new file mode 100644 index 00000000..4064a4cc --- /dev/null +++ b/dist/types/src/lib/skeetai/typedoc/examples/tsconfig.json.d.ts @@ -0,0 +1 @@ +export declare const tsconfig: () => string; diff --git a/dist/types/src/lib/skeetai/typedoc/index.d.ts b/dist/types/src/lib/skeetai/typedoc/index.d.ts new file mode 100644 index 00000000..006723e8 --- /dev/null +++ b/dist/types/src/lib/skeetai/typedoc/index.d.ts @@ -0,0 +1,4 @@ +import { AIType } from '@/lib/genPrompt'; +import { VertexAI } from '@/lib/vertexai'; +import { OpenAI } from '@/lib/openai'; +export declare const skeetGenTypedoc: (content: string, thisAi: AIType, thisAiInstance: VertexAI | OpenAI) => Promise; diff --git a/dist/types/src/lib/skeetai/typedoc/prompt.d.ts b/dist/types/src/lib/skeetai/typedoc/prompt.d.ts new file mode 100644 index 00000000..5ae3c156 --- /dev/null +++ b/dist/types/src/lib/skeetai/typedoc/prompt.d.ts @@ -0,0 +1,2 @@ +import { AIPrompt } from '@/lib/genPrompt'; +export declare const typedocPrompt: () => AIPrompt; diff --git a/dist/types/src/lib/translate/example.d.ts b/dist/types/src/lib/translate/example.d.ts new file mode 100644 index 00000000..cb0ff5c3 --- /dev/null +++ b/dist/types/src/lib/translate/example.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/dist/types/src/lib/translate/index.d.ts b/dist/types/src/lib/translate/index.d.ts new file mode 100644 index 00000000..d17b42cb --- /dev/null +++ b/dist/types/src/lib/translate/index.d.ts @@ -0,0 +1 @@ +export * from './translate'; diff --git a/dist/types/src/lib/translate/translate.d.ts b/dist/types/src/lib/translate/translate.d.ts new file mode 100644 index 00000000..bc984fd6 --- /dev/null +++ b/dist/types/src/lib/translate/translate.d.ts @@ -0,0 +1,17 @@ +/** + * Translates the provided text into the specified target language. + * + * @param text - The text to be translated. + * @param target - The target language code for the translation (defaults to 'ja' for Japanese). + * @returns A promise that resolves with the translated string. + * @throws Will throw an error if the translation fails. + * + * @example + * ```typescript + * import { translate } from "@skeet-framework/ai" + * + * const translatedText = await translate("Hello", "es") + * console.log(translatedText); // Outputs: "Hola" + * ``` + */ +export declare const translate: (text: string, target?: string) => Promise; diff --git a/dist/types/src/lib/types/index.d.ts b/dist/types/src/lib/types/index.d.ts new file mode 100644 index 00000000..92e54f9a --- /dev/null +++ b/dist/types/src/lib/types/index.d.ts @@ -0,0 +1,2 @@ +export * from './openaiTypes'; +export * from './vertexaiTypes'; diff --git a/dist/types/src/lib/types/openaiTypes.d.ts b/dist/types/src/lib/types/openaiTypes.d.ts new file mode 100644 index 00000000..0dba0ab8 --- /dev/null +++ b/dist/types/src/lib/types/openaiTypes.d.ts @@ -0,0 +1,18 @@ +export type OpenAIPromptParams = { + messages: OpenAIMessage[]; +}; +export type OpenAIOptions = { + organizationKey?: string; + apiKey?: string; + model?: string; + temperature?: number; + maxTokens?: number; + topP?: number; + n?: number; + stream?: boolean; +}; +export type OpenAIRole = 'function' | 'system' | 'assistant' | 'user'; +export type OpenAIMessage = { + role: OpenAIRole; + content: string; +}; diff --git a/dist/types/src/lib/types/skeetaiTypes.d.ts b/dist/types/src/lib/types/skeetaiTypes.d.ts new file mode 100644 index 00000000..623df056 --- /dev/null +++ b/dist/types/src/lib/types/skeetaiTypes.d.ts @@ -0,0 +1,14 @@ +export type Example = { + context: string; + examples: InputOutput[]; +}; +export type InputOutput = { + input: string; + output: string; +}; +export declare enum NamingEnum { + MIGRATION = "migration", + FUNCTION = "function", + MODEL = "model" +} +export declare const MODEL_PATH = "./functions/skeet/src/models"; diff --git a/dist/types/src/lib/types/vertexaiTypes.d.ts b/dist/types/src/lib/types/vertexaiTypes.d.ts new file mode 100644 index 00000000..6cb39e48 --- /dev/null +++ b/dist/types/src/lib/types/vertexaiTypes.d.ts @@ -0,0 +1,35 @@ +export type VertexPromptParams = { + context: string; + examples: VertexExample[]; + messages: VertexMessage[]; +}; +export type VertexExample = { + input: VertexExampleMessage; + output?: VertexExampleMessage; +}; +export type VertexExampleMessage = { + content: string; +}; +export type VertexMessage = { + author: string; + content: string; +}; +export type VertexParameterParams = { + temperature: number; + maxOutputTokens: number; + topP: number; + topK: number; +}; +export type VertexAiOptions = { + projectId?: string; + location?: string; + apiEndpoint?: string; + model?: string; + publisher?: string; + temperature?: number; + maxOutputTokens?: number; + topP?: number; + topK?: number; + isJapanese?: boolean; + delay?: number; +}; diff --git a/dist/types/src/lib/version.d.ts b/dist/types/src/lib/version.d.ts new file mode 100644 index 00000000..eaf59968 --- /dev/null +++ b/dist/types/src/lib/version.d.ts @@ -0,0 +1 @@ +export declare const VERSION = "1.4.19"; diff --git a/dist/types/src/lib/vertexai/delayedStream.d.ts b/dist/types/src/lib/vertexai/delayedStream.d.ts new file mode 100644 index 00000000..67108f32 --- /dev/null +++ b/dist/types/src/lib/vertexai/delayedStream.d.ts @@ -0,0 +1,9 @@ +/// +import { Readable, ReadableOptions } from 'stream'; +export declare class DelayedStream extends Readable { + data: string[]; + delay: number; + currentIndex: number; + constructor(data: string[], delay: number, options?: ReadableOptions); + _read(): void; +} diff --git a/dist/types/src/lib/vertexai/example.d.ts b/dist/types/src/lib/vertexai/example.d.ts new file mode 100644 index 00000000..cb0ff5c3 --- /dev/null +++ b/dist/types/src/lib/vertexai/example.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/dist/types/src/lib/vertexai/exampleJa.d.ts b/dist/types/src/lib/vertexai/exampleJa.d.ts new file mode 100644 index 00000000..cb0ff5c3 --- /dev/null +++ b/dist/types/src/lib/vertexai/exampleJa.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/dist/types/src/lib/vertexai/genTitle.d.ts b/dist/types/src/lib/vertexai/genTitle.d.ts new file mode 100644 index 00000000..7022d2a5 --- /dev/null +++ b/dist/types/src/lib/vertexai/genTitle.d.ts @@ -0,0 +1,3 @@ +import { VertexPromptParams } from '../types/vertexaiTypes'; +export declare const promptTitleGenerationEn: (content: string) => VertexPromptParams; +export declare const promptTitleGenerationJa: (content: string) => VertexPromptParams; diff --git a/dist/types/src/lib/vertexai/index.d.ts b/dist/types/src/lib/vertexai/index.d.ts new file mode 100644 index 00000000..6c462bb7 --- /dev/null +++ b/dist/types/src/lib/vertexai/index.d.ts @@ -0,0 +1 @@ +export * from './vertexAi'; diff --git a/dist/types/src/lib/vertexai/randomChat.d.ts b/dist/types/src/lib/vertexai/randomChat.d.ts new file mode 100644 index 00000000..d2aeaa17 --- /dev/null +++ b/dist/types/src/lib/vertexai/randomChat.d.ts @@ -0,0 +1,15 @@ +export declare const randomChat: (content: string) => { + context: string; + examples: { + input: { + content: string; + }; + output: { + content: string; + }; + }[]; + messages: { + author: string; + content: string; + }[]; +}; diff --git a/dist/types/src/lib/vertexai/sytemContexts.d.ts b/dist/types/src/lib/vertexai/sytemContexts.d.ts new file mode 100644 index 00000000..f0c5499f --- /dev/null +++ b/dist/types/src/lib/vertexai/sytemContexts.d.ts @@ -0,0 +1,3 @@ +import { VertexPromptParams } from '../types/vertexaiTypes'; +export declare const generateTitlePrompt: (content: string, isJapanese?: boolean) => VertexPromptParams; +export declare const promptTitleGenerationJa: (content: string) => VertexPromptParams; diff --git a/dist/types/src/lib/vertexai/vertexAi.d.ts b/dist/types/src/lib/vertexai/vertexAi.d.ts new file mode 100644 index 00000000..1384ccba --- /dev/null +++ b/dist/types/src/lib/vertexai/vertexAi.d.ts @@ -0,0 +1,63 @@ +/** + * `VertexAI` provides an interface to interact with Google's Vertex AI service. + * This class simplifies the process of making predictions using Vertex AI, allowing + * for easy configuration and prediction. + * + * Usage: + * ```typescript + * const vertexService = new VertexAI({ + * projectId: 'your-project-id', + * location: 'your-location', + * // ... other options + * }); + * + * const prompt = { + * //... your prompt data + * }; + * + * const response = await vertexService.predict(prompt); + * console.log(response); + * ``` + * + * @remarks + * Make sure to set the appropriate environment variables or pass them as options to the constructor. + * + * @class + * @example + * VertexAI + * ```typescript + * import { VertexAI } from '@skeet-framework/ai' + * + * const vertexAi = new VertexAI() + * const result = await vertexAi.chat('Hello') + * console.log(result) + * ``` + * + * OpenAI + * ```typescript + * import { OpenAI } from '@skeet-framework/ai' + * + * const openAi = new OpenAI() + * const result = await openAi.chat('Hello') + * console.log(result) + * ``` + */ +/// +import { VertexAiOptions, VertexParameterParams, VertexPromptParams } from '../types/vertexaiTypes'; +import { AIPromptable } from '@/lib/skeetai'; +export declare class VertexAI implements AIPromptable { + protected options: VertexAiOptions; + protected vertexParams: VertexParameterParams; + constructor(options?: VertexAiOptions); + private initializeOptions; + private initializeVertexParams; + private getEndpoint; + prompt(prompt: any): Promise; + promptStream(prompt: any): Promise; + chat(content: string): Promise; + private validateOptions; + private preparePredictRequest; + private processPredictions; + generateTitlePrompt(content: string, isJapanese?: boolean): Promise; + private handleError; +} diff --git a/docs/classes/OpenAI-1.html b/docs/classes/OpenAI-1.html index 696f4638..6ae00beb 100644 --- a/docs/classes/OpenAI-1.html +++ b/docs/classes/OpenAI-1.html @@ -24,7 +24,7 @@

Implements

  • AIPromptable
+
  • Defined in src/lib/openai/openAi.ts:16
  • @@ -63,19 +63,19 @@

    Parameters

    options: OpenAIOptions = {}

    Returns OpenAI

    +
  • Defined in src/lib/openai/openAi.ts:20
  • Properties

    aiInstance: openai.OpenAI
    +
  • Defined in src/lib/openai/openAi.ts:18
  • options: OpenAIOptions
    +
  • Defined in src/lib/openai/openAi.ts:17
  • Methods

    @@ -90,7 +90,7 @@

    Parameters

    content: string

    Returns Promise<string>

    +
  • Defined in src/lib/openai/openAi.ts:78
    • @@ -105,7 +105,7 @@
      fileId: Optional model: string

    Returns Promise<FineTuningJob>

    +
  • Defined in src/lib/openai/openAi.ts:138
    • @@ -118,7 +118,7 @@

      Parameters

      content: string

    Returns Promise<string>

    +
  • Defined in src/lib/openai/openAi.ts:88
    • @@ -132,7 +132,7 @@
      promptParams: Returns Promise<string>
    +
  • Defined in src/lib/openai/openAi.ts:50
  • Returns Promise<Stream<ChatCompletionChunk>>

    +
  • Defined in src/lib/openai/openAi.ts:111
    • @@ -158,7 +158,7 @@

      Parameters

      jobId: string

    Returns Promise<FineTuningJob>

    +
  • Defined in src/lib/openai/openAi.ts:146
    • @@ -171,7 +171,7 @@

      Parameters

      filePath: string

    Returns Promise<FileObject>

    +
  • Defined in src/lib/openai/openAi.ts:131
  • Returns Promise<undefined | FineTuningJob>

    +
  • Defined in src/lib/skeetai/index.ts:129
    • @@ -161,7 +161,7 @@

      Parameters

      content: string

    Returns Promise<undefined | string>

    +
  • Defined in src/lib/skeetai/index.ts:175
    • @@ -174,7 +174,7 @@

      Parameters

      error: any

    Returns void

    +
  • Defined in src/lib/skeetai/index.ts:183
    • @@ -189,7 +189,7 @@
      content: namingEnum: NamingEnum = NamingEnum.FUNCTION

    Returns Promise<undefined | string>

    +
  • Defined in src/lib/skeetai/index.ts:153
    • @@ -202,7 +202,7 @@

      Parameters

      content: string

    Returns Promise<undefined | string>

    +
  • Defined in src/lib/skeetai/index.ts:105
    • @@ -215,7 +215,7 @@

      Parameters

      jobId: string

    Returns Promise<undefined | FineTuningJob>

    +
  • Defined in src/lib/skeetai/index.ts:137
    • @@ -228,7 +228,7 @@

      Parameters

      content: string

    Returns Promise<string>

    +
  • Defined in src/lib/skeetai/index.ts:113
    • @@ -245,7 +245,7 @@
      langFrom: langTo: string = 'en'

    Returns Promise<void>

    +
  • Defined in src/lib/skeetai/index.ts:161
    • @@ -258,7 +258,7 @@

      Parameters

      content: string

    Returns Promise<undefined | string>

    +
  • Defined in src/lib/skeetai/index.ts:145
    • @@ -271,7 +271,7 @@

      Parameters

      filePath: string

    Returns Promise<undefined | FileObject>

    +
  • Defined in src/lib/skeetai/index.ts:121
  • Returns Promise<string>

    +
  • Defined in src/lib/vertexai/vertexAi.ts:148
    • @@ -109,7 +109,7 @@
      content: isJapanese: boolean = false

    Returns Promise<VertexPromptParams>

    +
  • Defined in src/lib/vertexai/vertexAi.ts:188
  • +
  • Defined in src/lib/vertexai/vertexAi.ts:96
    • @@ -130,7 +130,7 @@

      Parameters

      error: any

    Returns never

    +
  • Defined in src/lib/vertexai/vertexAi.ts:195
  • Returns VertexAiOptions

    +
  • Defined in src/lib/vertexai/vertexAi.ts:73
  • Returns VertexParameterParams

    +
  • Defined in src/lib/vertexai/vertexAi.ts:85
  • Returns Promise<{
        endpoint: string;
        instanceValue: any;
        parameters: any;
    }>

    +
  • Defined in src/lib/vertexai/vertexAi.ts:173
    • @@ -182,7 +182,7 @@

      Parameters

      response: any

    Returns Promise<string>

    +
  • Defined in src/lib/vertexai/vertexAi.ts:181
  • +
  • Defined in src/lib/vertexai/vertexAi.ts:100
    • @@ -209,7 +209,7 @@

      Parameters

      prompt: any

    Returns Promise<Readable>

    +
  • Defined in src/lib/vertexai/vertexAi.ts:123
  • +
  • Defined in src/lib/vertexai/vertexAi.ts:158
  • +
  • Defined in src/lib/types/skeetaiTypes.ts:14
  • +
  • Defined in src/lib/genPrompt.ts:39
  • +
  • Defined in src/lib/translate/translate.ts:22
  • +
  • Defined in src/lib/genPrompt.ts:36
  • +
  • Defined in src/lib/skeetai/index.ts:41
  • +
  • Defined in src/lib/genPrompt.ts:12
  • +
  • Defined in src/lib/genPrompt.ts:7
  • +
  • Defined in src/lib/types/skeetaiTypes.ts:1
  • +
  • Defined in src/lib/types/skeetaiTypes.ts:6
  • +
  • Defined in src/lib/types/openaiTypes.ts:18
  • +
  • Defined in src/lib/types/openaiTypes.ts:5
  • +
  • Defined in src/lib/types/openaiTypes.ts:1
  • +
  • Defined in src/lib/types/openaiTypes.ts:16
  • +
  • Defined in src/lib/types/vertexaiTypes.ts:28
  • +
  • Defined in src/lib/types/vertexaiTypes.ts:7
  • +
  • Defined in src/lib/types/vertexaiTypes.ts:12
  • +
  • Defined in src/lib/types/vertexaiTypes.ts:16
  • +
  • Defined in src/lib/types/vertexaiTypes.ts:21
  • +
  • Defined in src/lib/types/vertexaiTypes.ts:1
  • +
  • Defined in src/lib/types/skeetaiTypes.ts:17