12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- <?php
- namespace App\Http\Controllers\Api\V1\Chat;
- use App\Facades\AiChatContentFacade;
- use App\Http\Controllers\Api\V1\BaseController;
- use Illuminate\Http\Request;
- /**
- * AI聊天
- */
- class AiChatController extends BaseController
- {
- /**
- * 发送聊天数据
- * @param Request $request
- * @return array
- */
- public function sendData(Request $request)
- {
- return AiChatContentFacade::sendData(
- (int)$this->auth(),
- strval($request->get("conversation_id","")),
- strval($request->get("content",""))
- );
- }
- /**
- * 聊天历史,列表分页
- * @return array
- */
- public function index()
- {
- $conditions = [
- 'Robot' => true,
- 'user_id' => $this->auth(),
- "conversation_id"=>request('conversation_id', null)
- ];
- $fields = ['*'];
- $sort = '`id` asc';
- $page = request('page', 1);
- $limit = request('limit', 20);
- return AiChatContentFacade::getChatContentList($conditions, $fields, $sort, $page, $limit);
- }
- }
|