kaixindelele / ChatPaper

Use ChatGPT to summarize the arXiv papers. 全流程加速科研,利用chatgpt进行论文全文总结+专业翻译+润色+审稿+审稿回复
https://chatwithpaper.org
Other
18.19k stars 1.91k forks source link

关于添加第三方oepnai代理接口的功能 #225

Open Karenina-na opened 1 year ago

Karenina-na commented 1 year ago

您好,本项目目前是只能使用openai官方的接口和key吗,我想使用第三方的api接口比如 api2d 目前项目能够做到吗,谢谢。 api2d 接口示例:

const https = require('https');

var postData = JSON.stringify({
  model: 'gpt-3.5-turbo',
  messages: [{ role: 'user', content: '你好!给我讲个笑话。' }],
});

var options = {
  hostname: 'openai.api2d.net',
  port: 443,
  path: '/v1/chat/completions',
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    Authorization: 'Bearer fkxxxxx', // <-- 把 fkxxxxx 替换成你自己的 Forward Key,注意前面的 Bearer 要保留,并且和 Key 中间有一个空格。
  },
};

var req = https.request(options, (res) => {
  console.log('statusCode:', res.statusCode);
  console.log('headers:', res.headers);

  res.on('data', (d) => {
    process.stdout.write(d);
  });
});

req.on('error', (e) => {
  console.error(e);
});

req.write(postData);
req.end();
gxandys commented 1 year ago

强烈建议添加api2d的api。openai账号时不时就被封->找靠谱梯子->注册再被封。。。。太痛苦了!

Hezhexi2002 commented 1 year ago

您好,本项目目前是只能使用openai官方的接口和key吗,我想使用第三方的api接口比如 api2d 目前项目能够做到吗,谢谢。 api2d 接口示例:

const https = require('https');

var postData = JSON.stringify({
  model: 'gpt-3.5-turbo',
  messages: [{ role: 'user', content: '你好!给我讲个笑话。' }],
});

var options = {
  hostname: 'openai.api2d.net',
  port: 443,
  path: '/v1/chat/completions',
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    Authorization: 'Bearer fkxxxxx', // <-- 把 fkxxxxx 替换成你自己的 Forward Key,注意前面的 Bearer 要保留,并且和 Key 中间有一个空格。
  },
};

var req = https.request(options, (res) => {
  console.log('statusCode:', res.statusCode);
  console.log('headers:', res.headers);

  res.on('data', (d) => {
    process.stdout.write(d);
  });
});

req.on('error', (e) => {
  console.error(e);
});

req.write(postData);
req.end();

gpt_acadamic可以接第三方代理接口

QianXuZOZ commented 1 year ago

找到解决的办法了,以chat_paper.py为例, 首先在

class Paper:
def __init__(self, path, title='', url='', abs='', authers=[]):

内如第40行增加代码 openai.api_base = "https://oa.api2d.net/v1" 然后搜索所有的print("response_time:", response.response_ms / 1000.0, 's')全部注释掉即可 增加代码是为了实现api2d的接入,注释掉部分代码是防止程序进入死循环

Hezhexi2002 commented 1 year ago

找到解决的办法了,以chat_paper.py为例, 首先在

class Paper:
def __init__(self, path, title='', url='', abs='', authers=[]):

内如第40行增加代码 openai.api_base = "https://oa.api2d.net/v1" 然后搜索所有的print("response_time:", response.response_ms / 1000.0, 's')全部注释掉即可 增加代码是为了实现api2d的接入,注释掉部分代码是防止程序进入死循环

这种方法可以使用第三方反向代理得到的key吗

QianXuZOZ commented 1 year ago

不好意思,没接触过第三方反向代理的key  

 

------------------ Original ------------------ From: @.>; Date: 2023年8月3日(星期四) 下午5:47 To: @.>; Cc: @.>; @.>; Subject: Re: [kaixindelele/ChatPaper] 关于添加第三方oepnai代理接口的功能 (Issue #225)

找到解决的办法了,以chat_paper.py为例, 首先在 class Paper: def init(self, path, title='', url='', abs='', authers=[]):
内如第40行增加代码 openai.api_base = "https://oa.api2d.net/v1" 然后搜索所有的print("response_time:", response.response_ms / 1000.0, 's')全部注释掉即可 增加代码是为了实现api2d的接入,注释掉部分代码是防止程序进入死循环

这种方法可以使用第三方反向代理得到的key吗

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.Message ID: @.***>

Karenina-na commented 1 year ago

找到解决的办法了,以chat_paper.py为例, 首先在

class Paper:
def __init__(self, path, title='', url='', abs='', authers=[]):

内如第40行增加代码 openai.api_base = "https://oa.api2d.net/v1" 然后搜索所有的print("response_time:", response.response_ms / 1000.0, 's')全部注释掉即可 增加代码是为了实现api2d的接入,注释掉部分代码是防止程序进入死循环

是所有的都需要更换吗,还是只用换chat_paper.py里面的