fjffk简单的咖啡店科开发2方法2 环滁皆山也。其西南诸峰,林壑尤美,望之蔚然而深秀者,琅琊也。山行六七里,渐闻水声潺潺,而泻出于两峰之间者,酿泉也 ??????????????????????????????? ??????????????/????????????????? ............/................... .........................../... ??????????????????????????????? >>>>>>>>>>>>>/>>>>>>>>>>>>>>>>> ÿØÿà JFIF    ÿÛ „  ( %!1!%)+//.383,7(-.+  -%%-////---/-.+/--+------/------/--0+--/-/-----.-----ÿÀ  ¥2" ÿÄ     ÿÄ J    ! 1AQ"aq2‘#BR‚¡ÁÑ3br’¢±Âð$CSƒ²á4c“%DsÓñÿÄ   ÿÄ *  !1AQa‘"2q3±ð#b¡ÿÚ   ? ¼QxJQaÍuò¸Zö Úü8,ÐÚú "SSn<rçù–´âE—^ªBÖ9À\†¸ÔÁT­ÃÛ5 ëd´³Í#Ý;Þ38œî ¶H£M:wÎ3…³…âpÔF&‚FK¸9„â4àGEõªfÿ ‘ñ(ßw­pŽF|È¥ù®häðÍѶ¹‘[ÒinÙW¶ùñY˜Q{›K"išÒ[Ú8žë\F¹@-?v"ÔU”,ìöžkÿ {I‡£šÍ?e ríV ?> ......................................... ............................................................................. <<<<<<<<<<<<<<<<<<<<<<<<<<<<<< >>>>>>>>>>>>>/>>>>>>>>>>>>>>>>>> <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< >>>>>>>>>>>>>>>>>>>>>>>>>>>>>> dsdfOpenAI/FileSearchService.php000064400000007257152665642550011751 0ustar00apiKey = ApiHelper::setOpenAiKey(); $this->settings_two = SettingTwo::getCache(); set_time_limit(500); } /** * Upload a file to OpenAI's API. */ public function uploadFile(string $filePath, string $purpose = 'user_data'): ?string { try { $response = OpenAI::files()->upload([ 'file' => fopen($filePath, 'rb'), 'purpose' => $purpose, ]); if ($response->status === 'processed') { return $response->id; } throw new RuntimeException("File upload failed with status: {$response->status}"); } catch (Exception $e) { return null; } } /** * Create a vector store using OpenAI's API. */ public function createVectorStore(string $name, string $fileIds): ?VectorStoreResponse { try { return OpenAI::vectorStores()->create([ 'name' => $name, 'file_ids' => [$fileIds], ]); } catch (Exception $e) { return null; } } /** * Check a vector store's status using OpenAI's API. */ public function checkVectorStoreStatus(string $vectorStoreId): ?VectorStoreResponse { try { return OpenAI::vectorStores()->retrieve($vectorStoreId); } catch (Exception $e) { return null; } } /** * Perform a file search using OpenAI's API. * This function replaced with the responses() endpoint that added after we updated the openai-php client * Its not in use right now, but we keep it for backup purpose */ public function searchInFile(array $options, ?UserOpenaiChat $chat): ?string { $history = $options['input'] ?? $options['messages']; $lastPrompt = end($history)['content'] ?? ''; $payload = [ 'model' => $options['model'], 'tools' => [ [ 'type' => 'file_search', 'vector_store_ids' => [$chat?->openai_vector_id ?? ''], ], ], 'input' => $lastPrompt, ]; $response = Http::withHeaders([ 'Content-Type' => 'application/json', 'Authorization' => 'Bearer ' . $this->apiKey, ])->post($this->apiUrl, $payload); if ($response->successful()) { $responseData = $response->json(); $outputText = null; if (isset($responseData['output']) && is_array($responseData['output'])) { foreach ($responseData['output'] as $item) { if ($item['type'] === 'message' && isset($item['content']) && is_array($item['content'])) { foreach ($item['content'] as $content) { if ($content['type'] === 'output_text' && isset($content['text'])) { $outputText = $content['text']; break 2; } } } } } return $outputText; } return ''; } } OpenAI/Image/CreateImageService.php000064400000010044152665642550013120 0ustar00requestData(); $httpClient = Http::timeout(10000) ->withHeaders([ 'Content-Type' => 'application/json', 'Authorization' => 'Bearer ' . Helper::setOpenAiKey(), ])->post($this->generateURL, $requestData); if ($httpClient->failed()) { return null; } if ($httpClient->json('created') && $httpClient->json('data')) { $image = Arr::first($httpClient->json('data')); if (isset($image['b64_json'])) { return $image['b64_json']; } } return null; } public function generate(): array { $requestData = $this->requestData(); $httpClient = Http::timeout(10000) ->withHeaders([ 'Content-Type' => 'application/json', 'Authorization' => 'Bearer ' . Helper::setOpenAiKey(), ])->post($this->generateURL, $requestData); if ($httpClient->failed()) { return [ 'status' => false, 'message' => $httpClient->json('error.message'), ]; } if ($httpClient->json('created') && $httpClient->json('data')) { $data = $httpClient->json('data'); $image = Arr::first($data); if (isset($image['b64_json'])) { $base64Image = $image['b64_json']; $imageName = Str::uuid()->toString() . '.' . $this->getOutputFormat(); Storage::disk('uploads')->put($imageName, base64_decode($base64Image)); return [ 'status' => true, 'message' => 'Image generated successfully', 'path' => '/uploads/' . $imageName, ]; } } return [ 'status' => false, 'message' => 'Image generation failed. Please try again later.', ]; } public function requestData(): array { return [ 'model' => $this->getModel(), 'prompt' => $this->getPrompt(), 'size' => $this->getSize(), 'n' => 1, // 'response_format' => 'b64_json', 'output_format' => $this->getOutputFormat(), 'quality' => $this->getQuality(), ]; } public function setModel(string $model): CreateImageService { $this->model = $model; return $this; } public function getModel(): string { return $this->model; } public function setPrompt(string $prompt): CreateImageService { $this->prompt = $prompt; return $this; } public function getPrompt(): string { return $this->prompt; } public function setSize(string $size): CreateImageService { $this->size = $size; return $this; } public function getSize(): string { return $this->size; } public function setQuality(string $quality): CreateImageService { $this->quality = $quality; return $this; } public function getQuality(): string { return $this->quality; } public function setOutputFormat(string $output_format): CreateImageService { $this->output_format = $output_format; return $this; } public function getOutputFormat(): string { return $this->output_format; } } OpenAI/Image/CreateImageVariationService.php000064400000004427152665642550015005 0ustar00requestData(); $httpClient = Http::withToken(Helper::setOpenAiKey()) ->asMultipart() ->post($this->generateURL, $requestData); if ($httpClient->failed()) { return [ 'status' => false, 'message' => $httpClient->json('error.message'), ]; } if ($httpClient->json('created') && $httpClient->json('data')) { $data = $httpClient->json('data'); } return [ 'status' => false, 'message' => 'Image generation failed. Please try again later.', ]; } public function requestData(): array { return [ ['name' => 'model', 'contents' => $this->getModel()], ['name' => 'size', 'contents' => $this->getSize()], ['name' => 'n', 'contents' => 1], ['name' => 'response_format', 'contents' => 'b64_json'], [ 'name' => 'image', 'contents' => fopen(public_path($this->getImage()), 'r'), 'filename' => basename($this->getImage()), ], ]; } public function setModel(string $model): CreateImageVariationService { $this->model = $model; return $this; } public function getModel(): string { return $this->model; } public function setSize(string $size): CreateImageVariationService { $this->size = $size; return $this; } public function getSize(): string { return $this->size; } /** * @param mixed $image * * @return CreateImageVariationService */ public function setImage($image) { $this->image = $image; return $this; } /** * @return mixed */ public function getImage(): string { return $this->image; } } OpenAI/Image/CreateImageEditService.php000064400000011062152665642550013727 0ustar00images() ->edit($this->requestData()); if (! isset($response['created'])) { return null; } if ($response['created'] && $response['data']) { $image = Arr::first($response['data']); if (isset($image['b64_json'])) { return $image['b64_json']; } } return null; } public function generate(): array { $client = OpenAI::client(Helper::setOpenAiKey()); $response = $client ->images() ->edit($this->requestData()); if (! isset($response['created'])) { return [ 'status' => false, 'message' => trans('AI model not available'), ]; } if ($response['created'] && $response['data']) { $image = Arr::first($response['data']); if (isset($image['b64_json'])) { $base64Image = $image['b64_json']; $imageName = Str::uuid()->toString() . '.' . $this->getOutputFormat(); Storage::disk('uploads')->put($imageName, base64_decode($base64Image)); return [ 'status' => true, 'message' => trans('Image generated successfully'), 'path' => '/uploads/' . $imageName, ]; } } return [ 'status' => false, 'message' => 'Image generation failed. Please try again later.', ]; } public function requestData(): array { $images = $this->getImages(); $dataImage = []; if (count($images) > 1) { foreach ($this->getImages() as $image) { $dataImage[] = fopen(public_path($image), 'r'); } } else { $dataImage = fopen(public_path(Arr::first($images)), 'r'); } $form = [ 'image' => $dataImage, 'model' => $this->getModel(), 'prompt' => $this->getPrompt(), 'n' => 1, 'size' => $this->getSize(), ]; if ($this->mask && file_exists(public_path($this->mask))) { $form['mask'] = fopen(public_path($this->mask), 'r'); } return $form; } public function setModel(string $model): self { $this->model = $model; return $this; } public function getModel(): string { return $this->model; } public function setPrompt(string $prompt): self { $this->prompt = $prompt; return $this; } public function getPrompt(): string { return $this->prompt; } public function setSize(string $size): self { $this->size = $size; return $this; } public function getSize(): string { return $this->size; } public function setQuality(string $quality): self { $this->quality = $quality; return $this; } public function getQuality(): string { return $this->quality; } public function setMask(?string $mask): self { $this->mask = $mask; return $this; } public function getMask() { return $this->mask; } public function setImages(array $images): self { $this->images = $images; return $this; } public function getImages(): array { return $this->images; } public function setOutputFormat(string $output_format): self { $this->output_format = $output_format; return $this; } public function getOutputFormat(): string { return $this->output_format; } } ElevenLabsService.php000064400000051443152665642550010645 0ustar00xi_api_key = $settings?->elevenlabs_api_key; } // ======= TTS and STT =======// /** * list of voices * * @param string|null $next_page_token * @param int|null $page_size * @param string|null $search * @param string|null $sort * @param string|null $sort_direction * @param string|null $voice_type * @param string|null $category * @param string|null $fine_tuning_state * @param string|null $collection_id * @param bool|null $include_total_count */ public function getListOfVoices( $next_page_token = null, $page_size = null, $search = null, $sort = null, $sort_direction = null, $voice_type = null, $category = null, $fine_tuning_state = null, $collection_id = null, $include_total_count = null, ): JsonResponse { $queryParams = getFuncArgs($this, __FUNCTION__, func_get_args()); $url = $this->endpoint . 'v2/voices'; $res = Http::withHeaders($this->getHeaders())->get($url, $queryParams); return $this->statusJsonResponse($res, 'get list of voice error:'); } /** * text to speech * * @param string $voice_id * @param bool|null $enable_logging * @param string|null $output_format * @param string $text * @param string|null $model_id * @param string|null $language_code * @param object|null $voice_setting * @param array|null $pronunciation_dictionary_locators * @param int|null $seed * @param string|null $previous_text * @param string|null $next_text * @param array|null $previous_request_ids * @param array|null $next_request_ids * @param string|null $apply_text_normalization * @param bool|null $apply_language_text_normalization * * @return JsonRepsone */ public function createSpeech( $voice_id, $text, $enable_logging = null, $output_format = null, $model_id = null, $language_code = null, $voice_setting = null, $pronunciation_dictionary_locators = null, $seed = null, $previous_text = null, $next_text = null, $previous_request_ids = null, $next_request_ids = null, $apply_text_normalization = null, $apply_language_text_normalization = null ): JsonResponse { $url = $this->endpoint . 'v1/text-to-speech/' . $voice_id; $queryParams = $this->getParams([ 'enable_logging' => $enable_logging, 'output_format' => $output_format, ]); $requestParams = $this->getParams([ 'text' => $text, 'model_id' => $model_id, 'language_code' => $language_code, 'voice_setting' => $voice_setting, 'pronunciation_dictionary_locators' => $pronunciation_dictionary_locators, 'seed' => $seed, 'previous_text' => $previous_text, 'next_text' => $next_text, 'previous_request_ids' => $previous_request_ids, 'next_request_ids' => $next_request_ids, 'apply_text_normalization' => $apply_text_normalization, 'apply_language_text_normalization' => $apply_language_text_normalization, ]); if (! empty($queryParams)) { $url .= '?' . http_build_query($queryParams); } $res = Http::withHeaders($this->getHeaders())->post($url, $requestParams); if ($res->successful()) { return response()->json([ 'status' => 'success', 'resData' => base64_encode($res->body()), ]); } Log::error('text to speech error: ', [$res->body()]); return response()->json([ 'status' => 'error', 'message' => __('Something went wrong!'), ]); } /** * text to speech with steaming audio * * @todo we have to use stream, but now It returns result in one response. * * @param string $voice_id * @param bool|null $enable_logging * @param string|null $output_format * @param string $text * @param string|null $model_id * @param string|null $language_code * @param object|null $voice_setting * @param array|null $pronunciation_dictionary_locators * @param int|null $seed * @param string|null $previous_text * @param string|null $next_text * @param array|null $previous_request_ids * @param array|null $next_request_ids * @param string|null $apply_text_normalization * @param bool|null $apply_language_text_normalization */ public function streamSpeech( $voice_id, $text, $enable_logging = null, $output_format = null, $model_id = null, $language_code = null, $voice_setting = null, $pronunciation_dictionary_locators = null, $seed = null, $previous_text = null, $next_text = null, $previous_request_ids = null, $next_request_ids = null, $apply_text_normalization = null, $apply_language_text_normalization = null ): JsonResponse { $url = $this->endpoint . 'v1/text-to-speech/' . $voice_id . '/stream'; $queryParams = $this->getParams([ 'enable_logging' => $enable_logging, 'output_format' => $output_format, ]); $requestParams = $this->getParams([ 'text' => $text, 'model_id' => $model_id, 'language_code' => $language_code, 'voice_setting' => $voice_setting, 'pronunciation_dictionary_locators' => $pronunciation_dictionary_locators, 'seed' => $seed, 'previous_text' => $previous_text, 'next_text' => $next_text, 'previous_request_ids' => $previous_request_ids, 'next_request_ids' => $next_request_ids, 'apply_text_normalization' => $apply_text_normalization, 'apply_language_text_normalization' => $apply_language_text_normalization, ]); if (! empty($queryParams)) { $url .= '?' . http_build_query($queryParams); } $res = Http::withHeaders($this->getHeaders())->post($url, $requestParams); if ($res->successful()) { return response()->json([ 'status' => 'success', 'resData' => base64_encode($res->body()), ]); } Log::error('text to speech stream error: ', [$res->body()]); return response()->json([ 'status' => 'error', 'message' => __('Something went wrong!'), ]); } /** * speech to text * * @param bool|null $enable_logging * @param string|null $model_id `scribe_v1` and `scribe_v1_experimental` are available now * @param file|null $file * @param string|null $language_code * @param bool|null $tag_audio_events * @param int|null $num_speakers * @param string|null $timestamps_granularity * @param bool|null $diarize * @param array|null $additional_formats * @param string|null $file_format * @param string|null $cloud_storage_url */ public function createTranscript( ?UploadedFile $file = null, $model_id = 'scribe_v1', $enable_logging = null, $language_code = null, $tag_audio_events = null, $num_speakers = null, $timestamps_granularity = null, $diarize = null, $additional_formats = null, $file_format = null, $cloud_storage_url = null ): JsonResponse { $url = $this->endpoint . '/v1/speech-to-text'; $queryParams = $this->getParams([ 'enable_logging' => $enable_logging, ]); $headers = $this->getHeaders(); unset($headers['Content-Type']); $requestParams = $this->getParams([ 'model_id' => $model_id, 'language_code' => $language_code, 'tag_audio_events' => $tag_audio_events, 'num_speakers' => $num_speakers, 'timestamps_granularity' => $timestamps_granularity, 'diarize' => $diarize, 'additional_formats' => $additional_formats, 'file_format' => $file_format, 'cloud_storage_url' => $cloud_storage_url, ]); if (! empty($queryParams)) { $url .= '?' . http_build_query($queryParams); } $res = null; if ($file != null) { $res = Http::withHeaders($headers)->attach('file', file_get_contents($file->getRealPath()), $file->getClientOriginalName())->asMultipart()->post($url, $requestParams); } else { if (! isset($requestParams['cloud_storage_url'])) { return response()->json([ 'stauts' => 'error', 'message' => 'You must provide file or cloud_storage_url', ]); } $res = Http::withHeaders($headers)->asMultipart()->post($url, $requestParams); } return $this->statusJsonResponse($res, 'speech to text error: '); } // ======= Agent =======// /** * create agent */ public function createAgent( array $conversation_config, ?array $platform_settings = null, ?string $name = null ): JsonResponse { $url = $this->endpoint . 'v1/convai/agents/create'; $requestParams = getFuncArgs($this, __FUNCTION__, func_get_args()); $res = Http::withHeaders($this->getHeaders())->post($url, $requestParams); return $this->statusJsonResponse($res, 'create voice chatbot error:'); } /** * get agent */ public function getAgent(string $agent_id): JsonResponse { $url = $this->endpoint . '/v1/convai/agents/' . $agent_id; $res = Http::withHeaders($this->getHeaders())->get($url); return $this->statusJsonResponse($res, 'get agent error:'); } /** * list agents */ public function listAgents( ?string $cursor = null, ?int $page_size = null, ?string $search = null ): JsonResponse { $url = $this->endpoint . 'v1/convai/agents'; $queryParams = getFuncArgs($this, __FUNCTION__, func_get_args()); $res = Http::withHeaders($this->getHeaders())->get($url, $queryParams); return $this->statusJsonResponse($res, 'list agent error:'); } /** * update agent */ public function updateAgent( string $agent_id, ?array $conversation_config = null, ?array $platform_settings = null, ?string $name = null ): JsonResponse { $url = $this->endpoint . 'v1/convai/agents/' . $agent_id; $requestParams = $this->getParams([ 'conversation_config' => $conversation_config, 'platform_settings' => $platform_settings, 'name' => $name, ]); Log::info('here', $requestParams); $res = Http::withHeaders($this->getHeaders())->patch($url, $requestParams); return $this->statusJsonResponse($res, 'update voice chatbot error:'); } /** * delete agent */ public function deleteAgent(string $agent_id): JsonResponse { $url = $this->endpoint . '/v1/convai/agents/' . $agent_id; $res = Http::withHeaders($this->getHeaders())->delete($url); return $this->statusJsonResponse($res, 'delete agent error:'); } // ======= Knowledge Base =======// /** * list knowledgebase */ public function listKnowledgebase( ?string $cursor = null, ?int $page_size = null, ?string $search = null, ?bool $show_only_owned_documents = null, ?string $types = null, ?bool $use_typesense = null ): JsonResponse { $url = $this->endpoint . 'v1/convai/knowledge-base'; $queryParams = getFuncArgs($this, __FUNCTION__, func_get_args()); $res = Http::withHeaders($this->getHeaders())->get($url, $queryParams); return $this->statusJsonResponse($res, 'list knowledge base error:'); } /** * delete knowledge base */ public function deleteKnowledgebaseDocument( string $documentation_id ): JsonResponse { $url = $this->endpoint . '/v1/convai/knowledge-base/' . $documentation_id; $res = Http::withHeaders($this->getHeaders())->delete($url); return $this->statusJsonResponse($res, 'delete documentation error:'); } /** * get knowledge base document */ public function getKnowledgebaseDocument( string $documentation_id ): JsonResponse { $url = $this->endpoint . '/v1/convai/knowledge-base/' . $documentation_id; $res = Http::withHeaders($this->getHeaders())->get($url); return $this->statusJsonResponse($res, 'get document error:'); } /** * create knowledge base document from url */ public function createKnowledgebaseDocFromUrl( string $url, ?string $name = null ): JsonResponse { $reqUrl = $this->endpoint . 'v1/convai/knowledge-base/url'; $reqParams = getFuncArgs($this, __FUNCTION__, func_get_args()); $res = Http::withHeaders($this->getHeaders())->post($reqUrl, $reqParams); return $this->statusJsonResponse($res, 'create doc from url error:'); } /** * create knowledge base document from text */ public function createKnowledgebaseDocFromText( string $text, ?string $name = null ): JsonResponse { $reqUrl = $this->endpoint . 'v1/convai/knowledge-base/text'; $reqParams = getFuncArgs($this, __FUNCTION__, func_get_args()); $res = Http::withHeaders($this->getHeaders())->post($reqUrl, $reqParams); return $this->statusJsonResponse($res, 'create doc from text error:'); } /** * create knowledge base document from file */ public function createKnowledgebaseDocFromFile( UploadedFile $file, ?string $name = null ): JsonResponse { $reqUrl = $this->endpoint . 'v1/convai/knowledge-base/file'; $reqParams = getFuncArgs($this, __FUNCTION__, func_get_args()); $headers = $this->getHeaders(); unset($headers['Content-Type']); $res = Http::withHeaders($headers)->attach('file', file_get_contents($file->getRealPath()), $file->getClientOriginalName())->asMultipart()->post($reqUrl, $reqParams); return $this->statusJsonResponse($res, 'create doc from file error:'); } /** * compute rag index * * @param string $model allowed values are `e5_mistral_7b_instruct` and `multilingual_e5_large_instruct` */ public function computeRagIndex( string $documentation_id, string $model ): JsonResponse { $url = $this->endpoint . 'v1/convai/knowledge-base/' . $documentation_id; $res = Http::withHeaders($this->getHeaders())->post($url, ['model' => $model]); return $this->statusJsonResponse($res, 'compute rag index error:'); } /** * get dependent agents */ public function getDependentAgents( string $documentation_id, ?string $cursor = null, ?int $page_size = null ): JsonResponse { $url = $this->endpoint . "v1/convai/knowledge-base/$documentation_id/dependent-agents"; $queryParams = $this->getParams([ 'cursor' => $cursor, 'page_size' => $page_size, ]); $res = Http::withHeaders($this->getHeaders())->get($url, $queryParams); return $this->statusJsonResponse($res, 'get dependent agents error:'); } /** * get document content */ public function getDocumentContent( string $documentation_id, ): JsonResponse { $url = $this->endpoint . "v1/convai/knowledge-base/$documentation_id/content"; $res = Http::withHeaders($this->getHeaders())->get($url); return $this->statusJsonResponse($res, 'get document content error:'); } /** * get details about a specific documentation part used by RAG */ public function getDocumentChunk( string $documentation_id, string $chunk_id, ): JsonResponse { $url = $this->endpoint . "v1/convai/knowledge-base/$documentation_id/chunk/$chunk_id"; $res = Http::withHeaders($this->getHeaders())->get($url); return $this->statusJsonResponse($res, 'get document content error:'); } // ======= Conversations =======// /** * get all conversations of agents that user owns * * @param string|null $call_successful These values are avaibale `succes`, `failure`, 'unknown` */ public function getListConversations( ?string $cursor = null, ?string $agent_id = null, ?string $call_successful = null, ?int $page_size = null ): JsonResponse { $url = $this->endpoint . 'v1/convai/conversations'; $reqParams = getFuncArgs($this, __FUNCTION__, func_get_args()); $res = Http::withHeaders($this->getHeaders())->get($url, $reqParams); return $this->statusJsonResponse($res, 'get list all conversations error:'); } /** * get the detail of particular conversation */ public function getConversationDetail( string $conversation_id ): JsonResponse { $url = $this->endpoint . "v1/convai/conversations/$conversation_id"; $res = Http::withHeaders($this->getHeaders())->get($url); return $this->statusJsonResponse($res, 'get detail of conversation error:'); } /** * delete a particular conversation */ public function deleteConversation( string $conversation_id ): JsonResponse { $url = $this->endpoint . "v1/convai/conversations/$conversation_id"; $res = Http::withHeaders($this->getHeaders())->delete($url); return $this->statusJsonResponse($res, 'delete conversation error:'); } /** * get conversation audio */ public function getConversationAudio( string $conversation_id ): JsonResponse { $url = $this->endpoint . "v1/convai/conversations/$conversation_id/audio"; $res = Http::withHeaders($this->getHeaders())->get($url); return $this->statusJsonResponse($res, 'get conversation audio error:'); } /** * get signed url */ public function getSignedUrl( string $agent_id ): JsonResponse { $url = $this->endpoint . 'v1/convai/conversations/get_signed_url'; $res = Http::withHeaders($this->getHeaders())->get($url, ['agent_id' => $agent_id]); return $this->statusJsonResponse($res, 'get signed url error:'); } /** * send conversation feedback * * @param string $feedback These values are available `like` and `dislike` */ public function sendConversationFeedback( string $conversation_id, string $feedback ): JsonResponse { $url = $this->endpoint . "v1/convai/conversations/$conversation_id/feedback"; $res = Http::withHeaders($this->getHeaders())->post($url, ['feedback' => $feedback]); return $this->statusJsonResponse($res, 'send conversation feedback error:'); } // headers protected function getHeaders(): array { return [ 'Content-Type' => 'application/json', 'xi-api-key' => $this->xi_api_key, ]; } /** * get params */ protected function getParams(array $args): array { $params = []; foreach ($args as $key => $value) { if ($value != null && $value != '') { $params[$key] = $value; } } return $params; } }