JavaのOpenAI APIライブラリを使ってみる

JavaのOpenAI APIライブラリの[openai-java](https://github.com/TheoKanning/openai-java)を使ってみます。

機能の確認が主目的なのでコードのきれいさなどはあまり推敲できてません。

参考：OpenAI APIリファレンスhttps://platform.openai.com/docs/api-reference


# ライブラリのインポート

```:pom.xml
    <dependency>
      <groupId>com.theokanning.openai-gpt3-java</groupId>
      <artifactId>service</artifactId>
      <version>0.14.0</version>
    </dependency>
```

# 文章補完

与えた文章から、その続きを補完した文章を生成してくれます。

```java
public class App {
    public static void main(String[] args) {
        var service = new OpenAiService("Your Openai API Key"); // ご自身のキーに書き換えてください
        chatGptCompletion(service, "Somebody once told me the world is gonna roll me");
    }
    static void chatGptCompletion(OpenAiService service, String message) {
        var completionRequest = CompletionRequest.builder()
                .prompt(message)
                .model("ada")
                .echo(true)
                .build();
        service.createCompletion(completionRequest)
                .getChoices()
                .stream()
                .map(CompletionChoice::getText)
                .forEach(System.out::println);
    }
}
```
```:出力
Somebody once told me the world is gonna roll me over. It sure is [tweaking] right now.

When
```

# チャット対話

ChatGPTのように対話をします。
前の回答までの会話の文脈を考慮します。（今までの質問内容を繰り返し再投稿するので会話が長引くと使用料金が嵩みそうです）
返ってきたトークンごとに逐次的に画面出力するようにしてます。
「おわり」と入力すると会話を終了します。

```java
public class App {
    public static void main(String[] args) {
        var service = new OpenAiService("Your Openai API Key"); // ご自身のキーに書き換えてください
        chatGptChatStart(service);
        service.shutdownExecutor();
    }

    static void chatGptChatStart(OpenAiService service) {
        try (Scanner scan = new Scanner(System.in)) {
            List<ChatMessage> chatMessages = new ArrayList<>();
            chatMessages.add(new ChatMessage(ChatMessageRole.SYSTEM.value(), "あなたは便利なアシスタントです"));
            while (true) {
                System.out.println("質問を入力してください");
                String userMsg = scan.nextLine();
                if (userMsg.equals("おわり")) return;
                System.out.println();
                chatMessages.add(new ChatMessage(ChatMessageRole.USER.value(), userMsg));

                String replyMsg = chatGptChatStream(service, chatMessages);
                chatMessages.add(new ChatMessage(ChatMessageRole.ASSISTANT.value(), replyMsg));
            }
        }
    }
    static String chatGptChatStream(OpenAiService service, List<ChatMessage> chatMessages) {
        var chatCompletionRequest = ChatCompletionRequest.builder()
                .messages(chatMessages)
                .model("gpt-3.5-turbo")
                .stream(true)
                .build();
        String replyMsg = service.streamChatCompletion(chatCompletionRequest)
                .map(ChatCompletionChunk::getChoices)
                .flatMap(Flowable::fromIterable)
                .filter(choice -> choice.getIndex() == 0)
                .takeWhile(choice -> !"stop".equals(choice.getFinishReason()))
                .map(ChatCompletionChoice::getMessage)
                .filter(chatMessage -> chatMessage.getContent() != null)
                .map(ChatMessage::getContent)
                .doOnNext(System.out::print)
                .collect(StringBuilder::new, StringBuilder::append)
                .map(StringBuilder::toString)
                .blockingGet();
        System.out.println("\n");
        return replyMsg;
    }
}
```

```:出力
質問を入力してください
こんにちは

こんにちは！何かお手伝いできることがありますか？

質問を入力してください
javaとは何ですか？

Javaは、オブジェクト指向プログラミング言語であり、1995年にサン・マイクロシステムズによって開発されました。Javaは、一般的なアプリケーションソフトウェア
やWebアプリケーション、Androidアプリケーションなど、様々な目的で使用されます。

Javaは、プログラマがコンピュータで動作するプログラムを開発する際に使用できる、豊富なクラスライブラリーを提供しています。また、Javaの特徴の一つとして、
プログラムが様々なプラットフォームで動作し、Java仮想マシン（JVM）上で実行されるため、プログラムが特定のプラットフォームに依存しないことが挙げられます
。

質問を入力してください
先ほどの回答をもう少し短い文章に要約してください。 

Javaは、オブジェクト指向プログラミング言語であり、サン・マイクロシステムズによって開発され、様々なプラットフォームで動作することができます。豊富なクラ
スライブラリーを提供し、一般的なアプリケーションやWebアプリケーション、Androidアプリケーションの開発に使用されます。

質問を入力してください
おわり
```

# 画像生成

## テキスト to 画像

入力テキストから画像を生成してくれます。
生成モデルはDALL-Eを使用します。

```java
public class ImageApp {
    public static void main(String[] args) {
        var service = new OpenAiService("Your Openai API Key"); // ご自身のキーに書き換えてください

        createImage(service, "かわいい子猫");
    }

    static void createImage(OpenAiService service, String prompt) {
        var imgRequest = CreateImageRequest.builder()
                .prompt(prompt)
                .n(2)
                .size("256x256")
                .responseFormat("url")
                .build();
        service.createImage(imgRequest)
                .getData()
                .stream()
                .map(Image::getUrl)
                .forEach(System.out::println);
    }
}
```

```:出力
https://oaidalleapiprodscus.blob.core.windows.net/private/org-Cyn1sCatifBlvU9j7FymRFuh/user-uOUXOKLjf9RDKUUa8QrBvIk8/img-pPD8fFXeyBmBBAWC8drygAH1.png?st=2023-07-03T11%3A44%3A43Z&se=2023-07-03T13%3A44%3A43Z&sp=r&sv=2021-08-06&sr=b&rscd=inline&rsct=image/png&skoid=6aaadede-4fb3-4698-a8f6-684d7786b067&sktid=a48cca56-e6da-484e-a814-9c849652bcb3&skt=2023-07-02T20%3A31%3A30Z&ske=2023-07-03T20%3A31%3A30Z&sks=b&skv=2021-08-06&sig=NoohiYpEBKX5rYnJ4gQR9dPawuB4w/bKRbc5Tfyc5j0%3D
https://oaidalleapiprodscus.blob.core.windows.net/private/org-Cyn1sCatifBlvU9j7FymRFuh/user-uOUXOKLjf9RDKUUa8QrBvIk8/img-Fg18hYkhTnrD6mPIVMQP6Dx6.png?st=2023-07-03T11%3A44%3A43Z&se=2023-07-03T13%3A44%3A43Z&sp=r&sv=2021-08-06&sr=b&rscd=inline&rsct=image/png&skoid=6aaadede-4fb3-4698-a8f6-684d7786b067&sktid=a48cca56-e6da-484e-a814-9c849652bcb3&skt=2023-07-02T20%3A31%3A30Z&ske=2023-07-03T20%3A31%3A30Z&sks=b&skv=2021-08-06&sig=A88QG1gIrJd7ttACciBOqYCbTFV%2BWmRBjakZZcAH5To%3D
```

出力画像

![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/3123353/44199f50-636c-7f09-6648-8ff20e1284a9.png)

![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/3123353/ff56560e-df52-e0a4-8e4b-a56167577045.png)


## 画像 to 画像

入力画像から、それに似た別の画像を生成してくれます。
ライブラリの問題か、出力画像サイズを1024x1024の時にタイムアウトエラーになるときがありました。

```java
public class ImageApp {
    public static void main(String[] args) {
        var service = new OpenAiService("Your Openai API Key"); // ご自身のキーに書き換えてください

        variateImage(service, "img-36cA7HsodtiTuqxCfLCcNs8h_alpha.png");
    }

    static void variateImage(OpenAiService service, String image) {
        var variateImgRequest = CreateImageVariationRequest.builder()
                .size("256x256")
                .responseFormat("url")
                .build();
        service.createImageVariation(variateImgRequest, image)
                .getData()
                .stream()
                .map(Image::getUrl)
                .forEach(System.out::println);;
    }
}
```

```:出力
https://oaidalleapiprodscus.blob.core.windows.net/private/org-Cyn1sCatifBlvU9j7FymRFuh/user-uOUXOKLjf9RDKUUa8QrBvIk8/img-ya4HCwPCKcMCVHo8TEr2ystt.png?st=2023-07-03T11%3A52%3A40Z&se=2023-07-03T13%3A52%3A40Z&sp=r&sv=2021-08-06&sr=b&rscd=inline&rsct=image/png&skoid=6aaadede-4fb3-4698-a8f6-684d7786b067&sktid=a48cca56-e6da-484e-a814-9c849652bcb3&skt=2023-07-02T20%3A32%3A04Z&ske=2023-07-03T20%3A32%3A04Z&sks=b&skv=2021-08-06&sig=U6rUWXdkhVIC1WRTMn0inTV5%2BFdGPo1Oa%2BXyPkteJe0%3D
```

入力画像

![img-36cA7HsodtiTuqxCfLCcNs8h_alpha.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/3123353/f72e285d-04b0-b482-1f43-86df0fde51d9.png)

出力画像

![img-ya4HCwPCKcMCVHo8TEr2ystt.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/3123353/381f7a51-efe8-5643-8450-d74628bc0e20.png)


# 音声テキスト抽出

音声ファイルを入力すると、その音声での発言内容をテキストにしてくれます。

生成モデルはwhisper-1を使用します。

似た機能として抽出テキストを英語に翻訳したものを出力してくれるAPIもありました。

```java
public class AudioApp {
    public static void main(String[] args) {
        var service = new OpenAiService("Your Openai API Key"); // ご自身のキーに書き換えてください

        System.out.println("抽出テキスト：" + transcriptAudio(service, "レコーディング.m4a"));
        System.out.println();
        System.out.println("抽出テキストを英語に翻訳：" + translateAudio(service, "レコーディング.m4a"));
    }

    static String transcriptAudio(OpenAiService service, String filePath) {
        var transcriptionRequest = CreateTranscriptionRequest.builder()
                .model("whisper-1")
                .build();
        return service.createTranscription(transcriptionRequest, filePath)
                .getText();
    }

    static String translateAudio(OpenAiService service, String filePath) {
        var translateRequest = CreateTranslationRequest.builder()
                .model("whisper-1")
                .build();
        return service.createTranslation(translateRequest, filePath)
                .getText();
    }
}
```

入力した音声ファイルは「こんにちは DX戦2グループの三浦弘太郎です よろしくお願いします」と私が話したのを録音したファイルです。

```:出力
抽出テキスト：こんにちは DX1000IIグループの三浦幸太郎です よろしくお願いします

抽出テキストを英語に翻訳：Hello, I'm Kotaro Miura from DX-1000II group. Nice to meet you.
```

# Embeddings

テキストをベクトルデータに埋め込みます。
このデータはベクターデータベースなどに格納して全文検索やレコメンデーションなどに使えるそうです。
テキストのトークン数も出力してくれました。
埋め込みモデルはtext-embedding-ada-002を使用します。

```java
public class EmbeddingApp {
    public static void main(String[] args) {
        var service = new OpenAiService("Your Openai API Key"); // ご自身のキーに書き換えてください

       var embdReq = EmbeddingRequest.builder()
                .model("text-embedding-ada-002")
                .input(List.of("チャットボット", "豆蔵のMZbot"))
                .build();
        EmbeddingResult res = service.createEmbeddings(embdReq);

        System.out.println("ベクトル一覧");
        res.getData().stream().map(Embedding::getEmbedding).forEach(System.out::println);

        System.out.println();
        Usage usage = res.getUsage();
        System.out.println("プロンプトトークン：" + usage.getPromptTokens() + "、合計トークン：" + usage.getTotalTokens());
    }
}
```

```:出力
ベクトル一覧
[-0.03690111, -0.017665999, -0.0046227835, 0.009292911, 0.011822422, 0.005586568, -0.0154476045, -0.002477095, -0.0017263577, -0.014365461, -0.01265432, 0.014947113, -0.010523849, -0.009881327, -0.017341357, -0.0016096891, 0.0068783774, -3.4303116E-4, 0.038389057, -0.029786011, 0.01529881, 0.02057426, 0.009333491, -0.011146083, -0.017260196, -0.01951917, 0.015285282, -0.03849727, -0.0059889904, -0.0044334084, 0.027838152, -0.018612875, -0.010496796, -0.015122961, -0.019045733, -0.010097755, 0.0029150252, 0.010997288, 0.019356849, 0.0094958125, 0.03149039, 0.0072706547, 0.012397312, 0.005901066, -0.028135741, 0.0154205505, -0.030732887, 2.390439E-4, 0.0054580634, 0.0052653067, 0.0048797927, 0.003794267, -0.030868156, -0.0039396803, 0.007845543, 0.011105502, -0.007926704, 0.014378987, 7.363651E-4, -0.0046464554, 0.007832017, 0.011457198, -0.0285686, 0.015285282, -0.0028998074, 0.003537258, -0.024010068, 0.014717157, -0.0018109002, -0.010976997, 0.007074516, 0.018694036, 0.018829305, -0.03993111, 0.039200664, 0.02053368, -0.018369393, 0.0036894344, 0.0016088437, -0.009056192, 0.018491134, -0.003368173, 0.018666983, -0.014852425, 0.018031223, 0.0039126268, 2.8585931E-5, 0.01774716, 0.0031145455, -0.017260196, 0.012086195, 0.0065976963, -3.0562113E-4, 0.019870868, -0.0060735326, 0.0017939917, 
-0.005248398, 0.0293261, 0.006442138, -0.030245923, 0.0034628606, -0.009854273, -0.046369866, -0.0030519841, -0.025159847, 0.013323897, 0.023184933, 0.00851512, 0.010456216, -0.003095946, -0.00662475, 0.046261653, -0.0050488776, -0.032437265, -0.025552124, -0.0084880665, 0.020980066, -0.0140408175, -0.026066141, -0.03706343, 0.0024838585, 0.016421534, 0.011592466, -0.018450554, 0.030570565, 0.023550157, -0.029515475, -9.147498E-4, 0.0027899023, 9.790021E-4, 0.023955962, -0.01744957, 0.027053598, 0.005495262, -0.015082381, 0.012958674, -0.028785028, 0.007771146, -0.017057294, 0.0015065472, 0.009691952, 0.030272976, -0.01130164, 0.0021981047, -0.004582203, 0.023590738, 0.018437026, 0.008893871, 0.019248635, 0.0184235, 0.013492982, -0.016367426, 0.021250602, 0.0018379538, 0.007960522, 0.012431128, 0.023780113, 0.020682476, 0.0013180175, -0.022332745, -0.012282333, 0.016408008, 0.01905926, -0.023009084, 0.015434078, 0.03046235, -0.013547089, 0.015190595, 9.828065E-5, 0.0044198814, -0.0139596565, 0.015271756, -0.0019224962, 0.013662067, -0.0054208646, 0.0042305063, -0.0070204088, -0.0054343916, -5.228953E-4, -0.0147577375, -0.04052629, -0.017354883, -0.00957021, 0.0078252535, 0.0031517441, -0.0043657743, -0.0054141013, -0.0014617398, 0.021521138, -0.002872754, 0.024997525, 0.03941709, 0.018450554, -0.0075750076, -0.6324049, -0.035927176, 0.0026546342, 0.012174119, 0.0056812554, 0.01732783, -0.0046599824, 0.008095789, -0.02116944, 0.021372342, -0.012789588, 0.015244703, -0.013168339, -0.005089458, 0.019153947, -0.0071759666, 0.01191711, -0.023577211, 0.012498762, 0.012863986, -0.013317133, 0.01201856, -0.031084584, 6.742264E-4, -0.016462114, -0.013229209, 0.011423382, 0.011673627, -0.008298691, 0.0085692275, -0.023563683, 0.025038105, 0.014460148, -0.03625182, 0.059085056, 0.0044435533, -0.027040072, 0.024983998, -0.0036961979, 0.01981676, -0.03549432, -0.033330034, 0.0069223396, 0.0045450046, 0.010273604, -0.008738312, 0.004991389, -0.026972437, -0.01086202, -0.011362511, -0.0015868626, -0.011484252, 0.021142386, -0.008393379, 0.017720107, 0.00616822, 0.0360895, -0.016218632, 9.325037E-4, -0.010557666, -0.016637962, 0.007967285, -0.02598498, -0.021331763, -0.014433094, 0.006546971, -0.013810862, -0.013729701, 
0.009448469, -0.009407889, 0.0040580397, -0.013919076, 0.0034611698, 0.005035351, 0.016340373, 0.031165745, 0.024321185, -0.016962606, -0.011206953, 0.012140302, -0.0029691323, -0.007223311, -0.0055730413, -0.008244584, 0.02070953, -0.014027291, -0.043718614, -0.015772248, 0.009022375, 0.0052619246, 0.011193426, 0.03511557, -0.024023594, -0.010577957, -0.0129722, 0.0019208054, -0.012424365, -0.005508789, -0.0018903702, -0.012823406, -0.0074059223, -0.0051232753, 0.029488422, 0.032301996, 0.019289216, -0.0019444773, -0.03397932, 0.009482286, 0.013432112, -0.009901617, 0.016556801, 0.010138336, 0.005529079, -0.03338414, 0.01229586, -0.025795605, 0.025119266, -0.0047681965, 0.022697968, -0.024199443, 0.028785028, -0.018477608, 0.0147036305, 
0.0038348476, 0.005437773, 0.013486219, 2.4749816E-4, -0.012559633, 0.0062629078, 0.008663915, 2.4284831E-4, -0.020398414, 0.00921175, -0.0089412145, 0.024064176, -0.0063237785, 0.018152963, -0.009637844, 0.008623335, 0.0053464673, -0.0121808825, -0.011720971, 0.0069020493, 0.006533444, -0.016624436, -0.033302978, 0.004260942, 0.0039227717, -0.015582873, 0.014730684, 0.020777164, -0.0012596832, 0.0015276829, 0.029055564, 0.0047343797, -0.019208055, -0.016123945, -0.0139596565, 0.008562463, -0.016962606, 0.010030122, -0.0028101925, 0.0055798045, 0.0054208646, -0.015122961, 5.99829E-4, -0.018666983, 0.017422518, -0.017057294, -0.030327084, 0.0032058514, -0.0056102397, -0.006881759, 0.009921907, 0.0066484218, 0.0047343797, -0.008542174, -0.006181747, 0.0075952974, -0.017598366, -0.0020205656, 0.031111637, -0.0032684128, -0.022954978, 0.019627385, -0.0019174238, 0.023671899, 0.022386853, -0.015028274, 0.005241635, -0.015461131, 0.020668948, 0.007128623, 0.019857341, 0.033194765, -0.008907397, 0.016150998, 0.0040614214, 0.014500729, 0.012498762, 0.021480557, 0.020980066, 0.010219497, -0.03249137, 0.0013019544, -0.039714683, -0.008298691, -0.008677442, 0.03284307, -0.0022251585, -8.602199E-4, -6.890213E-4, -0.010097755, 9.7223866E-4, 0.027161812, 0.015515238, -0.012032088, 0.012573159, -0.018220598, 0.015772248, 0.01943801, -0.023049666, -0.0016384335, -0.028027527, 0.011477489, 0.007297708, -0.007987575, 0.02699949, 0.012417601, -0.0067295823, -9.418034E-4, -0.0073044715, 0.0067938347, 0.0016037711, 0.02429413, -0.04496308, 0.011612757, -0.015325863, 0.050049156, 0.024794623, -0.011964453, -0.0026005271, 0.01229586, -0.0059179747, 0.025349222, 0.013526799, 0.050914872, -0.0029488422, -0.0038686646, -6.5520435E-4, -0.041229684, -0.011666864, -0.031544495, -0.0025126028, 0.019546224, -0.011281351, 0.01265432, 0.00887358, 0.009962487, 0.028379224, 0.013892023, 0.034249853, -0.012532579, 0.019789707, 0.009935434, -0.01500122, 0.006198656, -0.0018075185, -0.023130827, -0.024781095, 0.0015970077, -0.0035541665, 7.9892656E-5, -0.016123945, 0.026417838, 0.0019377139, -0.010713225, 0.019938502, 0.01022626, 0.0059619364, -0.010645591, -0.03525084, 0.0053126505, -0.012816642, -0.007331525, -0.0046024933, -0.021561718, 0.0019799853, -0.011328694, -0.004233888, -0.013553852, 0.01800417, 0.011734498, 7.799045E-4, -0.0031906336, 0.009583737, -5.867249E-4, -0.022968505, -0.036874052, -0.021710513, 0.016178051, 0.012397312, -0.008521884, -0.018328812, 0.011504542, -0.009773112, -0.030029494, -0.016583856, -0.025525069, -0.024104755, -0.002105108, 1.835629E-4, -0.008616571, -0.012241753, -0.011369275, 0.025795605, 0.025132792, -0.017638946, 0.015271756, 8.919233E-4, -0.015893988, -0.0073788688, -0.022643862, -0.014000237, 0.011389565, -0.003457788, 0.02003319, 0.015068854, -0.01362825, -0.014879479, -0.02598498, -0.01951917, -2.0488345E-5, -0.015407024, -0.008109316, -0.0033056114, 0.018964572, -0.002444969, -0.0023468996, -0.010713225, 9.0291386E-4, -0.01432488, 0.031192798, -0.026309624, 0.020668948, 0.004771578, -0.003016476, -0.011734498, -8.521883E-4, -0.0029336244, -0.017923009, 0.030435298, -0.0015200741, -0.04458433, 0.009117062, 0.016827337, -0.017436044, -0.0025041488, -0.003288703, 0.020804217, -0.008907397, 0.049589247, -0.013635013, 0.007757619, 0.025809132, 0.030056547, 0.0063677407, -0.007108333, 0.00823782, -0.028785028, 0.019762654, 0.016137471, -0.0071150963, -0.024145337, 0.02079069, 0.012289097, -0.04731674, 0.0032836304, -0.010327711, 0.04231183, -0.013709411, 0.004369156, 0.0021811964, -4.8442848E-4, -0.009238804, -0.020209037, 0.007960522, 0.005248398, -0.011977981, -0.026255516, -0.009184697, -0.0300836, 0.008900634, 0.001802446, 0.0068547055, -0.025146319, -0.027053598, -0.013208919, 0.011815659, 0.0057624164, 0.030137708, -0.023685426, -0.019370375, 0.026214937, -0.016394481, -0.021494083, 0.0060126623, -0.02755409, -0.01812591, 0.0013645159, -0.0057150726, -0.001340844, -0.004186544, 0.0035507847, 0.011112265, -0.0048358305, 0.024010068, 0.019870868, 0.018098857, -0.0029014985, 0.013303607, 0.005326177, -4.9119187E-4, 0.0016984587, 0.007088043, -0.042988166, -0.010936417, -0.017381936, 0.0026106723, 8.1245333E-4, 0.03324887, 0.028893244, 0.004054658, 0.0030283122, 0.02459172, -0.010429162, 0.0139326025, -0.02323904, -0.001390724, -0.0027510128, 0.0075614806, 0.01872109, 4.8316034E-4, -0.026553106, 0.021264128, -0.036576465, 0.018531715, 0.01360796, -0.0053194137, -0.0073382882, 0.0033478828, -0.038253788, -0.0073518152, 0.008454249, 0.014771264, 0.0059754634, -0.01880225, -0.040499236, -0.03571075, -0.029650744, -0.023144353, 0.023049666, -0.0068851407, -0.027472928, -0.020682476, -0.0025954545, -2.64618E-4, -0.019167474, -0.0027966658, -0.02260328, -0.0044232635, 0.001430459, 0.029217886, 0.027161812, -2.863877E-4, 0.03819968, -0.022386853, -0.015596399, 0.004565295, -0.033546463, -0.01826118, -0.006137785, 0.02818985, 0.004233888, 0.017611893, 0.020804217, 0.013006018, -0.0029640598, 0.015434078, -0.0056812554, 0.006181747, -0.0032971574, -0.007297708, 0.0054445365, 0.0016840865, 0.041473165, 0.0033191382, -0.02015493, -0.02992128, 0.016651489, 0.0017855375, 0.018869884, -0.00783878, -0.032356102, -0.0016460423, -0.02019551, 0.0057725613, -0.015772248, -0.016908498, 0.0038077938, 0.008440723, 0.028406277, 0.014216666, 0.02446998, 0.0060633877, -0.013736464, -0.018477608, 0.010246551, 0.0146765765, -0.011903583, 0.006428611, -0.008440723, 0.011098739, 0.017354883, 0.029244939, 0.0055798045, 0.020912431, 0.0046667457, 0.017057294, 0.020438993, 0.0058503407, -0.020804217, -0.0016891591, -0.014554836, -0.05475648, -0.0052686883, -0.024267077, -0.03149039, -0.013161575, -0.0050624046, -0.0071827304, 0.017841848, -0.011105502, 0.0023113918, -0.011024341, -0.014365461, 0.03149039, 0.00682427, 0.032545477, 0.03638709, 0.015745195, 0.0016705596, -0.061898634, -0.016205106, -0.01661091, 0.013905549, 0.03249137, 0.0070068818, -0.015122961, 0.015028274, 0.018112384, -0.03021887, -0.0376045, 0.009894853, 0.044773705, -0.002150761, -0.012586687, -0.0039701154, -0.011146083, 0.01981676, -0.017909482, -0.026566634, -0.01466305, -0.00714215, -0.0076291147, -0.009360545, 0.003391845, 3.4345387E-4, 0.0063846493, 0.00957021, -0.004122292, -0.006678857, -0.021358816, 0.015109435, -0.0073382882, 0.025633285, -0.0021676696, -0.005059023, 0.013046598, 0.012113249, -0.013675594, -0.0035338763, -0.010293894, 0.04315049, -6.332233E-4, -0.014541309, -0.0036454722, -0.013242736, 0.03443923, -0.013547089, 0.013168339, 0.039281823, -0.033411194, 
-0.012688138, 0.025403328, -2.612363E-4, 0.012147065, -0.006959538, 7.870906E-4, -0.028757975, -0.007933468, -0.010368291, -2.8025836E-4, -0.03127396, -0.02365837, -0.018991625, -0.01774716, 0.014392514, 0.0114369085, -0.02530864, 0.013337424, 0.05083371, -0.018274706, 0.008866817, 0.008055209, -0.00374016, -0.0016570329, -0.010172153, 0.026539579, -0.01880225, 0.008420432, -0.01601573, -0.003513586, -0.022373326, 0.0012486926, 0.02970485, 0.0046667457, 0.023171406, 0.024077702, 0.009171169, -0.0037333965, -0.014257246, -0.0087518385, 0.0106929345, 0.012965437, 0.009360545, 0.022035155, -0.016408008, 0.008718022, 0.004876411, 3.333088E-4, -0.009921907, -0.03203146, -0.026499, -0.0033495736, -0.010293894, -0.023590738, -0.04217656, -0.022278639, -0.006543589, -0.0094958125, -0.01533939, -0.0013129449, 0.004886556, 0.011105502, 0.022684442, -0.0053802845, 0.0018294996, -0.019667966, -0.02341489, -0.006060006, -0.009800166, 
-0.021142386, -0.002510912, -0.02556565, 0.031517442, 0.005833432, -0.029217886, -0.021196494, -0.0039937873, -0.03362762, -0.012519052, -0.020587789, 0.008264874, -0.0045754397, -0.0045855846, -0.0050319694, 0.021047698, -0.008826236, 0.008819473, -0.011950927, 0.007148913, 0.0028964258, -0.009969251, 0.0124717085, 0.0048290673, -0.0039599705, -0.00580976, 0.02070953, 0.0017077584, 0.01533939, 0.011342221, 0.010753805, -0.012566396, 0.015122961, -0.024497032, -0.0059653185, -0.0021321618, 0.018464081, -0.037956197, -0.008711259, -0.0066416585, -0.01060501, -0.010659117, -2.424256E-4, 0.007284181, -0.0010322639, 0.0157993, -0.0315986, -0.002794975, -0.008650388, 0.011389565, 0.019735599, 9.147498E-4, -0.0073382882, 0.0053194137, 4.1066518E-4, -0.012038851, -0.024524087, 0.022630334, -0.019722072, -0.004920373, 0.027418822, -0.019843815, 0.017192561, -0.0011802132, 0.015691087, -0.034709767, 0.008548937, 0.004102002, 2.4432782E-4, -0.03968763, 0.015569346, 0.022292165, -0.027337661, -0.007980811, 0.011403091, -0.01157894, -0.025038105, -0.02586324, 0.015488185, -0.047100313, 0.013810862, 0.024185916, 0.0050996034, -0.021385869, 0.013844679, -0.0028964258, -7.389014E-4, 0.0010736897, 0.2863353, -0.033113603, -0.003943062, 0.012451419, -0.008258111, 0.017855374, 0.001177677, -0.0011886675, 0.004818922, 2.3481678E-4, -0.0117818415, -0.013804099, 0.008244584, -0.0029556055, -0.001368743, -9.764658E-4, -0.01233644, -0.026025562, -0.0012799733, -0.030570565, 0.008183713, -0.0075209, 0.0024365147, -0.0049575716, 0.015474658, 0.014771264, -0.021412922, -7.6553226E-4, 0.016002202, -0.0059450283, -0.012478472, 0.006851324, 0.0025041488, -0.005992372, 0.005745508, -0.00823782, 0.026539579, 0.0017204398, 0.02590382, 6.877532E-4, -0.002658016, 0.013405058, 0.019032206, -0.019451536, -6.73381E-4, -0.013763518, 0.010787622, -0.025092212, -0.0011531597, 0.025335694, 0.010212733, 0.00668562, 0.02548449, 0.036603518, -0.0048595024, -0.0024263696, 0.003885573, -0.015244703, -0.01804475, -0.0028118833, -0.003437498, 0.01931627, -6.543589E-4, 
0.02674248, -0.022725021, 0.007933468, -0.010523849, -3.679712E-4, 5.7150726E-4, -0.023563683, 0.010632064, -3.360564E-4, -0.01698966, -0.021791672, -0.029758958, -0.045450043, 0.026444891, 0.01943801, 0.010814676, 0.02970485, -0.00527207, -0.0032413593, 0.010686171, 0.011876529, -0.0037570684, -0.008190476, 0.015515238, -0.0022336126, -0.0071759666, 1.1952195E-4, 0.010699698, -0.0065943147, -0.0049880072, -0.006776926, -0.0014279227, 0.017341357, -2.0987674E-4, 0.01601573, -0.021399396, 0.022454487, -0.030868156, 0.02146703, 0.035764858, 0.012816642, -0.014365461, -0.013695884, -0.002737486, -0.011173136, 7.591916E-4, -0.010023358, -0.027662303, -0.022170423, 0.0042744684, 0.00988809, 0.005667729, -0.003423971, -0.01872109, -0.005901066, -0.0023840982, -0.0022911015, 0.038605485, -0.015150015, -0.015204122, 0.011998271, -0.025700917, -0.022116316, -0.002974205, -0.011605994, -0.008914161, -0.026404312, 0.013973183, -0.029190833, 0.010334474, 0.016502695, -0.0025362747, 0.030489406, 0.013405058, -0.011173136, -0.0066720936, 0.015014747, 0.015312336, -0.0045619127, 0.0012774371, -0.011748025, 0.006252763, 
-0.04420558, 0.023387836, 0.008413669, 0.016394481, 0.0026089814, -0.046640404, 0.008393379, -0.0011117338, 0.006039716, 0.019884394, 0.015285282, -0.021602297, -0.02327962, 0.0042203614, 0.009982778, -0.040986203, -0.0024618774, 0.034574497, -0.032464318, -0.012715191, -0.015068854, -0.17509088, 0.0037435417, 0.02121002, -0.02248154, 0.016881445, 0.003828084, -0.0069865915, 0.0012664465, 0.009002085, 0.006273053, 0.009671661, -0.0042981403, -0.018910466, -0.007933468, 0.0017584838, 0.023996541, -0.00851512, -0.004450317, 0.030056547, 0.010686171, 0.03460155, -0.022914397, -0.0034391887, 0.013817625, 0.025727972, 0.009062955, -0.013526799, 0.024091229, 0.008406905, -0.017814795, -0.025092212, -0.008420432, 0.023090245, 0.009238804, 0.016786758, 0.011788606, 0.026309624, -0.009184697, -0.006036334, -5.854568E-4, 0.0063677407, 0.03284307, -7.942767E-4, 0.011748025, 0.011856239, 0.014581889, 0.008589517, -0.017233143, -0.021101806, -0.012329677, 0.015150015, -0.031625655, 0.017544258, -0.0046092565, 0.026985964, 0.03925477, 0.0019867485, 0.026634267, -0.017138455, 0.0171114, 0.0034831506, -0.024537614, 0.00988809, -0.005136802, -0.005870631, -0.010490033, -0.026688375, 0.016894972, 0.005461445, 7.35097E-4, 0.0036860527, -0.0057252175, 0.011849476, -0.020939484, 0.011423382, 0.015461131, -0.0081160795, 0.020804217, 0.023617791, -7.3382887E-4, -0.012160593, 0.011964453, -0.017503677, 0.001498093, 0.015839882, 0.019992609, 0.018112384, -0.0069663012, -0.028785028, -0.021913415, 0.014893006, -0.021899888, -0.00783878, -0.0016494241, -4.8273764E-4, 0.016489169, 1.5365599E-4, 0.0052078175, -0.0020662185, -0.004108765, -0.01901868, -0.0031618893, 0.003973497, -0.008670678, 0.005126657, 0.004210216, 0.002194723, 0.0071015693, 0.036982268, -0.009583737, 0.019451536, -0.008575991, 0.018220598, 0.006577406, 0.010571193, 0.014311354, -0.016773231, -0.014378987, 0.015325863, -0.017652472, 0.0037333965, 0.0052382527, 0.0077305655, 0.025592703, -0.023482524, -0.016489169, -0.045504153, -0.018017696, -0.0044638435, 0.013749992, -0.0069663012, 0.047154423, 0.015244703, 0.03224789, -0.009779876, 0.008433959, -0.009029138, -0.014297826, -0.016962606, 0.004991389, 0.041824862, 0.0065503526, -0.009597264, -0.008887107, 0.0072436007, 0.015650507, 0.00925233, -0.008697731, 0.007892887, -0.022670915, -0.0026969055, -0.021981047, -0.0285686, 0.025755025, 0.02019551, 0.010036885, 0.03249137, -0.00913059, 0.00847454, 
-0.019952029, -0.010801149, 0.015731668, -0.026336677, -0.030327084, 0.020655422, -0.02315788, 0.0034036809, -0.0036623809, -0.018856358, -0.018058276, -0.02184578, -0.018734617, 0.031760924, 0.026661322, -0.010855257, -0.009455233, -0.035927176, -0.020006135, -0.021872833, -0.0051604738, 0.03993111, 0.015623453, 0.015921043, 0.013452401, -0.024402345, -0.0061344034, 8.61488E-4, -0.0012377021, -0.020303724, 0.02582266, -0.0014786482, 0.005688019, -0.019167474, -1.9529316E-4, 0.014257246, -0.016232159, -0.010780859, 0.038605485, -0.008603044, 0.038172625, 
-0.019532697, -0.017693054, 0.005363376, -0.010591484, 0.01914042, -0.015691087, -0.010672645, -0.012120012, 0.03376289, 0.013188629, -0.0146765765, 0.012735481, -0.009428179, 0.0015386734, -0.023604264, -0.013614723, 0.0055324608, -0.0012968818, -0.016002202, -0.009637844, -0.0069020493, -0.0032075422, -0.011849476, 0.002138925, 0.012437891, 0.0027442493, -0.024240024, -0.020100823, -0.09685188, 0.018058276, 0.008406905, 0.0071218596, 0.017314302, -0.027351188, 0.009299674, -0.020547207, 0.0065368256, 0.012728718, -0.02184578, 0.020344306, -0.0075479536, -0.032274943, -0.017097874, -0.012045614, 0.039985217, 0.0014262318, 0.0067938347, -0.0033952266, 0.023983015, 0.0060802964, 0.020520154, 0.018274706, -0.021453504, 0.0017889192, -0.027094178, 0.025714444, -0.013405058, -0.008684205, -0.020682476, -0.028406277, -0.0010728443, -0.0062899617, -0.0068107434, 0.0040478944, -0.0026106723, 0.010077465, -0.00558995, 0.039795842, -0.006540207, -0.021196494, 0.03287012, 5.5502146E-4, -0.03571075, 0.013303607, -0.013168339, 0.014487201, 0.03541316, -0.007345052, 0.019424483, 0.017260196, -0.0102397865, -0.026066141, -0.0117818415, -0.033952266, 0.036360037, -0.010895836, -0.0018227361, 0.0099489605, -0.0045450046, 0.029731903, 0.010699698, 0.002150761, -0.010740278, -6.513999E-4, 2.0712911E-4, -0.013621487, 0.030056547, -0.04066156, -0.008988558, 0.0012740553, -7.4397394E-4, 0.011321931, -0.01223499, 7.735638E-4, -0.008718022, 0.029163778, -0.036738787, 0.015785774, 0.0071827304, 
0.0038686646, -0.029975386, -0.013722938, 0.030435298, 0.015961623, -0.022170423, -0.015231175, -0.008427196, -0.0044097365, -0.027946366, -0.01058472, 0.012309387, 0.009935434, 0.00750061, 0.022238057, -0.008738312, 0.0010787622, 0.030651726, -5.3261773E-4, 2.3122372E-4, -0.0034696239, -0.0052653067, 0.0070001185, -0.0073518152, -0.0023333728, -0.011457198, -0.014081398, 0.0069798282, 0.018166492, 0.013188629, 0.025146319, -0.00823782, 0.03287012, -0.009090009, 0.026904803, -4.6202473E-4, -0.024023594, -0.026783062, 0.027729938, 0.029136725, 0.023090245, 0.024943417, -0.028812082, 0.0053971927, -0.001132024, 0.0036184187, -0.033059496, -0.009286148, -4.975326E-4, -0.0051063667, -0.018098857, -0.008014629, -0.0088600535, -0.001334926, 0.033167712, -0.0013771972, 0.010828203, -0.032274943, 0.048398886, 0.0078117265, 0.015542292, 0.0075547174, -0.006330542, -0.015582873, 0.012532579, 0.017909482, -0.00614793, -0.021494083, 
0.011944164, -0.0013974875, -0.0070609893, -0.015204122, -0.015961623, -0.007385632, -0.019830287, 0.028730921, 0.003706343, 6.7253556E-4, 0.023685426, -4.4300267E-4, -0.006553734, 0.017003186, -0.010435926, -0.007081279, 0.0073179984, 0.0035169676, -0.0034307344, -0.004944045, 0.023103772, 0.0047140894, -0.021832254, -0.0111799, -0.010199207, 0.0076764585, -0.002974205, 
0.013175102, -0.008264874, 0.014378987, 0.0012368567, 0.027067125, -0.028108688, -0.009347018, 0.01774716, -0.0021253983, -0.018328812, -0.013594433, -0.008163423]
[-0.03176027, -0.025470547, -0.01809004, -0.0011350543, -0.010256216, 0.028572911, -0.002709256, -0.020469934, -5.8390666E-4, -0.023898117, -0.014293538, 0.0081738075, -0.005071444, -0.018812507, -0.02022911, 0.01579514, 0.014435199, -0.0015600356, 0.021362394, -0.012480285, 0.02972036, 0.012621946, 0.00358578, -0.018897504, 0.004681878, -0.007408841, 0.0052626855, -0.032496907, -0.005779746, 0.013996052, 0.035018463, 0.003426412, -0.013748146, -0.011247839, -0.0016769056, -0.016092626, 0.007267181, 0.0031484035, 0.014761019, 0.004281687, 0.03309188, 0.006473882, 0.0032422533, 0.010631616, -0.02782211, 0.013401078, -0.029267048, 0.012551115, -0.009682491, -7.542312E-5, 0.0033431866, -0.0012811417, 0.0086908685, -2.3041957E-4, 0.01614929, 
-0.013648984, 0.007940068, 0.013939388, -0.009505415, -0.008315468, -0.0024206229, 0.024677249, -0.038701635, 0.006126814, -0.0053051836, 0.005482259, 0.0023958322, -0.003245795, 0.0027995645, -0.02292066, 0.019449979, 0.01811837, 0.022835664, -0.024974735, 0.03660506, -0.007557585, -0.032921888, 0.0045897984, 0.019209156, -0.0035078668, 0.021079075, 0.010298714, -0.003463598, -0.018600017, 0.016460944, 0.01486018, -0.008967106, 0.011035348, -0.011474496, -0.015993465, 0.016914258, -4.9227005E-4, 0.00403024, 0.016035963, -0.0067855353, -0.008768781, 0.0015104545, 0.0042781453, -0.0028739362, -0.03227025, -0.0024401012, 0.01192781, -0.029182052, -0.016588438, -0.032893553, -0.0069944845, 0.030825313, 0.017721722, 8.176464E-4, 8.8537775E-4, 0.006339305, 0.04788123, -0.0055495477, -0.058137447, -0.023331475, -0.0020452226, 0.013507323, 0.0038425396, -0.012409455, -0.01783505, 0.0036335904, 0.030032014, 0.016985087, -0.016602604, 0.02632051, 0.017211745, -0.020328274, 0.005351223, -0.011849896, -0.0060878578, 0.035726763, -0.0072600977, 0.015214331, 0.014548528, -0.01783505, 0.01930832, -0.021390727, -0.02130573, -0.028218761, -0.013039844, 0.0055282987, 0.02704298, -0.013542739, 0.0032900637, -7.89757E-4, 0.00857754, 0.008400464, 0.016205955, 0.009278759, -0.0070582316, 0.013486074, -0.02585303, 0.012650277, 1.9024556E-4, 0.0016096168, 0.011892394, 0.018019209, 0.008726283, -0.0326669, -0.00539018, -0.0014776955, 0.008386298, 0.0059816125, -0.016503442, 0.011162843, 0.035726763, -0.010504122, -0.0051387325, 0.0024312474, 0.0046464624, 0.0044020982, 0.01054662, -0.009717907, 0.020172447, -0.008216306, 0.014095214, -0.0040762792, 0.0121544665, -0.0037292112, -0.0071361447, -0.043999735, -0.022750668, -0.004526051, 0.0056982916, 0.0020452226, -0.0242806, 0.010348296, 0.004614589, 0.00515644, -0.0011828647, 0.0093425065, 0.038304985, -0.001839815, 0.0014360828, -0.61559963, -0.031250294, -0.0057726633, 0.007918819, 0.02284983, 0.026887152, -0.0042427303, 0.014314787, -0.01833086, 0.012579448, -0.023260646, 0.015993465, -0.0020469935, -0.016290952, 0.0060595255, -0.011212424, 0.007330928, -0.034905132, 0.01478935, 0.035046794, -0.03552844, 0.013563988, -0.020979911, 0.008641287, -0.0045473003, -0.011594907, 0.010532454, 0.0046252133, 0.0027322758, 0.012699859, -0.023827286, 0.0038744132, 0.018260032, -0.008513792, 0.052272703, -0.0029447665, -0.014491864, 0.041194856, -0.013847308, 0.011715319, -0.024691416, -0.028700406, 0.027751282, -0.013103591, -0.005482259, 0.0085350415, 0.018911669, 0.0029908062, -0.02439393, -0.009307091, 0.011609074, 0.0046110475, -0.008322551, -0.01525683, 0.015950967, 0.01769339, 0.026377175, -0.023770623, 0.0068705315, -0.008697951, -0.012012806, 0.011247839, -0.0059426557, -0.023798954, -0.013861475, -0.014562693, -0.025782201, 0.006601377, 0.0017291429, -0.02148989, 0.0085562905, -0.009335423, 0.010532454, 0.012076553, 0.023274811, 0.02639134, 0.014144795, -0.0038814961, -0.0049191588, 0.015639313, 4.4246754E-4, 0.0019159575, -0.0037008792, -0.027368797, 0.033828516, -0.0069342786, -0.025343053, -0.0047314586, 0.003991283, -0.007309679, 0.019492477, 0.013273584, -0.001933665, -0.011148677, -0.0030226798, 0.010936187, -0.027127976, 6.556222E-4, 0.022609007, -0.010376628, -0.039239943, 0.009066269, 0.02826126, 0.00367963, 0.019251654, 8.6678483E-4, -0.024082275, 0.008131309, 0.018840838, -0.036718387, -0.0047633327, 0.020328274, 0.011439081, -0.010043725, 0.010277465, -0.030825313, 0.027411295, 0.010886605, 0.01675843, -0.02177321, 0.02116407, -0.016092626, 0.008025064, 0.01701342, 0.0011536472, 0.0070228167, -0.012791938, -0.020257443, -0.023643129, 0.005641627, 0.0030085137, -0.0064809653, 0.007387592, -0.020073285, 0.022042366, 0.0055460064, 0.0064455504, 0.0020168906, 0.015979297, 0.0038637887, -0.016999254, -0.0038814961, 0.0066332505, -0.008705034, -0.0035255742, -0.036265075, 0.004090445, 0.009625827, -0.0013953553, 0.015880136, 0.034366824, 8.5881643E-4, -0.0069590695, 0.01586597, -0.010518288, -0.011453247, -0.03255357, 2.0651436E-4, -0.007302596, 0.004310019, 0.024110608, -0.013790644, -0.011439081, -0.006874073, -0.025116397, -0.012083636, 2.689335E-4, 0.015016007, -0.038531642, -0.043631416, 0.0051670647, -0.01858585, -0.014144795, -0.007578834, -0.013245252, 0.0031926723, -0.010879522, -0.013981886, -0.0075080036, -0.015880136, -0.0034901593, 0.003810666, 0.013500241, 0.010829941, 0.04147818, 0.0067926184, 0.02385562, 0.01099285, -0.015157668, 0.010291631, -0.027297968, 0.016999254, 0.02034244, 0.011014099, 0.009880816, -4.975823E-4, 0.025343053, 0.011056597, 0.0025020775, 0.015044339, 0.027113808, 0.013634818, 0.003288293, -0.038446646, 0.012168632, -0.037228364, -0.0036477565, -0.01532766, 0.029805357, 0.022948992, 0.007345094, -0.0011633864, -0.0054645515, 0.0182317, 0.01579514, 0.00421794, 0.013422327, -0.0039735753, -0.024719747, 0.010107473, 0.0017840362, 0.0040869038, 1.2362088E-4, -0.03771001, 0.0024808284, -0.004621672, 0.012310293, 0.026518835, 0.010596201, -0.01736757, 0.0039664926, -0.005418512, 0.0010580264, 0.0026348843, 0.03176027, -0.031250294, 0.015355992, -0.0027057144, 0.050657775, 0.0258247, -0.009264593, 0.013146089, 0.013911055, 0.0023002115, 0.012529866, 0.0043596, 0.037426688, 2.4015873E-4, -0.011453247, -0.005723082, -0.01486018, -0.026547167, -0.022354018, -0.006286182, 0.011056597, -0.027227137, -0.00367963, 0.02073909, 0.008605872, 0.033573527, 0.027595455, 0.03405517, -0.009236261, 0.0051847724, 0.00789757, -0.0054503856, 0.00789757, 0.007869238, -0.010744945, -0.008492543, -0.008747532, 0.022552343, -0.023543965, -0.006881156, 0.014732686, -0.007090105, -9.7125943E-4, 0.020894915, 0.017339239, 0.008081729, -0.015766807, -0.032326914, 0.011113262, 5.3565355E-4, -0.0016255536, -0.0038531641, -0.029862022, -0.004012532, -0.019492477, 0.012168632, -0.008329635, 0.011403666, 0.017990876, 0.0050572776, 0.0017238305, 0.01586597, -0.004026698, -0.020512432, -0.036945045, -0.012204047, 0.005209563, -0.01858585, 0.00843588, -0.013146089, 0.01811837, -0.01115576, -0.0126715265, -0.018019209, -0.01342941, -0.017310906, -0.00857754, -0.00735926, -0.0017583603, 0.0016963838, -0.020639926, 0.017112581, 0.017254243, -0.009122932, 0.013918139, 0.0019035622, -0.015129335, -0.010681197, -0.00766383, 0.0012324458, 0.0045331344, 0.013280666, 0.0014210313, 0.0064455504, -0.0014360828, -0.0035893214, -0.025768034, -0.008768781, 0.012126134, 0.00698386, -0.005864742, 0.0036406734, 0.0077913245, -0.016418446, -0.00120677, -0.017027585, -0.005992237, -0.030202007, 0.025215559, -0.03836165, 0.0029571617, 0.013889806, 0.0037610848, 0.0071821846, 0.011743651, 0.007415924, -0.01755173, 0.041818164, 0.013974803, -0.019379148, 0.018968333, 0.0035521355, -0.016800929, 0.010525371, -1.852653E-4, -0.009632911, -0.0069944845, 0.031816937, -0.013216919, 0.017778385, -0.0019425189, 0.028034601, 0.004239189, -0.0077417432, 0.0067536617, -0.01612096, 0.020540765, 0.01933665, -0.006905947, -0.031136965, 0.028544579, -0.01998829, -0.02395478, -7.175987E-4, 0.0013448888, 0.033545192, -0.013415244, -0.0029447665, -0.001042975, 2.4967652E-4, 0.005149357, -0.016744265, 0.024592252, -0.0023551048, -0.0153701585, -0.016914258, 0.0059072403, -0.024238102, -0.0072175995, -0.015965132, -0.0028934146, 0.0056487103, -0.03297855, -0.03555677, 0.019917458, 0.020781588, 0.03538678, -0.013783561, 0.0030580948, 0.02338814, -0.017112581, -0.0128061045, -0.004193149, -0.029238716, 0.0013776479, 0.0033750602, 0.02460642, -0.01258653, -0.001035892, 5.5645994E-4, 0.012629028, 0.0014033237, 0.037795007, 0.02474808, 0.016531773, -0.024776412, 0.022240689, 0.016744265, -0.011609074, 0.005779746, 0.01450603, -0.028176263, -0.016092626, -0.034338493, 0.0037469186, -0.008365049, 0.025583876, -8.450931E-4, -0.0012714025, 0.029635364, 0.020399105, -0.0033874554, 3.501669E-4, -0.021008244, 0.011446164, 0.0049156174, 0.0055885045, -1.03367856E-4, -0.004051489, -0.006601377, 0.010164137, -0.02413894, 0.030428663, -1.8847479E-4, 0.008301302, -0.00403024, -0.004887285, -0.032610234, -0.012041138, 0.018685013, 0.009002522, 0.03348853, -0.007755909, -0.022212358, -0.023543965, -0.03649173, -0.0032032968, 0.030343667, 0.008372133, -0.029550368, -0.041449845, -0.007855072, 0.004890827, -0.011035348, -8.5571763E-4, -0.02889873, -0.010121639, 0.013960637, 0.009717907, 0.02406811, 0.006757203, 0.024110608, -0.013889806, -0.0054433024, -0.008053396, -0.044538043, -0.02972036, -0.0077913245, 0.01851502, 0.026122186, 0.02556971, 0.008662536, 0.0015219644, -0.004338351, 0.008974189, -0.00607015, 0.0041541927, 0.0333752, -0.015710143, 0.004295853, 0.022821497, 0.023487302, -0.0029642447, -0.008407547, -0.019237489, 0.011375334, -0.009618744, 0.015313494, -0.015625147, -0.039891582, 0.01038371, -0.0067111636, 0.004497719, 0.002006266, -0.026844654, -0.020299941, 0.028601244, 0.012593614, 0.017707555, 0.011304503, 0.0077629923, -0.04000491, 0.015384324, -0.0038496226, 0.0067501203, -4.2785882E-4, 0.019959956, -0.0015901385, -0.014888513, 0.018855006, 0.0071751014, -0.004742083, 0.020639926, -0.0015857116, 0.030711984, 0.016248453, -0.01078036, -0.025697205, -0.010029559, -0.028842067, -0.053519316, -0.00367963, -0.03105197, -0.02800627, 0.006534088, 0.0021036577, 0.0013661379, 0.019209156, 0.0046252133, -0.014761019, 0.010674114, -0.004742083, 0.04340476, 0.0072175995, 0.026972149, 0.04530301, 0.008570457, -0.003707962, -0.053547647, -0.01471852, 0.0077417432, 0.0052343532, 0.0523577, -0.010794526, -0.026263846, 0.039636593, -0.009385005, -0.012898183, -0.028417084, 0.037426688, 0.024804743, 0.01274944, -0.011325752, -2.516064E-6, -0.0055070496, 0.013117757, -0.031505283, -0.0021550094, -0.0077488264, -0.025399718, -0.014761019, 0.0057124575, 0.0011545327, -0.010412043, -0.0056274612, 0.019464144, 0.005397263, 0.0018947085, 0.0010837024, 0.035330113, -0.026972149, 0.03666172, 0.012026972, 0.0061551463, 0.01954914, -7.8842894E-4, -0.020923248, -0.01901083, -0.004012532, 0.046294633, -0.0059143235, -0.022056531, -0.014010218, 0.005687667, 0.0032227752, -0.011665737, 0.0013094738, 0.007228224, -0.003390997, -0.0024808284, 0.008527959, 7.0564606E-4, -0.014456448, -0.00637472, -0.015044339, -0.010114555, -0.021886539, -0.023940615, 0.0018105976, -0.03960826, -0.022127362, -6.418989E-4, -0.019464144, 0.02055493, -0.0052272705, -0.0022984408, -0.014144795, 0.024578087, -0.03023034, 0.010270382, 0.012034055, 0.0026331134, -0.0011058368, -0.009597495, 0.0029376834, -0.023218147, 0.006091399, -0.024039777, -0.007911736, -0.019534975, -0.005007697, 0.008464212, 0.013443576, 0.0039948244, 0.029408708, -0.007415924, 0.013500241, -0.010582035, -0.0174384, 0.012352791, -0.010419126, 0.02650467, 0.011481579, -0.022764834, -0.0013068176, 0.0012616633, -0.01312484, 0.0051104007, -0.0258247, -0.029465372, 0.0072246827, 0.020030787, -0.015157668, -0.011339919, -0.01070953, -0.012126134, -0.02685882, -0.02685882, 0.00895294, 0.012763606, 0.008457129, 0.026433839, 0.004954574, 0.0018291905, -0.032185253, -0.030456996, -0.021886539, -0.012281961, -0.02901206, -0.016999254, -0.037200034, 0.021518221, -0.0021018868, -0.019039163, -0.014321871, 0.0022258398, -0.016305117, -0.013351497, -0.0120198885, 0.0099728955, -0.0010509434, 0.0020469935, 0.012572364, 0.004681878, 0.0023710416, 0.022863995, -0.015412657, -0.0029642447, -0.012650277, -0.01457686, 0.013252335, 0.005847035, -0.03241191, -0.022566509, 0.010858273, -0.0059957784, 0.016404279, 0.022368183, 0.010589118, -0.007309679, 0.007798407, -0.010404959, -0.0032333997, -0.001954914, 0.018415857, -0.03578343, -0.024337264, -0.0098383175, 0.0060028615, -0.024620585, -0.016163457, 0.028516248, 0.0024648916, 0.013868557, -0.020314109, -0.0022718795, 0.007635498, 0.012862768, 0.018075872, 0.0022063614, -0.0025746785, -0.007890487, 0.0080392305, -0.004848329, 
-0.033601858, 0.0065270048, -0.0057903705, -0.024875574, 0.004887285, 0.002643738, 0.01851502, -0.025073899, 0.0129194325, -0.029918686, 0.003311313, 0.012473202, 0.0042108567, -0.045161348, 0.013698565, 0.015355992, -0.027694616, -0.031193629, 0.01736757, -0.007677996, -0.0035468233, -0.01905333, 0.0045543835, -0.023487302, -0.008046313, -0.00356276, -0.010808692, -0.030032014, 3.127597E-4, -0.004072738, -0.004621672, 2.6207182E-4, 0.27788112, -0.022580674, -0.009505415, 0.029777026, 0.016645102, 0.012650277, 0.0144706145, -0.001162501, 0.011757817, -0.004759791, 9.56208E-4, -0.007862154, 0.0077063283, -0.0027871693, 0.0034689102, -0.004281687, -0.020753255, -0.019903293, -0.020710757, -0.0065270048, 0.0051635234, -0.012933599, 0.022028198, -2.2256184E-4, 0.0040869038, 0.004912076, -0.011488662, -0.005266227, 0.013464825, 0.0052272705, -0.0051174834, 0.0059072403, 0.014066882, -0.017240075, 0.014591026, 0.0051104007, 0.01952081, -0.012395289, 0.02374229, 0.004773957, -9.721448E-4, 0.019761631, 0.0015387866, 0.0061409804, 0.003159028, -0.013535655, 0.0038814961, -0.022226524, 0.010971601, 0.016262619, -0.001956685, -0.0065270048, 0.0062401425, 0.044538043, 0.012607779, -0.028672073, 0.027156306, -0.003461827, -0.0030492411, -0.014491864, -0.0032581901, 0.028856233, -0.022424849, 0.016574273, -0.014534362, -0.009016687, -0.03025867, 0.005478718, 0.01729674, -0.012409455, 0.020824086, -0.019846627, -0.012813187, -0.0131885875, -0.021603217, -0.035046794, 0.021121573, 0.020611595, 0.020894915, 0.026093854, 0.0090733515, 0.017509231, 0.002781857, 0.004504802, -0.013925222, -0.019789964, 0.013507323, -0.0025622833, 3.9310774E-4, -0.0043418924, 0.007855072, -0.020498266, -0.0037221282, -0.012430704, -0.006318056, 0.03079698, -0.01811837, 0.029493704, -0.009696658, 0.0015379012, -0.03448015, 0.010206635, 0.019846627, 0.0034901593, -0.021249067, 
0.004069196, 0.003534428, 0.0032475656, 0.010079141, 0.005839952, -0.0022931285, -0.029323712, -6.941362E-4, 0.0012829124, 0.011786149, -0.008230472, -0.017424235, -0.009420419, 0.014477697, -0.017126748, 0.044113062, -0.018883336, 0.0011651572, 0.014959343, -0.025343053, -0.019818297, 0.0066686654, -0.010971601, -0.0023285435, -0.04193149, 0.008166725, -0.011998639, 0.019506643, 0.0053405985, 0.009696658, 0.014031467, 0.0028066474, 0.006250767, -0.01450603, 0.011481579, 0.0131885875, -7.901997E-4, 0.030343667, -0.01912416, -0.0059143235, -0.015214331, 0.032156922, 0.010404959, 0.016262619, -0.0023993738, -0.025272224, 0.002941225, -0.023770623, -0.008697951, 0.013889806, 6.122387E-4, -0.042016488, -0.021574887, -0.013833143, 0.007628415, -0.06323722, 0.010759111, 0.022354018, -0.02685882, -0.007869238, -0.010433292, -0.18495187, 0.018600017, 0.04720126, -0.0371717, 0.032468572, -0.0042214813, 0.0025304097, -0.0089387745, 0.0041187773, -6.388001E-4, 0.019322485, 0.00782674, -0.0086908685, -0.021206569, -0.0042108567, 0.028048769, -0.028714571, 0.0016352928, 0.028119598, 0.012848603, 0.038899958, -0.011679904, -0.006881156, -0.009151265, 0.008924608, 0.022750668, -0.005287476, 0.012976097, 0.0014050945, -0.018415857, -0.010029559, -0.027892942, 0.02095158, 0.0131885875, 0.014194377, -0.004462304, 0.024124773, -2.5565282E-4, -0.003888579, 0.01722591, -0.023274811, 0.025867198, 0.007940068, 0.001919499, -5.192741E-4, 0.026292179, 0.016390113, -0.0011385959, -0.01687176, -0.008627121, 0.018486688, -0.012274877, 9.925085E-4, 0.0028881023, 0.041591506, 0.02850208, 0.01085119, 0.009618744, -0.010050808, 0.0066828313, 0.013259417, -0.02718464, 0.011311586, -0.017211745, -0.015001841, -0.006534088, -0.012969013, 0.009526665, -0.0051670647, -0.0015742017, 0.004642921, 0.008740449, 0.021744879, -0.008230472, 0.02148989, 0.028487915, 0.026306344, -0.012388206, 0.04204482, -0.0042427303, -0.03552844, 0.019166658, -0.033460196, -0.009958729, 0.006721788, 0.025484715, 0.02041327, -0.008251721, -0.007798407, -0.006636792, 0.01221113, -0.0046606287, 0.010504122, -0.013443576, -0.021079075, 0.01525683, -0.0034246412, 0.010532454, -0.017523397, -0.019393316, -0.01701342, 0.016191788, -0.009873733, 0.0041223187, 0.01886917, 
0.018047541, -0.022963159, 0.02252401, 0.033970173, -0.01221113, 0.025413884, -0.0049581155, 0.008187974, 0.021277398, 0.014258124, 0.025909696, -0.003607029, -0.012643195, 0.02779378, -0.015426822, -0.009717907, 0.0103553785, -0.005135191, 0.012551115, -0.0053724726, -0.0099728955, -0.052527692, -0.015440988, 0.006764286, 0.008634204, -0.0069874013, 0.02800627, 0.0056770425, 0.04261146, -0.00888211, 0.013450659, 0.005839952, -0.029663697, -0.0029146636, -0.0033520402, 0.025612209, -0.005337057, -1.2317818E-4, -0.0050147795, 0.008372133, 0.035613436, -0.008598789, 0.0018557518, -0.010688281, -0.014775184, 0.025328888, -0.017778385, -0.026122186, 0.039551597, 0.013726897, 2.9416676E-4, 0.027000481, -0.011864062, 0.0066474164, -0.02704298, 
-0.0182317, 0.024918072, -0.0053618476, -0.02088075, 0.03445182, -0.021036576, 0.0048731193, -0.0029429956, 0.005570797, -0.029862022, -0.012281961, -0.015313494, 0.017962545, 0.02969203, -0.00939917, -0.012777772, -0.036520064, -0.0015848263, -0.004657087, 0.0026756115, 0.030541992, 0.0011881769, 0.022127362, 0.022283187, -0.03227025, 0.010638699, 4.523727E-5, 0.009292925, -0.009951646, 0.0069732354, -0.0043489756, 0.008712118, -0.017622558, -0.02141906, 0.006229518, -0.023133151, 0.014187293, 0.022481512, -0.00965416, 0.024450593, -0.03555677, -0.02983369, -5.219302E-4, -0.011864062, 0.0034388073, -0.03065532, -0.008414631, -0.0016450319, 0.004356059, -0.010744945, 0.0019832463, 0.030740317, -0.0033803724, -0.0015582648, -0.013670233, -0.01715508, -0.008187974, 0.008195057, -0.012331542, -0.021730712, -0.013648984, -4.940408E-4, 0.0085562905, 0.004310019, 0.02556971, 0.013514406, -0.018033374, -0.02395478, -0.102222174, 0.028275425, -0.0117507335, 0.0031537157, 0.009023771, -0.031703606, 0.021433225, 0.0038814961, 0.006583669, 0.01790588, -0.0348768, -0.0011740109, -0.0010314651, -0.03972159, -0.015596814, -0.049354497, 0.04677628, 0.0037433773, 0.013670233, 5.746102E-4, 0.003483076, 0.02148989, 0.014123546, 0.010454541, -0.049014512, 0.012735274, -0.035188455, 0.03201526, -0.008542125, -0.0034795348, -0.014421034, -0.0318736, 0.002057618, -0.0035786969, -0.007862154, 0.011056597, 0.011191175, -0.0050006136, -0.0026419673, 0.02650467, -0.03255357, -0.0054008043, 0.013308999, 1.5516246E-4, -0.03348853, -0.008209223, -0.01342941, 0.009080434, 0.015228498, -0.014017301, 0.032213584, 0.01434312, -0.0064845067, -0.031448618, -0.015837638, -0.0295787, 0.024578087, -0.008081729, -0.02413894, -0.01237404, 0.024592252, 0.019223323, 0.02073909, -0.0055743386, -0.009094601, 0.009710823, -0.018897504, -0.012756523, 0.021291565, -0.030853644, -0.032638565, -0.014265207, 0.0081738075, -0.0039948244, 0.0013811893, -0.016390113, -0.0035007838, 0.00466417, -0.03309188, 0.0348768, 0.008230472, -0.011913643, -0.02292066, -0.02571137, 0.017792553, 0.021900704, -0.018217534, -2.8309954E-4, 0.012614863, -0.003665464, -0.009788737, 0.013110674, 0.012381122, 0.012551115, -0.004051489, 0.037256695, -0.018614182, -0.007954234, 0.021659883, -0.011856979, -0.0029890353, -0.0026384257, -0.0021603217, -0.0235298, -0.0034901593, -0.0028934146, -0.025272224, -0.021872373, 0.008450045, 0.016390113, 0.013401078, 0.009682491, -0.01966247, 0.029862022, -0.0031554864, 0.021730712, -0.009824152, -0.037625015, -0.024436427, 0.03802166, 0.045756325, 0.02088075, 0.016772596, -0.023005657, 0.007309679, -0.0033272498, 0.022283187, -0.030343667, 0.008117143, 0.0028633117, 0.011552409, -0.0134577425, 0.0074938373, -0.012997346, -0.013599402, 0.0068846974, 0.008166725, 0.0035291158, -0.039183278, 0.08941607, 0.0144706145, 0.003506096, 0.016956756, -0.027992103, -0.007309679, 0.007642581, 0.020583263, 0.009250427, -0.014293538, 0.0022293814, -0.017410068, 0.02460642, -0.025612209, -0.037795007, 0.007699245, -0.020639926, 0.007143228, -0.0059568216, -0.019067496, 0.025768034, -0.002454267, 0.0121403, 0.01221113, -0.025470547, -0.01389689, 0.027354632, -0.0056168367, 
0.013663149, -0.015695978, 0.023898117, 0.002622489, -0.029862022, -0.0066544996, -0.008095894, 0.002128448, 5.9895805E-4, 0.018075872, 0.002861541, 0.012196965, -0.015780974, 0.020002455, -0.020540765, -0.0073805093, 0.037908334, -0.023756456, -0.0189825, -0.017070083, -0.0067324126]

プロンプトトークン：14、合計トークン：14
```

# 文章校正

入力テキストに対して、指示した内容に従って修正してくれます。
モデルはtext-davinci-edit-001を使用します。

```java
public class EditsApp {

    public static void main(String[] args) {
        var service = new OpenAiService("Your Openai API Key", Duration.ofSeconds(20));

        var editReq = EditRequest.builder()
                .model("text-davinci-edit-001")
                .input("OpenI（オープンエーアイ、オプンAI）とは、鋭利法人OpenAI LPとその親会社である非営利法人OpenAI Inc. からなるアメリカの人工知（AI）の開発を行っている企業である")
                .instruction("誤字脱字を修正して")
                .build();
        EditResult editResult = service.createEdit(editReq);

        System.out.println(editResult.getChoices()
                .get(0)
                .getText());

        Usage usage = editResult.getUsage();

        System.out.println("プロンプトトークン：" + usage.getPromptTokens() + "、補完トークン：" + usage.getCompletionTokens() + "、合計トークン：" + usage.getTotalTokens());
    }
}
```

```:出力
OpenI（オープンエーアイ、オプンAI）とは、鋭利法人OpenAI LPとその親会社である非営利法人OpenAI Inc. からなるアメリカの人工知能（AI）の開発を行っている企業である

OpenI は、人工知能に関する内部の構想、潜在的な技術、研究成果に関し著作権や特許を申請しないことを考慮し建物、営業ユニットや個人的な資産は登録していない。

プロンプトトークン：136、補完トークン：362、合計トークン：498
```

理由はよく分かりませんが誤字脱字の修正はあまり正確ではありませんでした。

# プログラムコード校正

上と同じAPIで、プログラムソースコードの修正が得意なcode-davinci-edit-001というモデルを利用します。
コメントやテストの追加、別言語への変換などしてくれると助かりますね。

```java
public class EditsApp {
    public static void main(String[] args) {
        var service = new OpenAiService("Your Openai API Key", Duration.ofSeconds(20));

        var editReq = EditRequest.builder()
                .model("code-davinci-edit-001")
                .input(
"""
public class HelloWorld {
    public static void main(String[] args) {
        System.out.println("Hello, World!");
    }
}
"""
                )
                .instruction("JavaDocを追加して")
                .build();
        EditResult editResult = service.createEdit(editReq);

        System.out.println(editResult.getChoices()
                .get(0)
                .getText());

        Usage usage = editResult.getUsage();

        System.out.println("プロンプトトークン：" + usage.getPromptTokens() + "、補完トークン：" + usage.getCompletionTokens() + "、合計トークン：" + usage.getTotalTokens());
    }
}
```

```:出力
/**
 * HelloWorldのクラスです。
 *
 * @author taguchi
 * @author suzuki
 * @since 1.0
 */
public class HelloWorld {
    public static void main(String[] args) {
        System.out.println("Hello, World!");
    }
}

プロンプトトークン：56、補完トークン：52、合計トークン：108
```

入力テキストなしで指示文だけでも送れるそうなので試してみます。

```java
public class EditsApp {

    public static void main(String[] args) {
        var service = new OpenAiService("Your Openai API Key", Duration.ofSeconds(20));

        var editReq = EditRequest.builder()
                .model("code-davinci-edit-001")
                .instruction("Rust言語のHelloWorldプログラム")
                .build();
        EditResult editResult = service.createEdit(editReq);

        System.out.println(editResult.getChoices()
                .get(0)
                .getText());

        Usage usage = editResult.getUsage();

        System.out.println("プロンプトトークン：" + usage.getPromptTokens() + "、補完トークン：" + usage.getCompletionTokens() + "、合計トークン：" + usage.getTotalTokens());
    }
}
```

```rust:出力
// File         : file.rs
// Author       : Rahul Chadha
// Creation Date: 23 Dec. 2016


// Hello World in Rust
fn main() {
  println!("Hello, Global World!");
}

プロンプトトークン：25、補完トークン：69、合計トークン：94
```

参考：https://note.com/npaka/n/nb9d848e963a7