增加最新的 chat completions 接口支持(https://api.openai.com/v1/chat/completions),使用 gpt-3.5-turbo 模型,相比 text-davinci-003 成本隆低 90%
CREATE TABLE `openai_chat_completion` (
`id` varchar(36) COLLATE utf8mb4_general_ci NOT NULL DEFAULT 'uuid()' COMMENT 'UUID',
`prompt` varchar(1000) COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '提问',
`lines` tinyint(4) NOT NULL DEFAULT '1' COMMENT '行数',
`create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='文本应该会话';
ALTER TABLE `openai_chat_completion`
ADD PRIMARY KEY (`id`);
CREATE TABLE `openai_chat_completion_message` (
`id` varchar(36) COLLATE utf8mb4_general_ci NOT NULL DEFAULT 'uuid()' COMMENT 'UUID',
`chat_completion_id` varchar(36) COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '会话ID',
`line` tinyint(4) NOT NULL DEFAULT '1' COMMENT '行号',
`prompt` varchar(1000) COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '提问',
`answer` text COLLATE utf8mb4_general_ci NOT NULL COMMENT '回答',
`times` tinyint(4) NOT NULL DEFAULT '0' COMMENT '失败重试次数',
`is_complete` tinyint(4) NOT NULL DEFAULT '0' COMMENT '是否完成',
`create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='文本应该会话记录';
ALTER TABLE `openai_chat_completion_message`
ADD PRIMARY KEY (`id`),
ADD KEY `chat_completion_id` (`chat_completion_id`);