@@ -5,14 +5,16 @@ import {
5
5
State ,
6
6
Action ,
7
7
} from "../core/types.ts" ;
8
- import { elizaLog } from "../index.ts" ;
8
+ import { elizaLogger } from "../index.ts" ;
9
9
import { generateCaption , generateImage } from "./imageGenerationUtils.ts" ;
10
10
11
11
export const imageGeneration : Action = {
12
12
name : "GENERATE_IMAGE" ,
13
13
similes : [ "IMAGE_GENERATION" , "IMAGE_GEN" , "CREATE_IMAGE" , "MAKE_PICTURE" ] ,
14
14
description : "Generate an image to go along with the message." ,
15
15
validate : async ( runtime : IAgentRuntime , message : Memory ) => {
16
+ // TODO: Abstract this to an image provider thing
17
+
16
18
const anthropicApiKeyOk = ! ! runtime . getSetting ( "ANTHROPIC_API_KEY" ) ;
17
19
const togetherApiKeyOk = ! ! runtime . getSetting ( "TOGETHER_API_KEY" ) ;
18
20
@@ -27,19 +29,19 @@ export const imageGeneration: Action = {
27
29
options : any ,
28
30
callback : HandlerCallback
29
31
) => {
30
- elizaLog . log ( "Composing state for message:" , message ) ;
32
+ elizaLogger . log ( "Composing state for message:" , message ) ;
31
33
state = ( await runtime . composeState ( message ) ) as State ;
32
34
const userId = runtime . agentId ;
33
- elizaLog . log ( "User ID:" , userId ) ;
35
+ elizaLogger . log ( "User ID:" , userId ) ;
34
36
35
37
const imagePrompt = message . content . text ;
36
- elizaLog . log ( "Image prompt received:" , imagePrompt ) ;
38
+ elizaLogger . log ( "Image prompt received:" , imagePrompt ) ;
37
39
38
40
// TODO: Generate a prompt for the image
39
41
40
42
const res : { image : string ; caption : string } [ ] = [ ] ;
41
43
42
- elizaLog . log ( "Generating image with prompt:" , imagePrompt ) ;
44
+ elizaLogger . log ( "Generating image with prompt:" , imagePrompt ) ;
43
45
const images = await generateImage (
44
46
{
45
47
prompt : imagePrompt ,
@@ -51,13 +53,13 @@ export const imageGeneration: Action = {
51
53
) ;
52
54
53
55
if ( images . success && images . data && images . data . length > 0 ) {
54
- elizaLog . log (
56
+ elizaLogger . log (
55
57
"Image generation successful, number of images:" ,
56
58
images . data . length
57
59
) ;
58
60
for ( let i = 0 ; i < images . data . length ; i ++ ) {
59
61
const image = images . data [ i ] ;
60
- elizaLog . log ( `Processing image ${ i + 1 } :` , image ) ;
62
+ elizaLogger . log ( `Processing image ${ i + 1 } :` , image ) ;
61
63
62
64
const caption = await generateCaption (
63
65
{
@@ -66,7 +68,7 @@ export const imageGeneration: Action = {
66
68
runtime
67
69
) ;
68
70
69
- elizaLog . log (
71
+ elizaLogger . log (
70
72
`Generated caption for image ${ i + 1 } :` ,
71
73
caption . title
72
74
) ;
@@ -90,7 +92,7 @@ export const imageGeneration: Action = {
90
92
) ;
91
93
}
92
94
} else {
93
- elizaLog . error ( "Image generation failed or returned no data." ) ;
95
+ elizaLogger . error ( "Image generation failed or returned no data." ) ;
94
96
}
95
97
} ,
96
98
examples : [
0 commit comments