Merge branch 'TestServer' of https://github.com/Skyzayre/gpt_academic
This commit is contained in:
commit
26291b33d1
@ -372,7 +372,7 @@ def get_crazy_functions():
|
|||||||
"Color": "stop",
|
"Color": "stop",
|
||||||
"AsButton": False,
|
"AsButton": False,
|
||||||
"AdvancedArgs": True, # 调用时,唤起高级参数输入区(默认False)
|
"AdvancedArgs": True, # 调用时,唤起高级参数输入区(默认False)
|
||||||
"ArgsReminder": "在这里输入分辨率, 如1024x1024(默认),支持 1024x1024, 1792x1024, 1024x1792。如需生成高清图像,请输入 1024x1024-HD, 1792x1024-HD, 1024x1792-HD。", # 高级参数输入区的显示提示
|
"ArgsReminder": "在这里输入自定义参数「分辨率-质量(可选)-风格(可选)」, 参数示例「1024x1024-hd-vivid」 || 分辨率支持 「1024x1024」(默认) /「1792x1024」/「1024x1792」 || 质量支持 「-standard」(默认) /「-hd」 || 风格支持 「-vivid」(默认) /「-natural」", # 高级参数输入区的显示提示
|
||||||
"Info": "使用DALLE3生成图片 | 输入参数字符串,提供图像的内容",
|
"Info": "使用DALLE3生成图片 | 输入参数字符串,提供图像的内容",
|
||||||
"Function": HotReload(图片生成_DALLE3)
|
"Function": HotReload(图片生成_DALLE3)
|
||||||
},
|
},
|
||||||
|
@ -2,7 +2,7 @@ from toolbox import CatchException, update_ui, get_conf, select_api_key, get_log
|
|||||||
from crazy_functions.multi_stage.multi_stage_utils import GptAcademicState
|
from crazy_functions.multi_stage.multi_stage_utils import GptAcademicState
|
||||||
|
|
||||||
|
|
||||||
def gen_image(llm_kwargs, prompt, resolution="1024x1024", model="dall-e-2", quality=None):
|
def gen_image(llm_kwargs, prompt, resolution="1024x1024", model="dall-e-2", quality=None, style=None):
|
||||||
import requests, json, time, os
|
import requests, json, time, os
|
||||||
from request_llms.bridge_all import model_info
|
from request_llms.bridge_all import model_info
|
||||||
|
|
||||||
@ -25,7 +25,10 @@ def gen_image(llm_kwargs, prompt, resolution="1024x1024", model="dall-e-2", qual
|
|||||||
'model': model,
|
'model': model,
|
||||||
'response_format': 'url'
|
'response_format': 'url'
|
||||||
}
|
}
|
||||||
if quality is not None: data.update({'quality': quality})
|
if quality is not None:
|
||||||
|
data['quality'] = quality
|
||||||
|
if style is not None:
|
||||||
|
data['style'] = style
|
||||||
response = requests.post(url, headers=headers, json=data, proxies=proxies)
|
response = requests.post(url, headers=headers, json=data, proxies=proxies)
|
||||||
print(response.content)
|
print(response.content)
|
||||||
try:
|
try:
|
||||||
@ -121,13 +124,18 @@ def 图片生成_DALLE3(prompt, llm_kwargs, plugin_kwargs, chatbot, history, sys
|
|||||||
chatbot.append(("您正在调用“图像生成”插件。", "[Local Message] 生成图像, 请先把模型切换至gpt-*或者api2d-*。如果中文Prompt效果不理想, 请尝试英文Prompt。正在处理中 ....."))
|
chatbot.append(("您正在调用“图像生成”插件。", "[Local Message] 生成图像, 请先把模型切换至gpt-*或者api2d-*。如果中文Prompt效果不理想, 请尝试英文Prompt。正在处理中 ....."))
|
||||||
yield from update_ui(chatbot=chatbot, history=history) # 刷新界面 由于请求gpt需要一段时间,我们先及时地做一次界面更新
|
yield from update_ui(chatbot=chatbot, history=history) # 刷新界面 由于请求gpt需要一段时间,我们先及时地做一次界面更新
|
||||||
if ("advanced_arg" in plugin_kwargs) and (plugin_kwargs["advanced_arg"] == ""): plugin_kwargs.pop("advanced_arg")
|
if ("advanced_arg" in plugin_kwargs) and (plugin_kwargs["advanced_arg"] == ""): plugin_kwargs.pop("advanced_arg")
|
||||||
resolution = plugin_kwargs.get("advanced_arg", '1024x1024').lower()
|
resolution_arg = plugin_kwargs.get("advanced_arg", '1024x1024-standard-vivid').lower()
|
||||||
if resolution.endswith('-hd'):
|
parts = resolution_arg.split('-')
|
||||||
resolution = resolution.replace('-hd', '')
|
resolution = parts[0] # 解析分辨率
|
||||||
quality = 'hd'
|
quality = 'standard' # 质量与风格默认值
|
||||||
else:
|
style = 'vivid'
|
||||||
quality = 'standard'
|
# 遍历检查是否有额外参数
|
||||||
image_url, image_path = gen_image(llm_kwargs, prompt, resolution, model="dall-e-3", quality=quality)
|
for part in parts[1:]:
|
||||||
|
if part in ['hd', 'standard']:
|
||||||
|
quality = part
|
||||||
|
elif part in ['vivid', 'natural']:
|
||||||
|
style = part
|
||||||
|
image_url, image_path = gen_image(llm_kwargs, prompt, resolution, model="dall-e-3", quality=quality, style=style)
|
||||||
chatbot.append([prompt,
|
chatbot.append([prompt,
|
||||||
f'图像中转网址: <br/>`{image_url}`<br/>'+
|
f'图像中转网址: <br/>`{image_url}`<br/>'+
|
||||||
f'中转网址预览: <br/><div align="center"><img src="{image_url}"></div>'
|
f'中转网址预览: <br/><div align="center"><img src="{image_url}"></div>'
|
||||||
@ -257,4 +265,4 @@ def make_square_image(input_path, output_path):
|
|||||||
size = max(width, height)
|
size = max(width, height)
|
||||||
new_img = Image.new("RGBA", (size, size), color="black")
|
new_img = Image.new("RGBA", (size, size), color="black")
|
||||||
new_img.paste(img, ((size - width) // 2, (size - height) // 2))
|
new_img.paste(img, ((size - width) // 2, (size - height) // 2))
|
||||||
new_img.save(output_path)
|
new_img.save(output_path)
|
||||||
|
@ -923,7 +923,7 @@
|
|||||||
"的第": "The",
|
"的第": "The",
|
||||||
"个片段": "fragment",
|
"个片段": "fragment",
|
||||||
"总结文章": "Summarize the article",
|
"总结文章": "Summarize the article",
|
||||||
"根据以上的对话": "According to the above dialogue",
|
"根据以上的对话": "According to the conversation above",
|
||||||
"的主要内容": "The main content of",
|
"的主要内容": "The main content of",
|
||||||
"所有文件都总结完成了吗": "Are all files summarized?",
|
"所有文件都总结完成了吗": "Are all files summarized?",
|
||||||
"如果是.doc文件": "If it is a .doc file",
|
"如果是.doc文件": "If it is a .doc file",
|
||||||
@ -1501,7 +1501,7 @@
|
|||||||
"发送请求到OpenAI后": "After sending the request to OpenAI",
|
"发送请求到OpenAI后": "After sending the request to OpenAI",
|
||||||
"上下布局": "Vertical Layout",
|
"上下布局": "Vertical Layout",
|
||||||
"左右布局": "Horizontal Layout",
|
"左右布局": "Horizontal Layout",
|
||||||
"对话窗的高度": "Height of the Dialogue Window",
|
"对话窗的高度": "Height of the Conversation Window",
|
||||||
"重试的次数限制": "Retry Limit",
|
"重试的次数限制": "Retry Limit",
|
||||||
"gpt4现在只对申请成功的人开放": "GPT-4 is now only open to those who have successfully applied",
|
"gpt4现在只对申请成功的人开放": "GPT-4 is now only open to those who have successfully applied",
|
||||||
"提高限制请查询": "Please check for higher limits",
|
"提高限制请查询": "Please check for higher limits",
|
||||||
@ -2183,9 +2183,8 @@
|
|||||||
"找不到合适插件执行该任务": "Cannot find a suitable plugin to perform this task",
|
"找不到合适插件执行该任务": "Cannot find a suitable plugin to perform this task",
|
||||||
"接驳VoidTerminal": "Connect to VoidTerminal",
|
"接驳VoidTerminal": "Connect to VoidTerminal",
|
||||||
"**很好": "**Very good",
|
"**很好": "**Very good",
|
||||||
"对话|编程": "Conversation|Programming",
|
"对话|编程": "Conversation&ImageGenerating|Programming",
|
||||||
"对话|编程|学术": "Conversation|Programming|Academic",
|
"对话|编程|学术": "Conversation&ImageGenerating|Programming|Academic", "4. 建议使用 GPT3.5 或更强的模型": "4. It is recommended to use GPT3.5 or a stronger model",
|
||||||
"4. 建议使用 GPT3.5 或更强的模型": "4. It is recommended to use GPT3.5 or a stronger model",
|
|
||||||
"「请调用插件翻译PDF论文": "Please call the plugin to translate the PDF paper",
|
"「请调用插件翻译PDF论文": "Please call the plugin to translate the PDF paper",
|
||||||
"3. 如果您使用「调用插件xxx」、「修改配置xxx」、「请问」等关键词": "3. If you use keywords such as 'call plugin xxx', 'modify configuration xxx', 'please', etc.",
|
"3. 如果您使用「调用插件xxx」、「修改配置xxx」、「请问」等关键词": "3. If you use keywords such as 'call plugin xxx', 'modify configuration xxx', 'please', etc.",
|
||||||
"以下是一篇学术论文的基本信息": "The following is the basic information of an academic paper",
|
"以下是一篇学术论文的基本信息": "The following is the basic information of an academic paper",
|
||||||
@ -2630,7 +2629,7 @@
|
|||||||
"已经被记忆": "Already memorized",
|
"已经被记忆": "Already memorized",
|
||||||
"默认用英文的": "Default to English",
|
"默认用英文的": "Default to English",
|
||||||
"错误追踪": "Error tracking",
|
"错误追踪": "Error tracking",
|
||||||
"对话|编程|学术|智能体": "Dialogue|Programming|Academic|Intelligent agent",
|
"对话&编程|编程|学术|智能体": "Conversation&ImageGenerating|Programming|Academic|Intelligent agent",
|
||||||
"请检查": "Please check",
|
"请检查": "Please check",
|
||||||
"检测到被滞留的缓存文档": "Detected cached documents being left behind",
|
"检测到被滞留的缓存文档": "Detected cached documents being left behind",
|
||||||
"还有哪些场合允许使用代理": "What other occasions allow the use of proxies",
|
"还有哪些场合允许使用代理": "What other occasions allow the use of proxies",
|
||||||
@ -2904,4 +2903,4 @@
|
|||||||
"请配置ZHIPUAI_API_KEY": "Please configure ZHIPUAI_API_KEY",
|
"请配置ZHIPUAI_API_KEY": "Please configure ZHIPUAI_API_KEY",
|
||||||
"单个azure模型": "Single Azure model",
|
"单个azure模型": "Single Azure model",
|
||||||
"预留参数 context 未实现": "Reserved parameter 'context' not implemented"
|
"预留参数 context 未实现": "Reserved parameter 'context' not implemented"
|
||||||
}
|
}
|
||||||
|
@ -1043,9 +1043,9 @@
|
|||||||
"jittorllms响应异常": "jittorllms response exception",
|
"jittorllms响应异常": "jittorllms response exception",
|
||||||
"在项目根目录运行这两个指令": "Run these two commands in the project root directory",
|
"在项目根目录运行这两个指令": "Run these two commands in the project root directory",
|
||||||
"获取tokenizer": "Get tokenizer",
|
"获取tokenizer": "Get tokenizer",
|
||||||
"chatbot 为WebUI中显示的对话列表": "chatbot is the list of dialogues displayed in WebUI",
|
"chatbot 为WebUI中显示的对话列表": "chatbot is the list of conversations displayed in WebUI",
|
||||||
"test_解析一个Cpp项目": "test_parse a Cpp project",
|
"test_解析一个Cpp项目": "test_parse a Cpp project",
|
||||||
"将对话记录history以Markdown格式写入文件中": "Write the dialogue record history to a file in Markdown format",
|
"将对话记录history以Markdown格式写入文件中": "Write the conversations record history to a file in Markdown format",
|
||||||
"装饰器函数": "Decorator function",
|
"装饰器函数": "Decorator function",
|
||||||
"玫瑰色": "Rose color",
|
"玫瑰色": "Rose color",
|
||||||
"将单空行": "刪除單行空白",
|
"将单空行": "刪除單行空白",
|
||||||
@ -2270,4 +2270,4 @@
|
|||||||
"标注节点的行数范围": "標註節點的行數範圍",
|
"标注节点的行数范围": "標註節點的行數範圍",
|
||||||
"默认 True": "默認 True",
|
"默认 True": "默認 True",
|
||||||
"将两个PDF拼接": "將兩個PDF拼接"
|
"将两个PDF拼接": "將兩個PDF拼接"
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user