@mulmochat-plugin/generate-image 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +20 -38
- package/dist/common/types.d.ts +7 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +39 -39
- package/dist/plugin/index.d.ts +2 -1
- package/dist/plugin/types.d.ts +7 -0
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
#
|
|
1
|
+
# MulmoChat Plugin
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A plugin for [MulmoChat](https://github.com/receptron/MulmoChat) - a multi-modal voice chat application with OpenAI's GPT-4 Realtime API.
|
|
4
|
+
|
|
5
|
+
## What this plugin does
|
|
6
|
+
|
|
7
|
+
Generate images using AI based on text prompts. This plugin provides the UI components and tool definition, while the actual image generation is handled by the host application via `context.app.generateImage()`.
|
|
4
8
|
|
|
5
9
|
## Installation
|
|
6
10
|
|
|
@@ -11,40 +15,14 @@ yarn add @mulmochat-plugin/generate-image @mulmochat-plugin/ui-image
|
|
|
11
15
|
## Usage
|
|
12
16
|
|
|
13
17
|
```typescript
|
|
14
|
-
import
|
|
18
|
+
import Plugin from "@mulmochat-plugin/generate-image";
|
|
15
19
|
import "@mulmochat-plugin/generate-image/style.css";
|
|
16
20
|
|
|
17
|
-
//
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
This plugin requires `@mulmochat-plugin/ui-image` as a peer dependency for the view components.
|
|
23
|
-
|
|
24
|
-
## Host App Integration
|
|
25
|
-
|
|
26
|
-
This plugin calls `context.app.generateImage(toolName, prompt)` to generate images. The host application (MulmoChat) must provide this function via the `ToolContext.app` object.
|
|
27
|
-
|
|
28
|
-
The host app is responsible for:
|
|
29
|
-
- Selecting the image generation backend (Google Gemini, OpenAI, ComfyUI, etc.)
|
|
30
|
-
- Configuring API keys and model settings
|
|
31
|
-
- Handling the actual image generation API calls
|
|
32
|
-
|
|
33
|
-
Example host app implementation:
|
|
34
|
-
|
|
35
|
-
```typescript
|
|
36
|
-
const context: ToolContext = {
|
|
37
|
-
app: {
|
|
38
|
-
generateImage: async (toolName: string, prompt: string) => {
|
|
39
|
-
// Call your image generation API here
|
|
40
|
-
const imageData = await yourImageGenerationAPI(prompt);
|
|
41
|
-
return {
|
|
42
|
-
message: "Image generated",
|
|
43
|
-
data: { imageData, prompt },
|
|
44
|
-
};
|
|
45
|
-
},
|
|
46
|
-
},
|
|
47
|
-
};
|
|
21
|
+
// Add to pluginList
|
|
22
|
+
const pluginList = [
|
|
23
|
+
// ... other plugins
|
|
24
|
+
Plugin,
|
|
25
|
+
];
|
|
48
26
|
```
|
|
49
27
|
|
|
50
28
|
## Development
|
|
@@ -53,15 +31,19 @@ const context: ToolContext = {
|
|
|
53
31
|
# Install dependencies
|
|
54
32
|
yarn install
|
|
55
33
|
|
|
56
|
-
# Start dev server
|
|
34
|
+
# Start dev server (http://localhost:5173/)
|
|
57
35
|
yarn dev
|
|
58
36
|
|
|
37
|
+
# Build
|
|
38
|
+
yarn build
|
|
39
|
+
|
|
59
40
|
# Type check
|
|
60
41
|
yarn typecheck
|
|
61
42
|
|
|
62
43
|
# Lint
|
|
63
44
|
yarn lint
|
|
64
|
-
|
|
65
|
-
# Build
|
|
66
|
-
yarn build
|
|
67
45
|
```
|
|
46
|
+
|
|
47
|
+
## License
|
|
48
|
+
|
|
49
|
+
MIT
|
package/dist/common/types.d.ts
CHANGED
|
@@ -5,6 +5,11 @@
|
|
|
5
5
|
* These types are plugin-agnostic and can be used by any plugin implementation.
|
|
6
6
|
*/
|
|
7
7
|
import type { Component } from "vue";
|
|
8
|
+
/**
|
|
9
|
+
* Backend types that plugins can declare they use.
|
|
10
|
+
* App layer manages actual provider/model settings for each type.
|
|
11
|
+
*/
|
|
12
|
+
export type BackendType = "textLLM" | "imageGen" | "audio" | "search" | "browse" | "map";
|
|
8
13
|
/**
|
|
9
14
|
* Context passed to plugin execute function
|
|
10
15
|
*/
|
|
@@ -127,4 +132,6 @@ export interface ToolPlugin<T = unknown, J = unknown, A extends object = object>
|
|
|
127
132
|
config?: ToolPluginConfig;
|
|
128
133
|
/** Optional sample arguments for testing */
|
|
129
134
|
samples?: ToolSample[];
|
|
135
|
+
/** Backend types this plugin uses (e.g., ["textLLM", "imageGen"]) */
|
|
136
|
+
backends?: BackendType[];
|
|
130
137
|
}
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),r=require("@mulmochat-plugin/ui-image"),o="generateImage",i={type:"function",name:o,description:"Generate an image based on the prompt and display it on the screen. Be descriptive and specify the concrete details of the images in the prompt. Each call generates one image.",parameters:{type:"object",properties:{prompt:{type:"string",description:"A detailed prompt describing the image to generate"}},required:["prompt"]}},p=[{name:"Sunset Beach",args:{imageData:"https://picsum.photos/id/28/800/600",prompt:"A beautiful sunset over a calm ocean beach with palm trees"}},{name:"Mountain Lake",args:{imageData:"https://picsum.photos/id/29/800/600",prompt:"A serene mountain lake surrounded by pine trees and snow-capped peaks"}},{name:"City Skyline",args:{imageData:"https://picsum.photos/id/43/800/600",prompt:"A modern city skyline at night with glowing skyscrapers"}},{name:"Forest Path",args:{imageData:"https://picsum.photos/id/15/800/600",prompt:"A winding path through an enchanted forest with sunlight filtering through the leaves"}}],c=e.defineComponent({__name:"View",props:{selectedResult:{},sendTextMessage:{type:Function}},emits:["updateResult"],setup(t){const n=t,a=e.ref(null);return e.watch(()=>n.selectedResult,s=>{s?.toolName===o&&s.data&&(a.value=s)},{immediate:!0,deep:!0}),(s,h)=>a.value?(e.openBlock(),e.createBlock(e.unref(r.ImageView),{key:0,selectedResult:a.value},null,8,["selectedResult"])):e.createCommentVNode("",!0)}}),m=e.defineComponent({__name:"Preview",props:{result:{}},setup(t){return(n,a)=>(e.openBlock(),e.createBlock(e.unref(r.ImagePreview),{result:t.result},null,8,["result"]))}}),u=async(t,n)=>{const{prompt:a}=n;return t.app?.generateImage?t.app.generateImage(t,a):{message:"generateImage function not available"}};function l(t,n,a){return{toolName:o,data:{imageData:t,prompt:a},message:"",title:n}}const g={toolDefinition:i,execute:u,generatingMessage:"Generating image...",isEnabled:()=>!0,viewComponent:c,previewComponent:m,fileUpload:{acceptedTypes:["image/png","image/jpeg"],handleUpload:l},systemPrompt:`When you are talking about places, objects, people, movies, books and other things, you MUST use the ${o} API to draw pictures to make the conversation more engaging.`,backends:["imageGen"],samples:p},d={plugin:g};exports.default=d;
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { ImageView as
|
|
3
|
-
const
|
|
1
|
+
import { defineComponent as o, ref as m, watch as c, createBlock as r, createCommentVNode as u, openBlock as i, unref as p } from "vue";
|
|
2
|
+
import { ImageView as g, ImagePreview as l } from "@mulmochat-plugin/ui-image";
|
|
3
|
+
const s = "generateImage", d = {
|
|
4
4
|
type: "function",
|
|
5
|
-
name:
|
|
5
|
+
name: s,
|
|
6
6
|
description: "Generate an image based on the prompt and display it on the screen. Be descriptive and specify the concrete details of the images in the prompt. Each call generates one image.",
|
|
7
7
|
parameters: {
|
|
8
8
|
type: "object",
|
|
@@ -43,62 +43,62 @@ const r = "generateImage", d = {
|
|
|
43
43
|
prompt: "A winding path through an enchanted forest with sunlight filtering through the leaves"
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
|
-
], f = /* @__PURE__ */
|
|
46
|
+
], f = /* @__PURE__ */ o({
|
|
47
47
|
__name: "View",
|
|
48
48
|
props: {
|
|
49
49
|
selectedResult: {},
|
|
50
50
|
sendTextMessage: { type: Function }
|
|
51
51
|
},
|
|
52
52
|
emits: ["updateResult"],
|
|
53
|
-
setup(
|
|
54
|
-
const
|
|
55
|
-
return
|
|
56
|
-
() =>
|
|
57
|
-
(
|
|
58
|
-
|
|
53
|
+
setup(e) {
|
|
54
|
+
const a = e, t = m(null);
|
|
55
|
+
return c(
|
|
56
|
+
() => a.selectedResult,
|
|
57
|
+
(n) => {
|
|
58
|
+
n?.toolName === s && n.data && (t.value = n);
|
|
59
59
|
},
|
|
60
60
|
{ immediate: !0, deep: !0 }
|
|
61
|
-
), (
|
|
61
|
+
), (n, b) => t.value ? (i(), r(p(g), {
|
|
62
62
|
key: 0,
|
|
63
|
-
selectedResult:
|
|
64
|
-
}, null, 8, ["selectedResult"])) :
|
|
63
|
+
selectedResult: t.value
|
|
64
|
+
}, null, 8, ["selectedResult"])) : u("", !0);
|
|
65
65
|
}
|
|
66
|
-
}), y = /* @__PURE__ */
|
|
66
|
+
}), y = /* @__PURE__ */ o({
|
|
67
67
|
__name: "Preview",
|
|
68
68
|
props: {
|
|
69
69
|
result: {}
|
|
70
70
|
},
|
|
71
|
-
setup(
|
|
72
|
-
return (
|
|
71
|
+
setup(e) {
|
|
72
|
+
return (a, t) => (i(), r(p(l), { result: e.result }, null, 8, ["result"]));
|
|
73
73
|
}
|
|
74
|
-
}),
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
} catch (e) {
|
|
88
|
-
return console.error("Image generation error", e), {
|
|
89
|
-
message: `Image generation error: ${e instanceof Error ? e.message : "Unknown error"}`,
|
|
90
|
-
instructions: "Acknowledge that there was an error generating the image and suggest trying again with a different prompt."
|
|
91
|
-
};
|
|
92
|
-
}
|
|
93
|
-
}, _ = {
|
|
74
|
+
}), _ = async (e, a) => {
|
|
75
|
+
const { prompt: t } = a;
|
|
76
|
+
return e.app?.generateImage ? e.app.generateImage(e, t) : { message: "generateImage function not available" };
|
|
77
|
+
};
|
|
78
|
+
function k(e, a, t) {
|
|
79
|
+
return {
|
|
80
|
+
toolName: s,
|
|
81
|
+
data: { imageData: e, prompt: t },
|
|
82
|
+
message: "",
|
|
83
|
+
title: a
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
const v = {
|
|
94
87
|
toolDefinition: d,
|
|
95
|
-
execute:
|
|
88
|
+
execute: _,
|
|
96
89
|
generatingMessage: "Generating image...",
|
|
97
90
|
isEnabled: () => !0,
|
|
98
91
|
viewComponent: f,
|
|
99
92
|
previewComponent: y,
|
|
93
|
+
fileUpload: {
|
|
94
|
+
acceptedTypes: ["image/png", "image/jpeg"],
|
|
95
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
96
|
+
handleUpload: k
|
|
97
|
+
},
|
|
98
|
+
systemPrompt: `When you are talking about places, objects, people, movies, books and other things, you MUST use the ${s} API to draw pictures to make the conversation more engaging.`,
|
|
99
|
+
backends: ["imageGen"],
|
|
100
100
|
samples: h
|
|
101
|
-
}, A = { plugin:
|
|
101
|
+
}, A = { plugin: v };
|
|
102
102
|
export {
|
|
103
103
|
A as default
|
|
104
104
|
};
|
package/dist/plugin/index.d.ts
CHANGED
|
@@ -10,8 +10,9 @@
|
|
|
10
10
|
* // Use plugin directly
|
|
11
11
|
* ```
|
|
12
12
|
*/
|
|
13
|
-
import type { ToolPlugin } from "../common";
|
|
13
|
+
import type { ToolPlugin, ToolResult } from "../common";
|
|
14
14
|
import type { ImageToolData, GenerateImageArgs } from "./types";
|
|
15
|
+
export declare function createUploadedImageResult(imageData: string, fileName: string, prompt: string): ToolResult<ImageToolData, never>;
|
|
15
16
|
/**
|
|
16
17
|
* GenerateImage plugin instance
|
|
17
18
|
*/
|
package/dist/plugin/types.d.ts
CHANGED
|
@@ -7,3 +7,10 @@ export type { ImageToolData } from "@mulmochat-plugin/ui-image";
|
|
|
7
7
|
export interface GenerateImageArgs {
|
|
8
8
|
prompt: string;
|
|
9
9
|
}
|
|
10
|
+
/** Configuration value for image generation backend */
|
|
11
|
+
export interface ImageGenerationConfigValue {
|
|
12
|
+
backend: "gemini" | "openai" | "comfyui";
|
|
13
|
+
styleModifier?: string;
|
|
14
|
+
geminiModel?: "gemini-2.5-flash-image" | "gemini-3-pro-image-preview";
|
|
15
|
+
openaiModel?: "gpt-image-1" | "gpt-image-1.5" | "gpt-image-1-mini";
|
|
16
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mulmochat-plugin/generate-image",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Image generation plugin for MulmoChat",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -24,8 +24,8 @@
|
|
|
24
24
|
"lint": "eslint src demo"
|
|
25
25
|
},
|
|
26
26
|
"peerDependencies": {
|
|
27
|
-
"
|
|
28
|
-
"
|
|
27
|
+
"@mulmochat-plugin/ui-image": "^0.1.0",
|
|
28
|
+
"vue": "^3.5.0"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@mulmochat-plugin/ui-image": "^0.1.0",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"@typescript-eslint/parser": "^8.53.0",
|
|
35
35
|
"@vitejs/plugin-vue": "^6.0.3",
|
|
36
36
|
"eslint": "^9.39.2",
|
|
37
|
-
"eslint-plugin-vue": "^10.
|
|
37
|
+
"eslint-plugin-vue": "^10.7.0",
|
|
38
38
|
"globals": "^17.0.0",
|
|
39
39
|
"tailwindcss": "^4.1.18",
|
|
40
40
|
"typescript": "~5.9.3",
|