文本转图像
文本转图像工具规范 #
基类:EventBaseToolSpec
文本转图像工具规范。
workflows/handler.py 中的源代码llama_index/tools/text_to_image/base.py
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | |
generate_images #
generate_images(prompt: str, n: Optional[int] = 1, size: Optional[str] = '256x256') -> List[str]
向OpenAI的文本转图像API传递提示,根据提供的查询生成图像。
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
prompt
|
str
|
用于生成图像的提示 |
required |
n
|
int
|
要生成的图像数量。默认为1。 |
1
|
size
|
str
|
要生成的图像尺寸。默认为256x256。其他可接受的值为1024x1024和512x512 |
'256x256'
|
处理此函数返回的网址时,切勿删除任何参数或尝试修改网址,这些参数对于查看图像的授权是必需的
workflows/handler.py 中的源代码llama_index/tools/text_to_image/base.py
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | |
generate_image_variation #
generate_image_variation(url: str, n: Optional[int] = 1, size: Optional[str] = '256x256') -> str
接受图像URL并使用OpenAI的API生成该图像的变体。 此工具可以处理较小图像并创建更高分辨率的变体,反之亦然。
当从"generate_images"传递URL时,务必完全按照函数返回的URL原样传递,包括所有查询参数 参数: url (str): 要创建变体的图像URL n (int): 要生成的图像数量。默认为1 size (str): 要生成的图像尺寸。默认为256x256。其他可接受值为1024x1024和512x512
workflows/handler.py 中的源代码llama_index/tools/text_to_image/base.py
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | |
show_images #
show_images(urls: List[str])
使用此函数通过pyplot和pillow显示图像。这在jupyter笔记本中有效。
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
urls
|
str
|
要显示的图像的URL |
required |
workflows/handler.py 中的源代码llama_index/tools/text_to_image/base.py
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | |
选项: 成员:- TextToImageToolSpec