Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Translate prompt #324

Merged
merged 4 commits into from
Oct 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

代理 MidJourney 的discord频道,实现api形式调用AI绘图

[![GitHub release](https://img.shields.io/static/v1?label=release&message=v2.5.2&color=blue)](https://www.github.com/novicezk/midjourney-proxy)
[![GitHub release](https://img.shields.io/static/v1?label=release&message=v2.5.3&color=blue)](https://www.github.com/novicezk/midjourney-proxy)
[![License](https://img.shields.io/badge/license-Apache%202-4EB1BA.svg)](https://www.apache.org/licenses/LICENSE-2.0.html)

## 主要功能
Expand Down Expand Up @@ -66,7 +66,6 @@
依赖此项目且开源的,欢迎联系作者,加到此处展示
- [wechat-midjourney](https://github.com/novicezk/wechat-midjourney) : 代理微信客户端,接入MidJourney,仅示例应用场景,不再更新
- [stable-diffusion-mobileui](https://github.com/yuanyuekeji/stable-diffusion-mobileui) : SDUI,基于本接口和SD,可一键打包生成H5和小程序
- [ChatGPT-Midjourney](https://github.com/Licoy/ChatGPT-Midjourney) : 一键拥有你自己的 ChatGPT+Midjourney 网页服务
- [MidJourney-Web](https://github.com/ConnectAI-E/MidJourney-Web) : 🍎 Supercharged Experience For MidJourney On Web UI

## 开放API
Expand Down
4 changes: 2 additions & 2 deletions docs/docker-start.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
docker run -d --name midjourney-proxy \
-p 8080:8080 \
-v /xxx/xxx/config:/home/spring/config \
novicezk/midjourney-proxy:2.5.2
novicezk/midjourney-proxy:2.5.3
```
3. 访问 `http://ip:port/mj` 查看API文档

Expand All @@ -17,5 +17,5 @@ docker run -d --name midjourney-proxy \
-e mj.discord.guild-id=xxx \
-e mj.discord.channel-id=xxx \
-e mj.discord.user-token=xxx \
novicezk/midjourney-proxy:2.5.2
novicezk/midjourney-proxy:2.5.3
```
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<groupId>com.github.novicezk</groupId>
<artifactId>midjourney-proxy</artifactId>
<version>2.5.2</version>
<version>2.5.3</version>

<properties>
<hutool.version>5.8.18</hutool.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import com.github.novicezk.midjourney.dto.SubmitSimpleChangeDTO;
import com.github.novicezk.midjourney.enums.TaskAction;
import com.github.novicezk.midjourney.enums.TaskStatus;
import com.github.novicezk.midjourney.enums.TranslateWay;
import com.github.novicezk.midjourney.exception.BannedPromptException;
import com.github.novicezk.midjourney.result.SubmitResultVO;
import com.github.novicezk.midjourney.service.TaskService;
Expand Down Expand Up @@ -215,7 +216,7 @@ private Task newTask(BaseSubmitDTO base) {
}

private String translatePrompt(String prompt) {
if (CharSequenceUtil.isBlank(prompt)) {
if (TranslateWay.NULL.equals(this.properties.getTranslateWay()) || CharSequenceUtil.isBlank(prompt)) {
return prompt;
}
List<String> imageUrls = new ArrayList<>();
Expand All @@ -231,7 +232,7 @@ private String translatePrompt(String prompt) {
String imageStr = CharSequenceUtil.join("", imageUrls);
String text = prompt.substring(imageStr.length(), prompt.length() - paramStr.length());
if (CharSequenceUtil.isNotBlank(text)) {
text = this.translateService.translateToEnglish(prompt).trim();
text = this.translateService.translateToEnglish(text).trim();
}
return imageStr + text + paramStr;
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/banner.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ ___ _(/ ___ __ __ _ __ __ _____/
.-/ .-/ .-/ / .-/
(_/ (_/ (_/ (_/

:: MidJourney Proxy :: v2.5.2
:: MidJourney Proxy :: v2.5.3
2 changes: 1 addition & 1 deletion src/main/resources/config/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ knife4j:
description: 代理 MidJourney 的discord频道,实现api形式调用AI绘图
concat: novicezk
url: https://github.com/novicezk/midjourney-proxy
version: v2.5.2
version: v2.5.3
terms-of-service-url: https://github.com/novicezk/midjourney-proxy
group:
api:
Expand Down