Skip to content

Commit

Permalink
2.22.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Dooy committed Nov 15, 2024
1 parent 17ea3b7 commit 16c69fe
Show file tree
Hide file tree
Showing 25 changed files with 555 additions and 17 deletions.
3 changes: 3 additions & 0 deletions changlog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# 功能升级日志

# 计划
# 2.22.2
- 😄 新增:支持ruanway 官方api
- 🐞 修复:模型识图表示

# 2.22.1
- 😄 新增:超链定位tab 定位到可灵 https://vercel.ddaiai.com//#/video/index?tab=kling
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "chatgpt-web-midjourney-proxy",
"version": "2.22.1",
"version": "2.22.2",
"private": false,
"description": "ChatGPT Web Midjourney Proxy",
"author": "Dooy <[email protected]>",
Expand Down
6 changes: 5 additions & 1 deletion service/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -135,4 +135,8 @@ LUMA_KEY=xxxx

#ideogram设置
#IDEO_SERVER=
#IDEO_KEY=xxxx
#IDEO_KEY=xxxx

#runwayml runway api 相关设置
#RUNWAYML_SERVER=https://api.openai-hk.com
#RUNWAYML_KEY=hk-your-key
3 changes: 2 additions & 1 deletion service/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import FormData from 'form-data'
import axios from 'axios';
import AWS from 'aws-sdk';
import { v4 as uuidv4} from 'uuid';
import { viggleProxyFileDo,viggleProxy, lumaProxy, runwayProxy, ideoProxy, ideoProxyFileDo, klingProxy, pikaProxy, udioProxy } from './myfun'
import { viggleProxyFileDo,viggleProxy, lumaProxy, runwayProxy, ideoProxy, ideoProxyFileDo, klingProxy, pikaProxy, udioProxy, runwaymlProxy } from './myfun'


const app = express()
Expand Down Expand Up @@ -347,6 +347,7 @@ app.use('/pro/viggle/asset',authV2 , upload2.single('file'), viggleProxyFileDo
app.use('/viggle' ,authV2, viggleProxy);
app.use('/pro/viggle' ,authV2, viggleProxy);

app.use('/runwayml' ,authV2, runwaymlProxy );
app.use('/runway' ,authV2, runwayProxy );
app.use('/kling' ,authV2, klingProxy );

Expand Down
24 changes: 24 additions & 0 deletions service/src/myfun.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,30 @@ export const runwayProxy=proxy(process.env.RUNWAY_SERVER?? API_BASE_URL, {

});

//runwaymlProxy

export const runwaymlProxy=proxy(process.env.RUNWAYML_SERVER?? API_BASE_URL, {
https: false, limit: '10mb',
proxyReqPathResolver: function (req) {
let url = req.originalUrl;
let server= process.env.RUNWAYML_SERVER?? API_BASE_URL
if( server.indexOf('runwayml.com')>-1 ){
url= req.originalUrl.replace('/runwayml', '')
}
return url //req.originalUrl.replace('/sunoapi', '') // 将URL中的 `/openapi` 替换为空字符串
},
proxyReqOptDecorator: function (proxyReqOpts, srcReq) {
//mlog("sunoapi")
if ( process.env.RUNWAYML_KEY ) proxyReqOpts.headers['Authorization'] ='Bearer '+process.env.RUNWAYML_KEY;
else proxyReqOpts.headers['Authorization'] ='Bearer '+process.env.OPENAI_API_KEY;
proxyReqOpts.headers['Content-Type'] = 'application/json';
proxyReqOpts.headers['Mj-Version'] = pkg.version;
proxyReqOpts.headers['X-Runway-Version'] = '2024-11-06'; //'X-Runway-Version':
return proxyReqOpts;
},

});

export const klingProxy=proxy(process.env.KLING_SERVER?? API_BASE_URL, {
https: false, limit: '10mb',
proxyReqPathResolver: function (req) {
Expand Down
2 changes: 1 addition & 1 deletion src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
},
"package": {
"productName": "ChatGPT-MJ",
"version": "2.22.1"
"version": "2.22.2"
},
"tauri": {
"allowlist": {
Expand Down
5 changes: 5 additions & 0 deletions src/api/mjapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -381,9 +381,14 @@ export const canVisionModel= (model:string)=>{
export const isCanBase64Model=(model:string)=>{
//gpt-4o
//customVisionModel
let arr=['gpt-4o','gemini','1.5','sonnet','opus' ];
for( let m of arr){
if(model.indexOf(m)>-1) return true
}
if(model.indexOf('gpt-4o')>-1 || ( model.indexOf('gemini')>-1 && model.indexOf('1.5')>-1 ) ){
return true
}
//if(model.indexOf('sonnet')>-1 ) return true ;
let visionArr=['gemini-pro-vision','gpt-4o-2024-08-06','gpt-4o','gpt-4o-2024-05-13','gpt-4o-mini','gpt-4o-mini-2024-07-18','gemini-pro-1.5','gpt-4-turbo','gpt-4-turbo-2024-04-09','gpt-4-vision-preview','luma-video','claude-3-5-sonnet-20240620' ,'claude-3-sonnet-20240229','claude-3-opus-20240229', defaultVisionModel() ]
if( homeStore.myData.session.customVisionModel ){
homeStore.myData.session.customVisionModel.split(/[ ,]+/ig).map( (v:string)=>{
Expand Down
125 changes: 125 additions & 0 deletions src/api/runwayml.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
import { gptServerStore, homeStore, useAuthStore } from "@/store";
import { mlog } from "./mjapi";
import { sleep } from "./suno";
import { RunwayMlStore, RunwayMlTask } from "./runwaymlStore";

function getHeaderAuthorization(){
let headers={}
if( homeStore.myData.vtoken ){
const vtokenh={ 'x-vtoken': homeStore.myData.vtoken ,'x-ctoken': homeStore.myData.ctoken};
headers= {...headers, ...vtokenh}
}
if(!gptServerStore.myData.RUNWAY_KEY){
const authStore = useAuthStore()
if( authStore.token ) {
const bmi= { 'x-ptoken': authStore.token };
headers= {...headers, ...bmi }
return headers;
}
return headers
}
const bmi={
'Authorization': 'Bearer ' +gptServerStore.myData.RUNWAY_KEY
}
headers= {...headers, ...bmi }
return headers
}

export const getUrl=(url:string)=>{
if(url.indexOf('http')==0) return url;

const pro_prefix= url.indexOf('/pro')>-1?'/pro':'';//homeStore.myData.is_luma_pro?'/pro':''
url= url.replaceAll('/pro','')
if(gptServerStore.myData.RUNWAY_SERVER ){
return `${ gptServerStore.myData.RUNWAY_SERVER}${pro_prefix}/runwayml${url}`;
}
return `${pro_prefix}/runwayml${url}`;
}


export const runwayMlFetch=(url:string,data?:any,opt2?:any )=>{
mlog('runwayFetch', url );
let headers= opt2?.upFile?{}: {'Content-Type':'application/json'}

if(opt2 && opt2.headers ) headers= opt2.headers;

const otherHeader ={ 'X-Runway-Version': '2024-11-06'}

headers={...headers,...getHeaderAuthorization()} //,...otherHeader

return new Promise<any>((resolve, reject) => {
let opt:RequestInit ={method:'GET'};

opt.headers= headers ;
if(opt2?.upFile ){
opt.method='POST';
opt.body=data as FormData ;
}
else if(data) {
opt.body= JSON.stringify(data) ;
opt.method='POST';
}
fetch(getUrl(url), opt )
.then( async (d) =>{
if (!d.ok) {
let msg = '发生错误: '+ d.status
try{
let bjson:any = await d.json();
msg = '('+ d.status+')发生错误: '+(bjson?.error?.message??'' )
}catch( e ){
}
homeStore.myData.ms && homeStore.myData.ms.error(msg )
throw new Error( msg );
}

d.json().then(d=> resolve(d)).catch(e=>{

homeStore.myData.ms && homeStore.myData.ms.error('发生错误'+ e )
reject(e)
}
)})
.catch(e=>{
if (e.name === 'TypeError' && e.message === 'Failed to fetch') {
homeStore.myData.ms && homeStore.myData.ms.error('跨域|CORS error' )
}
else homeStore.myData.ms && homeStore.myData.ms.error('发生错误:'+e )
mlog('e', e.stat )
reject(e)
})
})
}

export interface RunwayMlInput {
model:string
promptText:string
}

export const runwayMlFeed= async(id:string, input:RunwayMlInput)=>{
const sunoS = new RunwayMlStore();
for(let i=0; i<1200; i++){
let d= await runwayMlFetch(`/v1/tasks/${id}`)
let task:RunwayMlTask={...d,...input} as RunwayMlTask
task.last_feed=new Date().getTime()
sunoS.save( task )
homeStore.setMyData({act:'runwayml.feed'})
if(task.status=='SUCCEEDED' || 'FAILED'== task.status ){
break;
}
//mlog('ddd>>',d )
await sleep(5800)
}
}

export const runwayMlFeedById= async(id:string)=>{
const sunoS = new RunwayMlStore();
const obj= sunoS.getOneById(id)
if (!obj) return ;
runwayMlFeed(id,{ model:obj.model,promptText:obj.promptText})
}


export function getRandomInt(min: number, max: number): number {
min = Math.ceil(min);
max = Math.floor(max);
return Math.floor(Math.random() * (max - min + 1)) + min;
}
53 changes: 53 additions & 0 deletions src/api/runwaymlStore.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import { ss } from "@/utils/storage";

export interface RunwayMlTask {
id: string;
status: string;
createdAt: string;
output?: string[];
last_feed?:number;
failure?: string
failureCode?: string
model:string
promptText:string
}



export class RunwayMlStore{
//private id: string;
private localKey='runwayml-store';
public save(obj:RunwayMlTask ){
if(!obj.id ) throw "taskID must";
let arr= this.getObjs();
let i= arr.findIndex( v=>v.id==obj.id );
if(i>-1) arr[i]= obj;
else arr.push(obj);
ss.set(this.localKey, arr );
return this;
}
public findIndex(id:string){
return this.getObjs().findIndex( v=>v.id== id )
}

public getObjs():RunwayMlTask[]{
const obj = ss.get( this.localKey ) as undefined| RunwayMlTask[];
if(!obj) return [];
return obj;
}
public getOneById(id:string):RunwayMlTask|null{
const i= this.findIndex(id)
if(i<0) return null;
let arr= this.getObjs();
return arr[i]
}
public delete( obj:RunwayMlTask ){
if(!obj.id ) throw "id must";
let arr= this.getObjs();
let i= arr.findIndex( v=>v.id==obj.id );
if(i<0) return false
arr.splice(i, 1);
ss.set(this.localKey, arr );
return true;
}
}
6 changes: 5 additions & 1 deletion src/locales/en-US.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,11 @@ export default {
"ud_fail": "Failed to generate this song!",
"ud_doing": "Cannot play while generating",
"ud_continuation": "Continuation",
"ud_precede": "Preced"
"ud_precede": "Preced",
"upImg2": '<span><b>Upload Image</b><br/>This model supports image recognition<br>Note: There will be additional image fees<br/>Formats: jpeg jpg png gif</span><p>Supports drag and drop</p> <p class="pt-2"><b>Upload MP3 MP4</b> <br>Will automatically call the whisper-1 model<br>Formats include: mp3 mp4 mpeg mpga m4a wav webm</p>',
"rml_info": "Note:<ul><li>1. Must include an image</li><li>2. The model only has one gen3a_turbo</li><li>3. The price for 10s is double that of 5s</li></ul>",
"rml_heng": "Landscape",
"rml_shu": "Portrait"

},
"mjset": {
Expand Down
7 changes: 6 additions & 1 deletion src/locales/fr-FR.ts
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,12 @@ export default {
"ud_fail": "Échec de la génération de cette chanson !",
"ud_doing": "Impossible de lire pendant la génération",
"ud_continuation": "Continuation",
"ud_precede": "Précédent"
"ud_precede": "Précédent",

"upImg2": "<span><b>Télécharger une image</b><br/>Ce modèle prend en charge la reconnaissance d'images<br>Remarque : des frais supplémentaires pour les images seront appliqués<br/>Formats : jpeg jpg png gif</span><p>Prend en charge le glisser-déposer</p> <p class=\"pt-2\"><b>Télécharger MP3 MP4</b> <br>Appellera automatiquement le modèle whisper-1<br>Formats : mp3 mp4 mpeg mpga m4a wav webm</p>",
"rml_info": "Remarque :<ul><li>1. Doit inclure une image</li><li>2. Le modèle n'a qu'un seul gen3a_turbo</li><li>3. Le prix pour 10 secondes est le double de celui de 5 secondes</li></ul>",
"rml_heng": "Paysage",
"rml_shu": "Portrait"
},
"mjset": {
"server": "Serveur",
Expand Down
7 changes: 6 additions & 1 deletion src/locales/ko-KR.ts
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,12 @@ export default {
"ud_fail": "이 곡 생성에 실패했습니다!",
"ud_doing": "생성 중에는 재생할 수 없습니다",
"ud_continuation": "계속",
"ud_precede": "이전"
"ud_precede": "이전",

"upImg2": "<span><b>이미지 업로드</b><br/>이 모델은 이미지 인식을 지원합니다<br>주의: 추가 이미지 요금이 발생합니다<br/>형식: jpeg jpg png gif</span><p>드래그 앤 드롭 지원</p> <p class=\"pt-2\"><b>MP3 MP4 업로드</b> <br>자동으로 whisper-1 모델을 호출합니다<br>형식: mp3 mp4 mpeg mpga m4a wav webm</p>",
"rml_info": "주의:<ul><li>1. 반드시 이미지를 포함해야 합니다</li><li>2. 모델은 gen3a_turbo 하나만 있습니다</li><li>3. 10초 가격은 5초의 두 배입니다</li></ul>",
"rml_heng": "가로 모드",
"rml_shu": "세로 모드"

},
"mjset": {
Expand Down
7 changes: 6 additions & 1 deletion src/locales/ru-RU.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,12 @@ export default {
"ud_fail": "Не удалось сгенерировать эту песню!",
"ud_doing": "Нельзя воспроизводить во время генерации",
"ud_continuation": "Продолжение",
"ud_precede": "Предшествующее"
"ud_precede": "Предшествующее",

"upImg2": "<span><b>Загрузить изображение</b><br/>Эта модель поддерживает распознавание изображений<br>Примечание: будут дополнительные расходы на изображения<br/>Форматы: jpeg jpg png gif</span><p>Поддерживает перетаскивание</p> <p class=\"pt-2\"><b>Загрузить MP3 MP4</b> <br>Автоматически вызовет модель whisper-1<br>Форматы: mp3 mp4 mpeg mpga m4a wav webm</p>",
"rml_info": "Примечание:<ul><li>1. Должно быть изображение</li><li>2. Модель имеет только одну gen3a_turbo</li><li>3. Цена за 10 секунд вдвое выше, чем за 5 секунд</li></ul>",
"rml_heng": "Пейзаж",
"rml_shu": "Портрет"

},
"mjset": {
Expand Down
7 changes: 6 additions & 1 deletion src/locales/tr-TR.ts
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,12 @@ export default {
"ud_fail": "Bu şarkının oluşturulması başarısız oldu!",
"ud_doing": "Oluşturma sırasında çalınamaz",
"ud_continuation": "Devam",
"ud_precede": "Önceki"
"ud_precede": "Önceki",

"upImg2": "<span><b>Görüntü Yükle</b><br/>Bu model görüntü tanımayı desteklemektedir<br>Not: Ekstra görüntü ücretleri olacaktır<br/>Formatlar: jpeg jpg png gif</span><p>Sürükleyip bırakmayı destekler</p> <p class=\"pt-2\"><b>MP3 MP4 Yükle</b> <br>otomatik olarak whisper-1 modelini çağıracaktır<br>Formatlar: mp3 mp4 mpeg mpga m4a wav webm</p>",
"rml_info": "Not:<ul><li>1. Bir resim içermelidir</li><li>2. Modelin yalnızca bir gen3a_turbo'su vardır</li><li>3. 10 saniyenin fiyatı 5 saniyenin iki katıdır</li></ul>",
"rml_heng": "Yatay",
"rml_shu": "Dikey"
},
"mjset": {
"server": "Sunucu",
Expand Down
6 changes: 5 additions & 1 deletion src/locales/vi-VN.ts
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,11 @@ export default {
"ud_fail": "Không thể tạo bài hát này!",
"ud_doing": "Không thể phát trong khi đang tạo",
"ud_continuation": "Tiếp tục",
"ud_precede": "Trước"
"ud_precede": "Trước",
"upImg2": "<span><b>Tải lên hình ảnh</b><br/>Mô hình này hỗ trợ nhận diện hình ảnh<br>Chú ý: sẽ có phí hình ảnh bổ sung<br/>Định dạng: jpeg jpg png gif</span><p>Hỗ trợ kéo và thả</p> <p class=\"pt-2\"><b>Tải lên MP3 MP4</b> <br>Sẽ tự động gọi mô hình whisper-1<br>Định dạng bao gồm: mp3 mp4 mpeg mpga m4a wav webm</p>",
"rml_info": "Chú ý:<ul><li>1. Phải có hình ảnh</li><li>2. Mô hình chỉ có một gen3a_turbo</li><li>3. Giá cho 10 giây gấp đôi giá cho 5 giây</li></ul>",
"rml_heng": "Chế độ ngang",
"rml_shu": "Chế độ dọc"

},
"mjset": {
Expand Down
5 changes: 5 additions & 0 deletions src/locales/zh-CN.ts
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,11 @@ export default {
,ud_doing:"生成中无法播放"
,ud_continuation:"后扩展"
,ud_precede:"前扩展"

,upImg2:'<span><b>上传图片</b><br/>该模型支持识图<br>注意:会有额外的图片费用<br/>格式: jpeg jpg png gif</span><p>支持拖拽</p> <p class="pt-2"><b>上传MP3 MP4</b> <br>会自动直接调用 whisper-1 模型<br>格式有:mp3 mp4 mpeg mpga m4a wav webm</p>'
,rml_info:'注意:<ul><li>1.必须带图</li><li>2.模型只有一个 gen3a_turbo </li><li>3.10s的价格是5s的双倍</li></ul>'
,rml_heng:'横屏'
,rml_shu:'竖屏'
},

draw: {
Expand Down
7 changes: 6 additions & 1 deletion src/locales/zh-TW.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,12 @@ export default {
"ud_fail": "這首歌生成失敗!",
"ud_doing": "生成中無法播放",
"ud_continuation": "後擴展",
"ud_precede": "前擴展"
"ud_precede": "前擴展",

"upImg2": "<span><b>上載圖片</b><br/>該模型支持識圖<br>注意:會有額外的圖片費用<br/>格式:jpeg jpg png gif</span><p>支持拖曳</p> <p class=\"pt-2\"><b>上載MP3 MP4</b> <br>會自動直接調用 whisper-1 模型<br>格式包括:mp3 mp4 mpeg mpga m4a wav webm</p>",
"rml_info": "注意:<ul><li>1. 必須帶圖</li><li>2. 模型只有一個 gen3a_turbo</li><li>3. 10秒的價格是5秒的雙倍</li></ul>",
"rml_heng": "橫屏",
"rml_shu": "豎屏"

},
"mjset": {
Expand Down
Loading

0 comments on commit 16c69fe

Please sign in to comment.