|
import gradio as gr |
|
import openai |
|
import os |
|
from openai import OpenAI |
|
client = OpenAI(api_key="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") |
|
|
|
|
|
|
|
|
|
def get_response(text, image1, image2, image3, image4): |
|
response = client.chat.completions.create( |
|
model="gpt-4-vision-preview", |
|
messages=[{ |
|
"role": "user", |
|
"content": [ |
|
{"type": "text","text": f'{text}'}, |
|
{"type": "image_url","image_url": {"url": f'{image1}'},}, |
|
{"type": "image_url","image_url": {"url": f'{image2}'},}, |
|
{"type": "image_url","image_url": {"url": f'{image3}'},}, |
|
{"type": "image_url","image_url": {"url": f'{image4}'},}, |
|
],}], |
|
temperature=0, |
|
max_tokens=600 |
|
) |
|
return response.choices[0].message.content |
|
|
|
|
|
iface = gr.Interface( |
|
fn=get_response, |
|
inputs=["text", "text", "text", "text", "text"], |
|
outputs="text" |
|
) |
|
|
|
iface.launch() |
|
|