OpenAI::Completions - OpenAI Completions スクレイパー

スクレイパーの概要

OpenAI Completions スクレイパー。OpenAIのCompletionsメソッド用スクレイパーです。公式APIに基づいて作成されており、APIキーを使用します。
OpenAI::ChatGPT スクレイパーと似ていますが、主な違いは System prompt content オプションがないことと、生成に使用されるモデルのタイプが異なることです。
A-Parserの機能により、このスクレイパーのスクレイピング設定を後で再利用するために保存(プリセット)したり、スクレイピングのスケジュールを設定したりすることが可能です。クエリの自動増殖、ファイルからのサブクエリの挿入、英数字の組み合わせやリストの総当たりを利用して、最大限の結果を取得できます。
内蔵された強力なテンプレートエンジン Template Toolkit により、結果に独自のロジックを適用し、JSON、SQL、CSVなどの様々な形式でデータを保存・構造化することが可能です。
収集データ
- OpenAIからの回答
- 使用されたトークン数
機能
- OpenAIからの回答をスクレイピングする
ユースケース
- あらゆる質問に対するOpenAIからの回答生成
クエリ
クエリとして、1行のテキストを指定する必要があります。例:
What are 5 key points I should know when studying Ancient Rome?
クエリの置換
クエリを増殖させるために、内蔵マクロを使用できます。
クエリ形式で a から zzzz までの文字の総当たりを指定すると、検索結果を最大限にローテーションさせ、多くの新しいユニークな結果を得ることができます:
$query {az:a:zzzz}
このマクロは、元の検索クエリごとに 475254 個の追加クエリを作成し、合計で 4 x 475254 = 1901016 個の検索クエリになります。これは膨大な数字ですが、A-Parserにとっては全く問題ありません。毎分 2000 クエリの速度であれば、このタスクは約 16 時間で処理されます。
結果の出力例
A-Parserは、内蔵のテンプレートエンジン Template Toolkit により柔軟な結果フォーマットをサポートしており、任意の形式やCSV、JSONなどの構造化された形式で結果を出力できます。
デフォルト出力
結果フォーマット:
Used tokens: $total_tokens, Answer:\n$answer\n
結果の例:
Used tokens: 290, Answer:
1. Founding and Early History: Ancient Rome was founded in 753 BCE by twin brothers Romulus and Remus. The city grew to become one of the most powerful and influential empires in world history.
2. Roman Republic: The Roman Republic was established in 509 BCE and lasted until 27 BCE. During this time, Rome developed a complex system of government, with two consuls elected annually, a senate, and assemblies of citizens.
3. Roman Empire: The Roman Empire began in 27 BCE when Augustus became the first Roman emperor. The empire grew to include much of Europe, the Middle East, and North Africa and lasted until the fall of the Western Roman Empire in 476 CE.
4. Achievements and Contributions: Ancient Rome made significant contributions to architecture, engineering, law, philosophy, art, literature, and language. Roman innovations include the arch, concrete, aqueducts, roads, and the Latin alphabet.
5. Decline and Fall: The Roman Empire faced numerous challenges, including economic instability, political corruption, military defeats, and invasions by barbarian tribes. The Western Roman Empire fell in 476 CE, while the Eastern Roman Empire (Byzantine Empire) survived until 1453 CE.
可能な設定
| パラメーター | デフォルト値 | 説明 |
|---|---|---|
| API domain | api.openai.com | APIリクエストのドメインを変更する機能 |
| API key | APIキー。複数指定可能(1行に1つ)。各試行ごとに、利用可能で現在のクエリ内で未使用のキーからランダムに選択されます。 | |
| Model name | text-davinci-003 | モデルのタイプ (gpt-3.5-turbo-instruct / babbage-002 / davinci-002 / text-davinci-003) |
| Temperature | 0.7 | Temperature |
| Top P | 1 | Top P |
| Maximum length | 256 | 使用するトークンの最大数 |
| Presence penalty | 0 | Presence penalty |
| Frequency penalty | 0 | Frequency penalty |