Skip to content

Commit

Permalink
update: release v1.7.6
Browse files Browse the repository at this point in the history
  • Loading branch information
POPPIN-FUMI committed Nov 7, 2023
1 parent 4906b3d commit 0bf43f2
Show file tree
Hide file tree
Showing 31 changed files with 66 additions and 64 deletions.
7 changes: 5 additions & 2 deletions dist/lib/genPrompt.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { OpenAIPromptParams, VertexPromptParams } from './types';
import { VertexPromptParams } from './types';
import { ChatCompletionMessageParam } from 'openai/resources';
/**
* Represents the AI platforms supported by the generatePrompt function.
*/
Expand Down Expand Up @@ -29,7 +30,9 @@ export interface AIPrompt {
*/
examples: AIExample[];
}
export declare function generatePrompt(context: string, examples: AIExample[], content: string, ai: AIType): VertexPromptParams | OpenAIPromptParams;
export declare function generatePrompt(context: string, examples: AIExample[], content: string, ai: AIType): VertexPromptParams | {
messages: ChatCompletionMessageParam[];
};
export declare const migrationPrompt: {
context: string;
examples: {
Expand Down
2 changes: 1 addition & 1 deletion dist/lib/version.d.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export declare const VERSION = "1.7.5";
export declare const VERSION = "1.7.6";
4 changes: 2 additions & 2 deletions docs/classes/OpenAI-1.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/classes/SkeetAI.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/classes/VertexAI.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/enums/InstanceType.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/enums/NamingEnum.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/enums/SkeetAiMode.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/functions/generatePrompt.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/functions/translate.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions docs/interfaces/AIPrompt.html

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions docs/interfaces/SkeetAIOptions.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/types/AIExample.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/types/AIType.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/types/AiInstance.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/types/Example.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/types/InputOutput.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/types/OpenAIMessage.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/types/OpenAIOptions.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/types/OpenAIPromptParams.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/types/OpenAIRole.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/types/VertexAiOptions.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/types/VertexExample.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/types/VertexExampleMessage.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/types/VertexMessage.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/types/VertexParameterParams.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/types/VertexPromptParams.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@skeet-framework/ai",
"version": "1.7.5",
"version": "1.7.6",
"description": "Skeet Framework Plugin - AI",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
15 changes: 7 additions & 8 deletions src/lib/genPrompt.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { inspect } from 'util'
import { OpenAIPromptParams, VertexExample, VertexPromptParams } from './types'
import { ChatCompletionMessageParam } from 'openai/resources'

/**
* Represents the AI platforms supported by the generatePrompt function.
Expand Down Expand Up @@ -41,7 +42,7 @@ export function generatePrompt(
examples: AIExample[],
content: string,
ai: AIType,
): VertexPromptParams | OpenAIPromptParams {
): VertexPromptParams | { messages: ChatCompletionMessageParam[] } {
if (ai === 'VertexAI') {
const exampleMessages = []
for (const example of examples) {
Expand Down Expand Up @@ -71,14 +72,14 @@ export function generatePrompt(
exampleMessages.push({
role: 'user',
content: example.input,
})
} as ChatCompletionMessageParam)
if (!example.output) continue
exampleMessages.push({
role: 'assistant',
content: example.output,
})
} as ChatCompletionMessageParam)
}
const messages = [
const messages: ChatCompletionMessageParam[] = [
{
role: 'system',
content: context,
Expand All @@ -90,9 +91,7 @@ export function generatePrompt(
},
]

return {
messages,
} as OpenAIPromptParams
return { messages }
} else {
throw new Error('Unsupported AI type')
}
Expand Down Expand Up @@ -156,4 +155,4 @@ export const namingPrompt = {
output: 'fetchLatestNews',
},
],
}
}
28 changes: 14 additions & 14 deletions src/lib/openai/exapmle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,25 @@ const exampleJosn = JSON.parse(
)

const run = async () => {
// const content = 'What is the skeet framework?'
// const prompt = generatePrompt(
// exampleJosn.context,
// exampleJosn.examples,
// content,
// 'OpenAI',
// ) as OpenAIPromptParams
const content = 'What is the skeet framework?'
const prompt = generatePrompt(
exampleJosn.context,
exampleJosn.examples,
content,
'OpenAI',
)
const openAi = new SkeetAI({
ai: 'OpenAI',
model: 'gpt-4-1106-preview',
}).aiInstance as OpenAI
// const result = await openAi.prompt(prompt)
const result = await openAi.prompt(prompt)

// console.log('Question:\n', prompt.messages[3].content)
// console.log('\nAnswer:\n', result)
const content2 =
'The Skeet framework is an open-source full-stack app development solution that aims to lower the development and operation cost of applications. It allows developers to focus more on the application logic and worry less about infrastructure. The framework can be assembled with a combination of SQL and NoSQL.'
const title = await openAi.generateTitle(content2)
console.log('\nGenerated title:\n', title)
console.log('Question:\n', content)
console.log('\nAnswer:\n', result)
// const content2 =
// 'The Skeet framework is an open-source full-stack app development solution that aims to lower the development and operation cost of applications. It allows developers to focus more on the application logic and worry less about infrastructure. The framework can be assembled with a combination of SQL and NoSQL.'
// const title = await openAi.generateTitle(content2)
// console.log('\nGenerated title:\n', title)
}

run()
2 changes: 1 addition & 1 deletion src/lib/version.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const VERSION = '1.7.5'
export const VERSION = '1.7.6'

0 comments on commit 0bf43f2

Please sign in to comment.