mirror of
https://github.com/Yanyutin753/RefreshToV1Api.git
synced 2025-10-20 19:00:39 +00:00
支持最新的gpt-4-o模型,并重定向gpt-4-mobile到gpt-4-s
This commit is contained in:
72
main.py
72
main.py
@@ -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
|
import base64
|
||||||
from fake_useragent import UserAgent
|
import hashlib
|
||||||
|
import json
|
||||||
|
import logging
|
||||||
import os
|
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
|
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_apscheduler import APScheduler
|
||||||
|
from flask_cors import CORS, cross_origin
|
||||||
|
|
||||||
|
|
||||||
# 读取配置文件
|
# 读取配置文件
|
||||||
@@ -133,7 +122,6 @@ logger.addHandler(stream_handler)
|
|||||||
# 创建FakeUserAgent对象
|
# 创建FakeUserAgent对象
|
||||||
ua = UserAgent()
|
ua = UserAgent()
|
||||||
|
|
||||||
import random
|
|
||||||
import threading
|
import threading
|
||||||
|
|
||||||
# 开启线程锁
|
# 开启线程锁
|
||||||
@@ -336,9 +324,9 @@ scheduler.start()
|
|||||||
# PANDORA_UPLOAD_URL = 'files.pandoranext.com'
|
# PANDORA_UPLOAD_URL = 'files.pandoranext.com'
|
||||||
|
|
||||||
|
|
||||||
VERSION = '0.7.9.2'
|
VERSION = '0.7.9.3'
|
||||||
# VERSION = 'test'
|
# VERSION = 'test'
|
||||||
UPDATE_INFO = '支持最新的gpt-4-o模型,且支持上传文件'
|
UPDATE_INFO = '支持最新的gpt-4-o模型,并重定向gpt-4-mobile到gpt-4-s'
|
||||||
# UPDATE_INFO = '【仅供临时测试使用】 '
|
# UPDATE_INFO = '【仅供临时测试使用】 '
|
||||||
|
|
||||||
with app.app_context():
|
with app.app_context():
|
||||||
@@ -852,13 +840,9 @@ def send_text_prompt_and_get_response(messages, api_key, account_id, stream, mod
|
|||||||
"action": "next",
|
"action": "next",
|
||||||
"messages": formatted_messages,
|
"messages": formatted_messages,
|
||||||
"parent_message_id": str(uuid.uuid4()),
|
"parent_message_id": str(uuid.uuid4()),
|
||||||
"model": "gpt-4-mobile",
|
"model": "gpt-4",
|
||||||
"timezone_offset_min": -480,
|
"timezone_offset_min": -480,
|
||||||
"suggestions": [
|
"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."],
|
|
||||||
"history_and_training_disabled": False,
|
"history_and_training_disabled": False,
|
||||||
"conversation_mode": {"kind": "primary_assistant"}, "force_paragen": False, "force_rate_limit": 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",
|
"action": "next",
|
||||||
"messages": formatted_messages,
|
"messages": formatted_messages,
|
||||||
"parent_message_id": str(uuid.uuid4()),
|
"parent_message_id": str(uuid.uuid4()),
|
||||||
"model": "auto",
|
"model": "gpt-4o",
|
||||||
"timezone_offset_min": -480,
|
"timezone_offset_min": -480,
|
||||||
"suggestions": [
|
"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.",
|
"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}"
|
execution_output_image_url_buffer = f"{UPLOAD_BASE_URL}/{today_image_url}"
|
||||||
|
|
||||||
else:
|
else:
|
||||||
logger.error(f"下载图片失败: {image_download_response.text}")
|
logger.error(
|
||||||
|
f"下载图片失败: {image_download_response.text}")
|
||||||
|
|
||||||
execution_output_image_id_buffer = image_file_id
|
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.headers}")
|
||||||
logger.debug(f"请求体: {request.data}")
|
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>')
|
@app.route('/images/<filename>')
|
||||||
|
Reference in New Issue
Block a user