-
Notifications
You must be signed in to change notification settings - Fork 233
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'gh/vision-gpt-llm-app-temp' of https://github.com/Agent…
…a-AI/agenta into feat/file-input-support-playground
- Loading branch information
Showing
14 changed files
with
128 additions
and
27 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
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
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
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
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,50 @@ | ||
import agenta as ag | ||
from openai import OpenAI | ||
|
||
|
||
client = OpenAI() | ||
|
||
|
||
SYSTEM_PROMPT = "You are an expert in reading images you look into details, you answer in accurate language." | ||
HUMAN_PROMPT = "Please compare two images" | ||
|
||
ag.init(app_name="explain_image", base_name="app") | ||
ag.config.default( | ||
temperature=ag.FloatParam(0.5, 0, 1), | ||
max_tokens=ag.IntParam(300, 1, 4000), | ||
prompt_system=ag.TextParam(SYSTEM_PROMPT), | ||
prompt_human=ag.TextParam(HUMAN_PROMPT), | ||
) | ||
|
||
|
||
@ag.entrypoint | ||
def explain( | ||
image_one: ag.FileInputURL, | ||
image_two: ag.FileInputURL, | ||
) -> str: | ||
messages = [{"role": "system", "content": ag.config.prompt_system}] + [ | ||
{ | ||
"role": "user", | ||
"content": [ | ||
{"type": "text", "text": ag.config.prompt_human}, | ||
{ | ||
"type": "image_url", | ||
"image_url": { | ||
"url": image_one, | ||
}, | ||
}, | ||
{ | ||
"type": "image_url", | ||
"image_url": { | ||
"url": image_two, | ||
}, | ||
}, | ||
], | ||
} | ||
] | ||
chat_completion = client.chat.completions.create( | ||
model="gpt-4-vision-preview", | ||
messages=messages, | ||
max_tokens=max_tokens, | ||
) | ||
return chat_completion.choices[0].message.content |
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,2 @@ | ||
agenta | ||
openai |