-
Notifications
You must be signed in to change notification settings - Fork 895
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[prompty] Prompty supports image as input (#3303)
# Description prompty ``` --- name: Basic Prompt with Image description: A basic prompt that uses the GPT-3 chat API to answer questions model: api: chat configuration: type: azure_openai azure_deployment: gpt-4-vision-preview connection: azure_open_ai_connection parameters: temperature: 0.2 sample: image: "data:image/jpg;path:../datas/logo.jpg" question: what is it --- system: As an AI assistant, your task involves interpreting images and responding to questions about the image. Remember to provide accurate answers based on the information present in the image. Directly give the answer, no more explanation is needed. # user: {{question}} ![image]({{image}}) ``` ```python prompty = Prompty.load(source="path/to/prompty.prompty") # Local image path prompty(image="data:image/jpg;path:path/to/image.jpg") # image url prompty(image="data:image/jpg;url:http://link.to.image.jpg") # or image obj from promptflow.contracts.multimedia import Image image = Image(image_buffer, mime_type="image/png") prompty(image=image) ``` Trace: ![image](https://github.com/microsoft/promptflow/assets/17938940/5ffe8dcd-6fcd-4c0b-a28b-fa3c9ca072a0) Please add an informative description that covers that changes made by the pull request and link all relevant issues. # All Promptflow Contribution checklist: - [ ] **The pull request does not introduce [breaking changes].** - [ ] **CHANGELOG is updated for new features, bug fixes or other significant changes.** - [ ] **I have read the [contribution guidelines](../CONTRIBUTING.md).** - [ ] **Create an issue and link to the pull request to get dedicated review from promptflow team. Learn more: [suggested workflow](../CONTRIBUTING.md#suggested-workflow).** ## General Guidelines and Best Practices - [ ] Title of the pull request is clear and informative. - [ ] There are a small number of commits, each of which have an informative message. This means that previously merged commits do not appear in the history of the PR. For more information on cleaning up the commits in your PR, [see this page](https://github.com/Azure/azure-powershell/blob/master/documentation/development-docs/cleaning-up-commits.md). ### Testing Guidelines - [ ] Pull request includes test coverage for the included changes.
- Loading branch information
1 parent
71b308b
commit 52f6b90
Showing
4 changed files
with
145 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
src/promptflow/tests/test_configs/prompty/prompty_with_image.prompty
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
--- | ||
name: Basic Prompt with Image | ||
description: A basic prompt that uses the GPT-3 chat API to answer questions | ||
model: | ||
api: chat | ||
configuration: | ||
type: azure_openai | ||
azure_deployment: gpt-4-vision-preview | ||
connection: azure_open_ai_connection | ||
parameters: | ||
temperature: 0.2 | ||
sample: | ||
image: "data:image/jpg;path:../datas/logo.jpg" | ||
question: what is it | ||
--- | ||
system: | ||
As an AI assistant, your task involves interpreting images and responding to questions about the image. | ||
Remember to provide accurate answers based on the information present in the image. | ||
Directly give the answer, no more explanation is needed. | ||
|
||
# user: | ||
{{question}} | ||
![image]({{image}}) |