File size: 842 Bytes
988ce90
 
 
 
 
39b5447
57e16da
988ce90
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
57e16da
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import { getInference } from "$lib/agents/getInference";
import type {
  TextToImageArgs,
  TextToImageOutput,
} from "@huggingface/inference";
import type { Tool } from "$lib/types";

export const textToImageTool: Tool<
  TextToImageArgs["inputs"],
  TextToImageOutput
> = {
  name: "textToImage",
  description: "Generate an image from a text prompt.",
  examples: [
    {
      prompt: "Generate an image of a cat wearing a top hat",
      command: "textToImage('cat wearing a top hat')",
    },
    {
      prompt: "Draw a brown dog on a beach",
      command: "textToImage('drawing of a brown dog on a beach')",
    },
  ],
  call: async (input) => {
    return await getInference().textToImage(
      {
        inputs: await input,
        model: "stabilityai/stable-diffusion-2",
      },
      { wait_for_model: true }
    );
  },
};