Skip to content

Commit

Permalink
[共通] OpenAI::Chat / Vision のデフォルトモデルを GPT-4o に #1234
Browse files Browse the repository at this point in the history
  • Loading branch information
Reputeless committed Jun 12, 2024
1 parent 0c576d4 commit ec5c603
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 21 deletions.
29 changes: 10 additions & 19 deletions Siv3D/include/Siv3D/OpenAI/Chat.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,26 +23,17 @@ namespace s3d
{
namespace Model
{
/// @brief GPT-3.5
/// @brief GPT-3.5 16K
/// @see https://platform.openai.com/docs/models/gpt-3-5
/// @remark alias: `GPT3_5_Turbo_16K_1106` from February 2024 16th
inline constexpr char32 GPT3_5_Turbo[] = U"gpt-3.5-turbo";

/// @brief GPT-3.5 16K (0125)
/// @see https://platform.openai.com/docs/models/gpt-3-5
inline constexpr char32 GPT3_5_Turbo_16K_0125[] = U"gpt-3.5-turbo-0125";

/// @brief GPT-4 8K
/// @see https://platform.openai.com/docs/models/gpt-4-and-gpt-4-turbo
inline constexpr char32 GPT4[] = U"gpt-4";

/// @brief GPT-4 32K
/// @brief GPT-4 Turbo 128K
/// @see https://platform.openai.com/docs/models/gpt-4-and-gpt-4-turbo
inline constexpr char32 GPT4_32K[] = U"gpt-4-32k";
inline constexpr char32 GPT4_Turbo[] = U"gpt-4-turbo";

/// @brief latest GPT-4 Turbo preview
/// @brief GPT-4o 128K
/// @see https://platform.openai.com/docs/models/gpt-4-and-gpt-4-turbo
inline constexpr char32 GPT4_Turbo_Preview[] = U"gpt-4-turbo-preview";
inline constexpr char32 GPT4o[] = U"gpt-4o";
}

/// @brief メッセージのロール | Message role
Expand Down Expand Up @@ -84,7 +75,7 @@ namespace s3d
Array<std::pair<Role, String>> messages;

/// @brief モデル | Model
String model = Model::GPT3_5_Turbo;
String model = Model::GPT4o;

/// @brief レスポンスのフォーマット | Response format
/// @remark `ResponseFormat::JSON` を指定した場合、メッセージには "JSON" という言葉を含める必要があります。 | If `ResponseFormat::JSON` is specified, the message must contain the word "JSON".
Expand All @@ -98,11 +89,11 @@ namespace s3d
/// @brief ChatGPT にメッセージを送り、その返答メッセージを取得します。 | Sends a message to ChatGPT and retrieves the response message.
/// @param apiKey OpenAI API キー | OpenAI API key
/// @param message メッセージ | Message
/// @param model 使用するモデル | The model to be used (default: Model::GPT3_5_Turbo)
/// @param model 使用するモデル | The model to be used (default: Model::GPT4o)
/// @return 返答メッセージ。取得に失敗した場合は空の文字列 | Response message. An empty string if the retrieval fails.
/// @remark インターネットアクセスが必要です。 | Internet access is required.
[[nodiscard]]
String Complete(StringView apiKey, StringView message, StringView model = Model::GPT3_5_Turbo);
String Complete(StringView apiKey, StringView message, StringView model = Model::GPT4o);

/// @brief ChatGPT にメッセージを送り、その返答メッセージを取得します。 | Sends messages to ChatGPT and retrieves the response message.
/// @param apiKey OpenAI API キー | OpenAI API key
Expand All @@ -124,12 +115,12 @@ namespace s3d
/// @brief ChatGPT にメッセージを送り、レスポンス(JSON)を取得する非同期タスクを返します。 | Returns an asynchronous task for sending a message to ChatGPT and retrieving the response (JSON).
/// @param apiKey OpenAI API キー | OpenAI API key
/// @param message メッセージ | Message
/// @param model 使用するモデル | The model to be used (default: Model::GPT3_5_Turbo)
/// @param model 使用するモデル | The model to be used (default: Model::GPT4o)
/// @return 非同期タスク | Asynchronous task
/// @remark 戻り値の task が `(task.isReady() == true) && (task.getResponse().isOK() == true)` になれば結果を取得できます。 | The result can be retrieved if `(task.isReady() == true) && (task.getResponse().isOK() == true)`.
/// @remark インターネットアクセスが必要です。 | Internet access is required.
[[nodiscard]]
AsyncHTTPTask CompleteAsync(StringView apiKey, StringView message, StringView model = Model::GPT3_5_Turbo);
AsyncHTTPTask CompleteAsync(StringView apiKey, StringView message, StringView model = Model::GPT4o);

/// @brief ChatGPT にメッセージを送り、レスポンス(JSON)を取得する非同期タスクを返します。 | Returns an asynchronous task for sending messages to ChatGPT and retrieving the response (JSON).
/// @param apiKey OpenAI API キー | OpenAI API key
Expand Down
4 changes: 2 additions & 2 deletions Siv3D/include/Siv3D/OpenAI/Vision.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ namespace s3d
{
/// @brief GPT-4 Turbo with vision 128K
/// @see https://platform.openai.com/docs/models/gpt-4-and-gpt-4-turbo
inline constexpr char32 GPT4V_Turbo_128K_Preview[] = U"gpt-4-vision-preview";
inline constexpr char32 GPT4o[] = U"gpt-4o";
}

/// @brief 画像データ | Image data
Expand Down Expand Up @@ -78,7 +78,7 @@ namespace s3d
Array<ImageData> images;

/// @brief モデル | Model
String model = Model::GPT4V_Turbo_128K_Preview;
String model = Model::GPT4o;

/// @brief 最大トークン数 | Maximum number of tokens
int32 maxTokens = 600;
Expand Down

0 comments on commit ec5c603

Please sign in to comment.