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
865c9271
Commit
865c9271
authored
Apr 14, 2023
by
haojie
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
http://124.223.61.50:8099/haojie/open_ai_api
parents
94019363
b18d567d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
5 deletions
+13
-5
app/Jobs/ReadDiscordMessageJob.php
+11
-3
app/Jobs/SendImagineJob.php
+2
-2
No files found.
app/Jobs/ReadDiscordMessageJob.php
View file @
865c9271
...
...
@@ -27,9 +27,16 @@ public function handle()
{
$data
=
$this
->
data
;
$content
=
$data
[
'message_content'
]
??
''
;
preg_match
(
'/\*\*(.*)\*\*/'
,
$content
,
$matches
);
if
(
isset
(
$matches
[
1
]))
{
$key
=
app
(
TaskService
::
class
)
->
getDiscordMessageKey
(
$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
(
$content
);
$cachePrompt
=
Cache
::
get
(
$key
);
if
(
!
empty
(
$cachePrompt
))
{
$updateData
=
[
...
...
@@ -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 @
865c9271
...
...
@@ -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