Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
O
open_ai_api
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
haojie
open_ai_api
Commits
db7a2ff5
Commit
db7a2ff5
authored
Apr 14, 2023
by
wangfa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改图生图
parent
2a936aba
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
4 deletions
+12
-4
app/Jobs/ReadDiscordMessageJob.php
+10
-2
app/Jobs/SendImagineJob.php
+2
-2
No files found.
app/Jobs/ReadDiscordMessageJob.php
View file @
db7a2ff5
...
...
@@ -27,8 +27,15 @@ public function handle()
{
$data
=
$this
->
data
;
$content
=
$data
[
'message_content'
]
??
''
;
preg_match
(
'/\*\*(.*)\*\*/'
,
$content
,
$matches
);
if
(
isset
(
$matches
[
1
]))
{
preg_match
(
'/\*\*<(.*)> (.*)\*\*/'
,
$content
,
$matches
);
if
(
blank
(
$matches
))
{
preg_match
(
'/\*\*(.*)\*\*/'
,
$content
,
$matches
);
$content
=
$matches
[
1
]
??
''
;
}
else
{
$content
=
$matches
[
2
]
??
''
;
}
if
(
isset
(
$content
)
&&
filled
(
$content
))
{
$key
=
app
(
TaskService
::
class
)
->
getDiscordMessageKey
(
$matches
[
1
]);
$cachePrompt
=
Cache
::
get
(
$key
);
if
(
!
empty
(
$cachePrompt
))
{
...
...
@@ -38,6 +45,7 @@ public function handle()
];
PromptTask
::
where
(
'id'
,
$cachePrompt
[
'prompt_task_id'
])
->
update
(
$updateData
);
Cache
::
forget
(
$key
);
}
}
}
...
...
app/Jobs/SendImagineJob.php
View file @
db7a2ff5
...
...
@@ -26,13 +26,13 @@ public function __construct(array $data = [])
public
function
handle
()
{
$data
=
$this
->
data
;
$key
=
app
(
TaskService
::
class
)
->
getDiscordMessageKey
(
$data
[
'prompt'
]);
Cache
::
set
(
$key
,
[
'prompt_task_id'
=>
$data
[
'prompt_id'
]],
(
60
*
60
*
24
));
// 处理图转图
if
(
$data
[
'type'
]
==
TaskService
::
TYPE_IMG_TO_IMG
)
{
$promptImg
=
json_decode
((
$data
[
'prompt_img'
]
??
''
));
$data
[
'prompt'
]
=
(
$promptImg
[
0
]
??
''
)
.
' '
.
$data
[
'prompt'
];
}
$key
=
app
(
TaskService
::
class
)
->
getDiscordMessageKey
(
$data
[
'prompt'
]);
Cache
::
set
(
$key
,
[
'prompt_task_id'
=>
$data
[
'prompt_id'
]],
(
60
*
60
*
24
));
app
(
ExternalApiService
::
class
)
->
imagine
(
$data
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment