사이트 활용팁

chatGPT 활용한 댓글 답변 게시판

해당 경로 파일에, 아래 소스코드 추가

	// CHATGPT 추가 시작
	if ($chatgpt){ //CHATGPT 요청

		$api_key = $config['cf_1'];
		$url = "https://api.openai.com/v1/chat/completions";

		$post_fields = array(
			"model" => "gpt-3.5-turbo",
			"messages" => array(
				array(
					"role" => "user",
					"content" => $wr_content
				)
			),
			"max_tokens" => 4000,
			"temperature" => 0
		);

		$header  = [
			'Content-Type: application/json',
			'Authorization: Bearer ' . $api_key
		];

		$ch = curl_init();
		curl_setopt($ch, CURLOPT_URL, $url);
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
		curl_setopt($ch, CURLOPT_POST, 1);
		curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($post_fields));
		curl_setopt($ch, CURLOPT_HTTPHEADER, $header);

		$result = curl_exec($ch);
		if (curl_errno($ch)) {
			echo 'Error: ' . curl_error($ch);
		}
		curl_close($ch);
		$result_json = json_decode($result, true);
		$wr_link2 = $result_json["choices"][0]["message"]['content'];
	}
	// CHATGPT 추가 끝
관련링크
이전글 제목을 해시태그로 자동 변환 소스코드
다음글 뱃지 및 강조할 내용 추가
Warning: include_once(/volume4/web/rebuilder/theme/main/skin/board/main_board/view_comment.skin.php): Failed to open stream: No such file or directory in /volume4/web/rebuilder/bbs/view_comment.php on line 127 Warning: include_once(): Failed opening '/volume4/web/rebuilder/theme/main/skin/board/main_board/view_comment.skin.php' for inclusion (include_path='/volume4/web/rebuilder/plugin/htmlpurifier/standalone:.:/usr/share/pear') in /volume4/web/rebuilder/bbs/view_comment.php on line 127