4 Commits

Author SHA1 Message Date
Yanyutin753
3cc275502a 支持最新的gpt-4-o模型,并重定向gpt-4-mobile到gpt-4-s 2024-05-16 19:34:44 +08:00
Clivia
21fd5b81be 支持 gpt-4o 2024-05-14 18:49:40 +08:00
Clivia
9017ec892f 支持最新的gpt-4o模型 2024-05-14 18:44:47 +08:00
Yanyutin753
12f7d616d7 feat gpt-4-o 支持上传文件 2024-05-14 13:56:58 +08:00
4 changed files with 44 additions and 41 deletions

3
.idea/misc.xml generated
View File

@@ -1,4 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Black">
<option name="sdkName" value="Python 3.8 (pythonProject7)" />
</component>
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.8 (pythonProject7)" project-jdk-type="Python SDK" />
</project>

View File

@@ -17,7 +17,7 @@
3. 支持直接把refresh_token作为请求key方便接入one_api
4. 支持 gpt-4-mobile 、gpt-4-s 、基本所有的GPTS
4. 支持 gpt-4o 、gpt-4-s 、基本所有的GPTS
* **oaiFree 的 backend-api 接口,无需打码**
@@ -39,11 +39,11 @@
- [x] 支持 gpt-4-s
- [x] 支持 gpt-4-mobile
- [x] 支持 gpt-4o
- [x] 支持 gpt-3.5-turbo
- [x] 暂不 支持 gpts
- [x] 支持 gpts
- [x] 支持 流式输出

View File

@@ -10,7 +10,7 @@
"gpt_4_s_new_name": "gpt-4-s",
"gpt_4_mobile_new_name": "gpt-4-mobile,dall-e-3",
"gpt_3_5_new_name": "gpt-3.5-turbo",
"gpt_4_o_new_name": "gpt-4-o",
"gpt_4_o_new_name": "gpt-4-o,gpt-4o",
"need_delete_conversation_after_response": "true",
"use_oaiusercontent_url": "false",
"custom_arkose_url": "false",

74
main.py
View File

@@ -1,32 +1,21 @@
# 导入所需的库
from flask import Flask, request, jsonify, Response, send_from_directory
from flask_cors import CORS, cross_origin
import requests
import uuid
import json
import time
import os
from datetime import datetime
from PIL import Image
import io
import re
import threading
from queue import Queue, Empty
import logging
from logging.handlers import TimedRotatingFileHandler
import uuid
import hashlib
import requests
import json
import hashlib
from PIL import Image
from io import BytesIO
from urllib.parse import urlparse, urlunparse
import base64
from fake_useragent import UserAgent
import hashlib
import json
import logging
import os
import uuid
from datetime import datetime
from io import BytesIO
from logging.handlers import TimedRotatingFileHandler
from queue import Queue
from urllib.parse import urlparse
import requests
from fake_useragent import UserAgent
from flask import Flask, request, jsonify, Response, send_from_directory
from flask_apscheduler import APScheduler
from flask_cors import CORS, cross_origin
# 读取配置文件
@@ -133,7 +122,6 @@ logger.addHandler(stream_handler)
# 创建FakeUserAgent对象
ua = UserAgent()
import random
import threading
# 开启线程锁
@@ -336,9 +324,9 @@ scheduler.start()
# PANDORA_UPLOAD_URL = 'files.pandoranext.com'
VERSION = '0.7.9.2'
VERSION = '0.7.9.3'
# VERSION = 'test'
UPDATE_INFO = '支持最新的gpt-4-o模型'
UPDATE_INFO = '支持最新的gpt-4-o模型,并重定向gpt-4-mobile到gpt-4-s'
# UPDATE_INFO = '【仅供临时测试使用】 '
with app.app_context():
@@ -724,7 +712,7 @@ def send_text_prompt_and_get_response(messages, api_key, account_id, stream, mod
message_id = str(uuid.uuid4())
content = message.get("content")
if isinstance(content, list) and ori_model_name not in ['gpt-3.5-turbo', 'gpt-4-o']:
if isinstance(content, list) and ori_model_name not in ['gpt-3.5-turbo']:
logger.debug(f"gpt-vision 调用")
new_parts = []
attachments = []
@@ -852,13 +840,9 @@ def send_text_prompt_and_get_response(messages, api_key, account_id, stream, mod
"action": "next",
"messages": formatted_messages,
"parent_message_id": str(uuid.uuid4()),
"model": "gpt-4-mobile",
"model": "gpt-4",
"timezone_offset_min": -480,
"suggestions": [
"Give me 3 ideas about how to plan good New Years resolutions. Give me some that are personal, family, and professionally-oriented.",
"Write a text asking a friend to be my plus-one at a wedding next month. I want to keep it super short and casual, and offer an out.",
"Design a database schema for an online merch store.",
"Compare Gen Z and Millennial marketing strategies for sunglasses."],
"suggestions": [],
"history_and_training_disabled": False,
"conversation_mode": {"kind": "primary_assistant"}, "force_paragen": False, "force_rate_limit": False
}
@@ -890,7 +874,7 @@ def send_text_prompt_and_get_response(messages, api_key, account_id, stream, mod
"action": "next",
"messages": formatted_messages,
"parent_message_id": str(uuid.uuid4()),
"model": "auto",
"model": "gpt-4o",
"timezone_offset_min": -480,
"suggestions": [
"What are 5 creative things I could do with my kids' art? I don't want to throw them away, but it's also so much clutter.",
@@ -1519,7 +1503,8 @@ def data_fetcher(upstream_response, data_queue, stop_event, last_data_time, api_
execution_output_image_url_buffer = f"{UPLOAD_BASE_URL}/{today_image_url}"
else:
logger.error(f"下载图片失败: {image_download_response.text}")
logger.error(
f"下载图片失败: {image_download_response.text}")
execution_output_image_id_buffer = image_file_id
@@ -2390,7 +2375,22 @@ def catch_all(path):
logger.debug(f"请求头: {request.headers}")
logger.debug(f"请求体: {request.data}")
return jsonify({"message": "Welcome to Inker's World"}), 200
html_string = f"""
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<p> Thanks for using RefreshToV1Api {VERSION}</p>
<p> 感谢Ink-Osier大佬的付出敬礼</p>
<p><a href="https://github.com/Yanyutin753/RefreshToV1Api">项目地址</a></p>
</body>
</html>
"""
return html_string, 500
@app.route('/images/<filename>')