2023-11-08 03:48:51 +00:00
|
|
|
{
|
|
|
|
"cells": [
|
2023-11-08 05:48:25 +00:00
|
|
|
{
|
|
|
|
"cell_type": "markdown",
|
|
|
|
"metadata": {},
|
|
|
|
"source": [
|
|
|
|
"<div>\n",
|
|
|
|
" <img src=\"https://user-images.githubusercontent.com/1991296/230134379-7181e485-c521-4d23-a0d6-f7b3b61ba524.png\" width=\"500\"/>\n",
|
|
|
|
"</div>"
|
|
|
|
]
|
|
|
|
},
|
2023-11-08 03:48:51 +00:00
|
|
|
{
|
|
|
|
"cell_type": "code",
|
|
|
|
"execution_count": 1,
|
|
|
|
"metadata": {},
|
|
|
|
"outputs": [
|
|
|
|
{
|
|
|
|
"name": "stdout",
|
|
|
|
"output_type": "stream",
|
|
|
|
"text": [
|
2023-11-08 05:48:25 +00:00
|
|
|
"{'text': 'Llama C++'}\n"
|
2023-11-08 03:48:51 +00:00
|
|
|
]
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"source": [
|
|
|
|
"from openai import OpenAI\n",
|
|
|
|
"\n",
|
|
|
|
"client = OpenAI(base_url=\"http://100.64.159.73:8000/v1\", api_key=\"sk-1234\")\n",
|
|
|
|
"response = client.chat.completions.create(\n",
|
|
|
|
" model=\"gpt-4-vision-preview\",\n",
|
|
|
|
" messages=[\n",
|
|
|
|
" {\n",
|
|
|
|
" \"role\": \"user\",\n",
|
|
|
|
" \"content\": [\n",
|
|
|
|
" {\n",
|
|
|
|
" \"type\": \"image_url\",\n",
|
|
|
|
" \"image_url\": {\n",
|
2023-11-08 05:48:25 +00:00
|
|
|
" \"url\": \"https://user-images.githubusercontent.com/1991296/230134379-7181e485-c521-4d23-a0d6-f7b3b61ba524.png\",\n",
|
2023-11-08 03:48:51 +00:00
|
|
|
" },\n",
|
|
|
|
" },\n",
|
2023-11-08 05:48:25 +00:00
|
|
|
" {\"type\": \"text\", \"text\": \"What does the image say. Format your response as a json object with a single 'text' key.\"},\n",
|
2023-11-08 03:48:51 +00:00
|
|
|
" ],\n",
|
|
|
|
" }\n",
|
|
|
|
" ],\n",
|
2023-11-08 05:48:25 +00:00
|
|
|
" response_format={ \"type\": \"json_object\" }\n",
|
2023-11-08 03:48:51 +00:00
|
|
|
")\n",
|
2023-11-08 05:48:25 +00:00
|
|
|
"import json\n",
|
|
|
|
"print(json.loads(response.choices[0].message.content))"
|
2023-11-08 03:48:51 +00:00
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
|
|
|
"execution_count": null,
|
|
|
|
"metadata": {},
|
|
|
|
"outputs": [],
|
|
|
|
"source": []
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"metadata": {
|
|
|
|
"kernelspec": {
|
|
|
|
"display_name": ".venv",
|
|
|
|
"language": "python",
|
|
|
|
"name": "python3"
|
|
|
|
},
|
|
|
|
"language_info": {
|
|
|
|
"codemirror_mode": {
|
|
|
|
"name": "ipython",
|
|
|
|
"version": 3
|
|
|
|
},
|
|
|
|
"file_extension": ".py",
|
|
|
|
"mimetype": "text/x-python",
|
|
|
|
"name": "python",
|
|
|
|
"nbconvert_exporter": "python",
|
|
|
|
"pygments_lexer": "ipython3",
|
|
|
|
"version": "3.11.5+"
|
|
|
|
},
|
|
|
|
"orig_nbformat": 4
|
|
|
|
},
|
|
|
|
"nbformat": 4,
|
|
|
|
"nbformat_minor": 2
|
|
|
|
}
|