Skip to content

Commit db63ca2

Browse files
committed
docs & test for image URL fetching
1 parent e242401 commit db63ca2

File tree

6 files changed

+12
-5
lines changed

6 files changed

+12
-5
lines changed

docs/language/components.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -773,7 +773,7 @@ Note that syntax must be specified as `multimedia` to show the image.
773773

774774
#### Parameters
775775

776-
- **src**: The path to the image file.
776+
- **src**: The path or URL to the image file.
777777
- **alt**: The alternative text to show when the image cannot be displayed.
778778
- **base64**: The base64 encoded image data. It can not be specified together with `src`.
779779
- **type**: The MIME type of the image **to be shown**. If not specified, it will be inferred from the file extension.

examples/104_financial_analysis.poml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Given the stock ticker, provide a full and up-to-date financial analysis coverin
2323

2424
<img src="assets/104_chart_price.png" syntax="multimedia" />
2525

26-
<img src="assets/104_chart_normalized_price.png" syntax="multimedia" />
26+
<img src="https://raw.githubusercontent.com/microsoft/poml/refs/heads/main/examples/assets/104_chart_normalized_price.png" syntax="multimedia" />
2727

2828
<Hint>
2929
The table contains stock tickers of 7 companies. Please analyze and give financial analysis and comparison for them.

packages/poml/assets/componentDocs.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1433,7 +1433,7 @@
14331433
"name": "src",
14341434
"type": "string",
14351435
"choices": [],
1436-
"description": "The path to the image file.",
1436+
"description": "The path or URL to the image file.",
14371437
"required": false
14381438
},
14391439
{

packages/poml/essentials.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -667,7 +667,7 @@ interface ImageProps extends PropsSyntaxBase, MultiMedia.ImageProps {
667667
*
668668
* @see {@link Inline} for other props available.
669669
*
670-
* @param {string} src - The path to the image file.
670+
* @param {string} src - The path or URL to the image file.
671671
* @param {string} alt - The alternative text to show when the image cannot be displayed.
672672
* @param {string} base64 - The base64 encoded image data. It can not be specified together with `src`.
673673
* @param {string} type - The MIME type of the image **to be shown**. If not specified, it will be inferred from the file extension.

packages/poml/tests/util.test.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ describe('content', () => {
5757

5858
describe('preprocessImage', () => {
5959
const sampleImagePath = __dirname + '/assets/tomCat.jpg';
60+
const sampleImageURL = 'https://raw.githubusercontent.com/microsoft/poml/refs/heads/main/packages/poml/tests/assets/tomCat.jpg';
6061
const sampleImageBase64 = readFileSync(sampleImagePath).toString('base64');
6162

6263
test('should process an image from a supported file path', async () => {
@@ -73,6 +74,12 @@ describe('preprocessImage', () => {
7374
expect(metadata.format).toBe('png');
7475
});
7576

77+
test('should process an image from an URL', async () => {
78+
const result = await preprocessImage({ src: sampleImageURL });
79+
expect(result.base64).toBeTruthy();
80+
expect(result.mimeType).toBe('image/jpeg');
81+
});
82+
7683
test('should resize the image with the resize parameter', async () => {
7784
const result = await preprocessImage({ base64: sampleImageBase64, type: 'png', resize: 0.5 });
7885
expect(result.base64).toBeTruthy();

python/poml/_tags.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1202,7 +1202,7 @@ def image(
12021202
Note that syntax must be specified as `multimedia` to show the image.
12031203
12041204
Args:
1205-
src (Optional[str]): The path to the image file.
1205+
src (Optional[str]): The path or URL to the image file.
12061206
alt (Optional[str]): The alternative text to show when the image cannot be displayed.
12071207
base64 (Optional[str]): The base64 encoded image data. It can not be specified together with `src`.
12081208
type (Optional[str]): The MIME type of the image **to be shown**. If not specified, it will be inferred from the file extension.

0 commit comments

Comments
 (0)