Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
110 commits
Select commit Hold shift + click to select a range
368bdf4
Initial-Commit-multimodal
w-javed Oct 3, 2024
920c46c
Fix
w-javed Oct 4, 2024
17c7dac
Sync eng/common directory with azure-sdk-tools for PR 9092 (#37713)
azure-sdk Oct 3, 2024
5d8ca40
Removing private parameter from __call__ of AdversarialSimulator (#37…
nagkumar91 Oct 3, 2024
6e5bd48
Enabling option to disable response payload on writes (#37365)
FabianMeiswinkel Oct 3, 2024
10f9ac7
deprecate azure_germany (#37654)
xiangyan99 Oct 4, 2024
db68d9d
Add default impl to handle token challenges (#37652)
xiangyan99 Oct 4, 2024
793c3fc
Make Credentials Required for Content Safety and Protected Materials …
needuv Oct 4, 2024
4d4e5bc
addFeedRangesAndUseFeedRangeInQueryChangeFeed (#37687)
xinlian12 Oct 4, 2024
22f081c
Update release date for core (#37723)
xiangyan99 Oct 4, 2024
71e44d4
Improvements to mindependency dev_requirement conflict resolution (#3…
scbedd Oct 4, 2024
ee45fa1
Need to add environment to subscription configuration (#37726)
azure-sdk Oct 4, 2024
2e2366b
Enable samples for formrecognizer (#37676)
xiangyan99 Oct 4, 2024
0faf959
Merge branch 'main' into multi-moodal-sdk-support
w-javed Oct 5, 2024
088ed3b
multi-modal-changes
w-javed Oct 14, 2024
3ff2c2a
Merge-conflicts
w-javed Oct 14, 2024
5ff2668
fixes
w-javed Oct 14, 2024
5c270cd
Fix with latest
w-javed Oct 16, 2024
c473df7
merge-conflicts
w-javed Oct 16, 2024
99d0cf0
dict-fix
w-javed Oct 16, 2024
d570130
adding-protected-material
w-javed Oct 17, 2024
4bc8a34
Merge branch 'main' into multi-moodal-sdk-support
w-javed Oct 17, 2024
6ad0164
adding-protected-material
w-javed Oct 17, 2024
7655b9e
adding-protected-material
w-javed Oct 17, 2024
3c4b816
bumping-version
w-javed Oct 17, 2024
255add0
adding assets
w-javed Oct 17, 2024
49a8ad8
Added image in simulator
w-javed Oct 17, 2024
f64d4d3
Merge branch 'main' into multi-moodal-sdk-support
w-javed Oct 17, 2024
acad134
Added image in simulator
w-javed Oct 17, 2024
60eae73
bumping-version
w-javed Oct 18, 2024
e14c6d7
push-asset
w-javed Oct 18, 2024
b12ef57
merge-conflict-fix
w-javed Oct 18, 2024
e070237
assets
w-javed Oct 18, 2024
66548f5
pushing asset
w-javed Oct 18, 2024
f05726c
merge-conflicts
w-javed Oct 19, 2024
1fe065b
remove-containt-on-key
w-javed Oct 19, 2024
82fd655
asset
w-javed Oct 19, 2024
6dddb96
asset2
w-javed Oct 19, 2024
c5fa8cf
asset3
w-javed Oct 19, 2024
74b3582
asset4
w-javed Oct 19, 2024
2e11e9d
adding conftest
w-javed Oct 20, 2024
651fc00
conftest
w-javed Oct 20, 2024
3ed59e8
cred fix
w-javed Oct 20, 2024
4031d46
asset-new
w-javed Oct 20, 2024
b5fc1c5
fix
w-javed Oct 20, 2024
24a52aa
asset
w-javed Oct 20, 2024
73e62c6
adding multi-modal-without-tests
w-javed Oct 20, 2024
c89b341
asset-from-main
w-javed Oct 20, 2024
b63910d
asset-from-main
w-javed Oct 20, 2024
ca4c3e6
fix
w-javed Oct 20, 2024
8b28458
adding one test only
w-javed Oct 20, 2024
1eb9304
new asset
w-javed Oct 20, 2024
dd53e67
tests,fix: Sanitizer should replace with enum value not enum name
kdestin Oct 21, 2024
9fcd7f8
test-asset
w-javed Oct 21, 2024
d64704d
[AutoRelease] t2-containerservicefleet-2024-09-24-42036(can only be m…
azure-sdk Oct 21, 2024
78b11c9
[AutoRelease] t2-dns-2024-09-25-81486(can only be merged by SDK owner…
azure-sdk Oct 21, 2024
6962ca2
[AutoRelease] t2-appconfiguration-2024-10-09-68726(can only be merged…
azure-sdk Oct 21, 2024
aa2bb08
code and test (#37855)
azure-sdk Oct 21, 2024
52f3784
[AutoRelease] t2-servicefabricmanagedclusters-2024-10-08-57405(can on…
azure-sdk Oct 21, 2024
09724d8
[AutoRelease] t2-containerinstance-2024-10-21-66631(can only be merge…
azure-sdk Oct 21, 2024
9f5f7f9
[sdk generation pipeline] bump typespec-python 0.36.1 (#38008)
msyyc Oct 21, 2024
45e049c
[AutoRelease] t2-dnsresolver-2024-10-12-16936(can only be merged by S…
azure-sdk Oct 21, 2024
617f8aa
Merge branch 'main' into multi-moodal-sdk-support-one-test
w-javed Oct 21, 2024
706eea3
new asset after fix in conftest
w-javed Oct 21, 2024
bd08adf
asset
w-javed Oct 21, 2024
3c71da9
chore: Update assets.json
kdestin Oct 21, 2024
6d48318
Move perf pipelines to TME subscription (#38020)
azure-sdk Oct 21, 2024
14d4675
fix
w-javed Oct 21, 2024
d4b8272
after-comments
w-javed Oct 21, 2024
33e3075
fix
w-javed Oct 21, 2024
237443b
fix
w-javed Oct 21, 2024
525379e
asset
w-javed Oct 22, 2024
9603f21
Merge branch 'main' into multi-moodal-sdk-support-one-test
w-javed Oct 22, 2024
af143e8
new asset with 1 test recording only
w-javed Oct 22, 2024
511e4b5
chore: Update assets.json
kdestin Oct 22, 2024
ac94148
conftest fix
w-javed Oct 23, 2024
4f445f6
Merge branch 'main' into multi-moodal-sdk-support-one-test
w-javed Oct 23, 2024
dc7cb7d
assets change
w-javed Oct 23, 2024
48bec25
new test
w-javed Oct 23, 2024
307b4e4
few changes
w-javed Oct 23, 2024
20093f8
removing proxy start
w-javed Oct 23, 2024
e819a80
added all tests
w-javed Oct 24, 2024
6f1595e
merge with asset
w-javed Oct 24, 2024
60a823f
asset
w-javed Oct 24, 2024
b6334eb
fixes
w-javed Oct 25, 2024
9092831
Merge branch 'main' into multi-moodal-sdk-support-one-test
w-javed Oct 25, 2024
93ba2f0
fixes with asset
w-javed Oct 25, 2024
1be5ef1
asset-after-tax
w-javed Oct 25, 2024
78f8ec2
enabling 2 more tests
w-javed Oct 25, 2024
84d4eac
unit test fix
w-javed Oct 25, 2024
7a9eb2b
asset
w-javed Oct 25, 2024
30eba68
new asset
w-javed Oct 25, 2024
ca7cdfe
fixes per comments
w-javed Oct 25, 2024
9afeb5f
changes by black
w-javed Oct 25, 2024
dd67a01
merge fix
w-javed Oct 25, 2024
c5fb4f1
merge fix
w-javed Oct 25, 2024
1701076
pylint fix
w-javed Oct 25, 2024
9397aaf
merge conflict
w-javed Oct 25, 2024
a1d9be9
pylint fix
w-javed Oct 26, 2024
47ff5fd
ground test fix
w-javed Oct 26, 2024
a7689a2
fixes - pylint, black, mypy
w-javed Oct 26, 2024
9c09880
more tests
w-javed Oct 26, 2024
ebd21d3
docstring fixes
w-javed Oct 26, 2024
c9db879
merge conflict
w-javed Oct 26, 2024
9fdef18
doc string fix
w-javed Oct 26, 2024
058c37a
asset
w-javed Oct 26, 2024
1e15809
few updates after Nagkumar review
w-javed Oct 28, 2024
49d3a02
fix
w-javed Oct 28, 2024
a155e1b
test fix
w-javed Oct 28, 2024
87a8416
fix mypy
w-javed Oct 28, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -90,24 +90,25 @@ def _store_multimodal_content(messages, tmpdir: str):

# traverse all messages and replace base64 image data with new file name.
for message in messages:
for content in message.get("content", []):
if content.get("type") == "image_url":
image_url = content.get("image_url")
if image_url and "url" in image_url and image_url["url"].startswith("data:image/jpg;base64,"):
# Extract the base64 string
base64image = image_url["url"].replace("data:image/jpg;base64,", "")

# Generate a unique filename
image_file_name = f"{str(uuid.uuid4())}.jpg"
image_url["url"] = f"images/{image_file_name}" # Replace the base64 URL with the file path

# Decode the base64 string to binary image data
image_data_binary = base64.b64decode(base64image)

# Write the binary image data to the file
image_file_path = os.path.join(images_folder_path, image_file_name)
with open(image_file_path, "wb") as f:
f.write(image_data_binary)
if isinstance(message.get("content", []), list):
for content in message.get("content", []):
if content.get("type") == "image_url":
image_url = content.get("image_url")
if image_url and "url" in image_url and image_url["url"].startswith("data:image/jpg;base64,"):
# Extract the base64 string
base64image = image_url["url"].replace("data:image/jpg;base64,", "")

# Generate a unique filename
image_file_name = f"{str(uuid.uuid4())}.jpg"
image_url["url"] = f"images/{image_file_name}" # Replace the base64 URL with the file path

# Decode the base64 string to binary image data
image_data_binary = base64.b64decode(base64image)

# Write the binary image data to the file
image_file_path = os.path.join(images_folder_path, image_file_name)
with open(image_file_path, "wb") as f:
f.write(image_data_binary)


def _log_metrics_and_instance_results(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{"messages":[{"role":"system","content":[{"type":"text","text":"This is a nature boardwalk at the University of Wisconsin-Madison."}]},{"role":"user","content":[{"type":"text","text":"Can you describe this image?"},{"type":"image_url","image_url":{"url":"https://cdn.britannica.com/68/178268-050-5B4E7FB6/Tom-Cruise-2013.jpg"}}]}]}
{"messages":[{"role":"system","content":[{"type":"text","text":"This is a nature boardwalk at the University of Wisconsin-Madison."}]},{"role":"user","content":[{"type":"text","text":"Can you describe this image?"},{"type":"image_url","image_url":{"url":"https://cdn.britannica.com/68/178268-050-5B4E7FB6/Tom-Cruise-2013.jpg"}}]}]}

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
import time
from unittest.mock import MagicMock, patch
from uuid import uuid4

import tempfile
import jwt
import pandas as pd
import pathlib
import pytest
from promptflow.azure._utils._token_cache import ArmTokenCache

Expand Down Expand Up @@ -303,6 +305,30 @@ def test_wrong_artifact_path(
assert len(caplog.records) == 1
assert expected_error in caplog.records[0].message

def test_store_multi_modal_no_images(self, token_mock, caplog):
data_path = os.path.join(pathlib.Path(__file__).parent.resolve(), "data")
data_file = os.path.join(data_path, "generated_qa_chat_conv.jsonl")
data_convo = pd.read_json(data_file, lines=True)
with tempfile.TemporaryDirectory() as tmpdir:
for value in data_convo["messages"]:
ev_utils._store_multimodal_content(value, tmpdir)

def test_store_multi_modal_image_urls(self, token_mock, caplog):
data_path = os.path.join(pathlib.Path(__file__).parent.resolve(), "data")
data_file = os.path.join(data_path, "generated_conv_image_urls.jsonl")
data_convo = pd.read_json(data_file, lines=True)
with tempfile.TemporaryDirectory() as tmpdir:
for value in data_convo["messages"]:
ev_utils._store_multimodal_content(value, tmpdir)

def test_store_multi_modal_images(self, token_mock, caplog):
data_path = os.path.join(pathlib.Path(__file__).parent.resolve(), "data")
data_file = os.path.join(data_path, "generated_conv_images.jsonl")
data_convo = pd.read_json(data_file, lines=True)
with tempfile.TemporaryDirectory() as tmpdir:
for value in data_convo["messages"]:
ev_utils._store_multimodal_content(value, tmpdir)

def test_log_metrics_and_instance_results_logs_error(self, token_mock, caplog):
"""Test that we are logging the error when there is no trace destination."""
logger = logging.getLogger(ev_utils.__name__)
Expand Down