微软的Azure页面 : https://learn.microsoft.com/zh-cn/azure/ai-services/openai/concepts/models
调用代码:https://learn.microsoft.com/zh-cn/azure/ai-services/openai/how-to/switching-endpoints
openai说明: https://platform.openai.com/docs/guides/vision
不同区域的服务器开通不同模型 美国西部
代码
,GPT4识别图片,并中文回复prompt=“What’s in this image? 并使用中文回答”
需要解析的远程图片
from openai import AzureOpenAI
api_key="your_key"
azure_endpoint="your_model_url"
client = AzureOpenAI(
api_key=api_key,
api_version="2023-12-01-preview",
azure_endpoint=azure_endpoint
)
response = client.chat.completions.create(
model="gpt-4-vision-preview",
messages=[
{
"role": "user",
"content": [
{"type": "text", "text": "What’s in this image? 并使用中文回答"},
{
"type": "image_url",
"image_url": {
"url": "https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg",
},
},
],
}
],
max_tokens=300,
)
print(response.choices[0])
这张图片是一个木制的步道穿过一片绿色的草地,远处有一些树木,天空是蓝色的,有一些白云。
Choice(finish_reason=None, index=0, logprobs=None, message=ChatCompletionMessage(
content='这张图片是一个木制的步道穿过一片绿色的草地,远处有一些树木,天空是蓝色的,有一些白云。', role='assistant', function_call=None, tool_calls=None),
finish_details={'type': 'stop', 'stop': '<|fim_suffix|>'},
content_filter_results={'hate': {'filtered': False, 'severity': 'safe'}, 'self_harm': {'filtered': False, 'severity': 'safe'}, 'sexual': {'filtered': False, 'severity': 'safe'}, 'violence': {'filtered': False, 'severity': 'safe'}})