Files
wehub-resource-sync e768098d0e
tools_continuous_delivery / Private PyPI non-main branch release (push) Has been skipped
tools_continuous_delivery / Private PyPI main branch release (push) Failing after 2m42s
Publish Promptflow Doc / Build (push) Has been cancelled
Publish Promptflow Doc / Deploy (push) Has been cancelled
Flake8 Lint / flake8 (push) Has been cancelled
Spell check CI / Spell_Check (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 13:39:52 +08:00

60 lines
1.5 KiB
Python

"""Test script for the chat-with-image MAF workflow."""
import asyncio
from dotenv import load_dotenv
load_dotenv()
from workflow import ChatInput, create_workflow # noqa: E402
async def test_single_turn():
"""Single-turn: ask about an image."""
workflow = create_workflow()
result = await workflow.run(
ChatInput(
question=[
"How many colors can you see?",
{"data:image/png;url": "https://uhf.microsoft.com/images/microsoft/RE1Mu3b.png"},
]
)
)
output = result.get_outputs()[0]
print("Answer:", output)
assert isinstance(output, str) and len(output) > 0
async def test_multi_turn():
"""Multi-turn: follow-up about the same image."""
chat_history = [
{
"inputs": {
"question": [
{"data:image/png;url": "https://uhf.microsoft.com/images/microsoft/RE1Mu3b.png"},
"What is in this image?",
]
},
"outputs": {"answer": "This is a logo."},
}
]
workflow = create_workflow()
result = await workflow.run(
ChatInput(
question=["Describe it in more detail."],
chat_history=chat_history,
)
)
output = result.get_outputs()[0]
print("Answer:", output)
assert isinstance(output, str) and len(output) > 0
async def main():
await test_single_turn()
await test_multi_turn()
if __name__ == "__main__":
asyncio.run(main())