<?php
$text=$_GET['text'];
$id=$_GET['id'];
$key="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";//只需要改这一个地方,这里填你的SK
if($id==1){
session_start();
if (!$_SESSION['chatgptSessionPrompt']) {
$_SESSION['chatgptSessionPrompt'] = '';
}
$ch = curl_init();
$prompt=$_SESSION['chatgptSessionPrompt'] .'\n提问:' . $text . '\n Ai:';
$chatgptaray=array('\n提问:','\nAI:');
curl_setopt($ch, CURLOPT_URL, "https://api.openai.com/v1/completions");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, '{
"model": "text-davinci-003",
"prompt": "'.$prompt.'",
"max_tokens": 2048
}');
curl_setopt($ch, CURLOPT_POST, 1);
// Set the API key as an HTTP header
$headers = array();
$headers[] = "Content-Type: application/json";
$headers[] = "Authorization: Bearer ".$key;
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
// Send the request and parse the response
$response = curl_exec($ch);
$response_data = json_decode($response, true);
$_SESSION['chatgptSessionPrompt'] = $prompt . $response_data['data'];
if (curl_errno($ch)) {
// If there was an error executing the cURL request, print it out
echo 'Error: ' . curl_error($ch);
} else {
$result = array(
'code'=> 200,
'msg'=>"获取成功",
'data'=>array(
'html'=> $response_data['choices'][0]['text'],
'title'=>$text
),
);
echo json_encode($result,320);
exit();
}
curl_close($ch);
}
if($id==2){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.openai.com/v1/images/generations");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, '{
"n": 1,
"prompt": "'.$text.'",
"size": "256x256"
}');
curl_setopt($ch, CURLOPT_POST, 1);
// Set the API key as an HTTP header
$headers = array();
$headers[] = "Content-Type: application/json";
$headers[] = "Authorization: Bearer ".$key;
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
// Send the request and parse the response
$response = curl_exec($ch);
$response_data = json_decode($response, true);
if (curl_errno($ch)) {
// If there was an error executing the cURL request, print it out
echo 'Error: ' . curl_error($ch);
} else {
$result = array(
'code'=> 200,
'msg'=>"获取成功",
'data'=>array(
'url'=> $response_data['data'][0]['url'],
'title'=>$text
),
);
echo json_encode($result,320);
exit();
}
curl_close($ch);
}
?>
没有合适的资源?快使用搜索试试~ 我知道了~
GPT镜像包,可图可文字,gpt3.5,需要自己的API
1星 需积分: 1 26 下载量 12 浏览量
2023-05-11
23:12:58
上传
评论 3
收藏 9.31MB GZ 举报
温馨提示
共35个文件
jpg:14个
js:4个
css:4个
GPT镜像包,可图可文字,gpt3.5,需要自己的API
资源推荐
资源详情
资源评论
收起资源包目录
gpt镜像.tar.gz (35个子文件)
c
js
wangEditor.min.js 256KB
toast.js 2KB
img
mm
2.jpg 1.33MB
6.jpg 1.17MB
1.jpg 2.43MB
5.jpg 427KB
3.jpg 1.16MB
7.jpg 2.07MB
4.jpg 796KB
speech.png 7KB
css
common.css 41KB
wenda.css 4KB
chatgptApi.php 2KB
__MACOSX
._js 212B
._css 212B
js
._wangEditor.min.js 212B
._toast.js 212B
img
mm
._5.jpg 212B
._2.jpg 212B
._3.jpg 212B
._7.jpg 212B
._1.jpg 212B
._4.jpg 212B
._6.jpg 212B
._mm 212B
._speech.png 212B
._index.html 212B
css
._common.css 212B
._wenda.css 212B
._chatgptApi.php 212B
._img 212B
fonts
._iconfont.woff2 212B
._fonts 212B
gpt.html 7KB
fonts
iconfont.woff2 3KB
共 35 条
- 1
资源评论
- qq_529713772023-12-15#标题与内容不符
大群群主
- 粉丝: 9
- 资源: 3
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- Picasso_v3.1 2.ipa
- chromedriver-mac-arm64.zip
- 蓝zapro.apk
- chromedriver-linux64.zip
- UCAS研一深度学习实验-MNIST手写数字识别python源码+详细注释(高分项目)
- 基于Python和PyTorch框架完成的一个手写数字识别实验源码(带MINIST手写数字数据集)+详细注释(高分项目)
- 基于Matlab在MNIST数据集上利用CNN完成手写体数字识别任务,并实现单层CNN反向传播算法+源代码+文档说明(高分项目)
- NVIDIA驱动、CUDA和Pytorch及其依赖
- 基于SVM多特征融合的微表情识别python源码+项目说明+详细注释(高分课程设计)
- html动态爱心代码一(附源码)
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功