1.1.3 • Published 2 years ago

simple-prompt-executer v1.1.3

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Prompt を実行してパースするだけ

使い方サンプル

npm install simple-prompt-executeryarn add simple-prompt-executer でパッケージを入れれます

Node ESM

import { makePromptString, parsePrompt } from "simple-prompt-executer";

const prompt = {
  prompt: `以下の文章から4択クイズを考えてください。`,
  exampleDescription: "パンをテーマにクイズを考えた例です。",
  response: {
    question: {
      example: "パンはパンでも食べられないパンはなんだ",
      description: "クイズの問題",
    },
    selection: {
      example: ["フライパン", "AI", "パンダ", "パン粉"],
      description: "選択肢",
    },
    answer: {
      example: "パン",
      description: "答え",
    },
  },
};
const executer = new PromptExecuter({ openAiApiKey: "sk-xxxx" });
const result = await executer.execute(prompt);
//   ^result = {
// 	question: "クリスマスに隠かくれているものはなーんだ?",
// 	selection: ["リス", "トナカイ", "シカ", "奈良"],
// 	answer: "リス"
// }

// 型がついてるのでこれはエラーになります
result.notExistProperty;

Deno

import { PromptExecuter } from "npm:simple-prompt-executer";

const prompt = {
  prompt: `以下の文章から4択クイズを考えてください。`,
  exampleDescription: "パンをテーマにクイズを考えた例です。",
  response: {
    question: {
      example: "パンはパンでも食べられないパンはなんだ",
      description: "クイズの問題",
    },
    selection: {
      example: ["フライパン", "AI", "パンダ", "パン粉"],
      description: "選択肢",
    },
    answer: {
      example: "パン",
      description: "答え",
    },
  },
};

const executer = new PromptExecuter({ openAiApiKey: "sk-xxxx" });
const result = await executer.execute(prompt);
//   ^result = {
// 	question: "クリスマスに隠かくれているものはなーんだ?",
// 	selection: ["リス", "トナカイ", "シカ", "奈良"],
// 	answer: "リス"
// }

// 型がついてるのでこれはエラーになります
result.notExistProperty;

LLM は自分で決めたい

import { makePromptString, parsePrompt } from "simple-prompt-executer";

const prompt = {
  prompt: `以下の文章から4択クイズを考えてください。`,
  exampleDescription: "パンをテーマにクイズを考えた例です。",
  response: {
    question: {
      example: "パンはパンでも食べられないパンはなんだ",
      description: "クイズの問題",
    },
    selection: {
      example: ["フライパン", "AI", "パンダ", "パン粉"],
      description: "選択肢",
    },
    answer: {
      example: "パン",
      description: "答え",
    },
  },
};

const stringPrompt = makePromptString(prompt);
// ^ stringPrompt = 以下の文章から4択クイズを考えてください。
// [以下のフォーマットで回答してください]
// \`\`\`
// question: クイズの問題
// selection: 選択肢
// answer: 答え
// \`\`\`

// [例]
// パンをテーマにクイズを考えた例です。
// \`\`\`
// question: パンはパンでも食べられないパンはなんだ
// selection: フライパン, AI, パンダ, パン粉
// answer: パン
// \`\`\`

const llmOutput = `Use any llm here`;
const result = parsePrompt(prompt, llmOutput);
//   ^result = {
// 	question: "クリスマスに隠かくれているものはなーんだ?",
// 	selection: ["リス", "トナカイ", "シカ", "奈良"],
// 	answer: "リス"
// }

// 型がついてるのでこれはエラーになります
result.notExistProperty;

Lisence

This project is licensed under the MIT License, see the LICENSE.txt file for details

1.1.3

2 years ago

1.1.2

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago

0.0.15

2 years ago

0.0.14

2 years ago

0.0.13

2 years ago

0.0.12

2 years ago

0.0.11

2 years ago

0.0.10

2 years ago

0.0.9

2 years ago

0.0.8

2 years ago

0.0.7

2 years ago

0.0.6

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago