限时特惠: 腾讯云服务器 1年92、3年只要388 !做个智能机器人啥的~
入口: https://url.cn/B4K9jWu0
import requests
def chatgpt_bot(msg='hello'):
'''
(URL失效)
接口来自: https://chat.bujj.org/
网站源码: https://github.com/ddiu8081/chatgpt-demo
'''
url = 'https://chatgpt.ddiu.me/api/generate'
data = {"messages":[{"role":"user","content":msg}]}
headers = {
'Content-Type': 'text/plain;charset=UTF-8'
}
proxies = {
'http': 'http://127.0.0.1:7890',
'https': 'http://127.0.0.1:7890'
}
resp = requests.post(url=url, json=data, headers=headers, proxies=proxies)
resp.encoding = 'utf-8'
return resp.text.strip()
def chatgpt_bot2(msg='hello'):
url = f'https://v1.apigpt.cn/?q={msg}&apitype=sql'
resp = requests.get(url=url)
resp.encoding = 'utf-8'
return resp.json()['ChatGPT_Answer'].strip()
def chatgpt_bot3(msg='hello'):
url = 'https://api.caonm.net/api/ai/o.php?msg=' + msg
resp = requests.get(url=url)
resp.encoding = 'utf-8'
return resp.json()['Output'].strip()
def chatgpt_bot4(msg='hello'):
'''响应非常慢'''
url = f'https://v1.welm.cc/?q={msg}&apitype=sql'
resp = requests.get(url=url)
resp.encoding = 'utf-8'
return resp.json()['Welm_Answer'].strip()
def chatgpt_bot5(msg='hello'):
token = 'sk-76f1c7a8cbfb2854a5ca5ac0ec6ebcecAPIGPT-v2'
url = f'https://v2.apigpt.cn?q={msg}&key={token}&id=123456&conversationId=123456&token=123456'
resp = requests.get(url=url)
resp.encoding = 'utf-8'
return resp.json()['text'].strip()
def chatgpt_bot6(msg='hello'):
url = 'https://open-gpt.app/api/generate'
data = {"userInput":msg,"id":"clezxas4j0000mn0863j0lw7h","userKey":""}
resp = requests.post(url=url, json=data)
resp.encoding = 'utf-8'
return resp.text.strip()
def chatgpt_bot7(msg='hello'):
url = 'https://ai117.com/'
data = {"msg":msg,"token":"","style":"0"}
resp = requests.post(url=url, json=data)
resp.encoding = 'utf-8'
return resp.json()['data'][1].strip().replace("(如未显示完全,请填写APIKEY获取完整消息)", "")
def chatgpt_bot8(msg='hello'):
url = 'https://askai.ws/api/chatgpt/ask'
data = {"type":"text","keepChat":false,"question":msg}
resp = requests.post(url=url, json=data)
resp.encoding = 'utf-8'
return resp.text.strip()
print(chatgpt_bot2('你好'))
print(chatgpt_bot3('你好'))
评论 (1)