Skip to content

Commit 52644d0

Browse files
committed
docs: update image examples to use local files instead of URLs
1 parent eea650c commit 52644d0

File tree

2 files changed

+20
-6
lines changed

2 files changed

+20
-6
lines changed

docs/en/sgr-api/SGR-Integration-&-Examples.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,21 +103,27 @@ print("\n\nResearch completed!")
103103

104104
### Example 3: Research Request with Image
105105

106-
Send a research request with an image attachment.
106+
Send a research request with a local image file attachment.
107107

108108
```python
109+
import base64
109110
from openai import OpenAI
110111

111112
client = OpenAI(base_url="http://localhost:8010/v1", api_key="dummy")
112113

113-
# Research request with image
114+
# Read local image file and encode to base64
115+
with open("chart.png", "rb") as image_file:
116+
image_data = base64.b64encode(image_file.read()).decode("utf-8")
117+
image_url = f"data:image/png;base64,{image_data}"
118+
119+
# Research request with local image
114120
response = client.chat.completions.create(
115121
model="sgr-agent",
116122
messages=[{
117123
"role": "user",
118124
"content": [
119125
{"type": "text", "text": "Analyze this chart and research the trends shown"},
120-
{"type": "image_url", "image_url": {"url": "https://example.com/chart.png"}}
126+
{"type": "image_url", "image_url": {"url": image_url}}
121127
]
122128
}],
123129
stream=True,
@@ -131,6 +137,7 @@ for chunk in response:
131137
```
132138

133139
**Image Formats Supported:**
140+
- Local image files (converted to Base64): PNG, JPEG, GIF, WebP
134141
- Image URLs (HTTP/HTTPS)
135142
- Base64 encoded images (`data:image/jpeg;base64,...` or `data:image/png;base64,...`)
136143

docs/ru/sgr-api/SGR-Integration-&-Examples.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,21 +103,27 @@ print("\n\nИсследование завершено!")
103103

104104
### Пример 3: Исследовательский запрос с изображением
105105

106-
Отправка исследовательского запроса с вложенным изображением.
106+
Отправка исследовательского запроса с локальным файлом изображения.
107107

108108
```python
109+
import base64
109110
from openai import OpenAI
110111

111112
client = OpenAI(base_url="http://localhost:8010/v1", api_key="dummy")
112113

113-
# Исследовательский запрос с изображением
114+
# Прочитать локальный файл изображения и закодировать в base64
115+
with open("chart.png", "rb") as image_file:
116+
image_data = base64.b64encode(image_file.read()).decode("utf-8")
117+
image_url = f"data:image/png;base64,{image_data}"
118+
119+
# Исследовательский запрос с локальным изображением
114120
response = client.chat.completions.create(
115121
model="sgr-agent",
116122
messages=[{
117123
"role": "user",
118124
"content": [
119125
{"type": "text", "text": "Проанализируй этот график и исследуй показанные тренды"},
120-
{"type": "image_url", "image_url": {"url": "https://example.com/chart.png"}}
126+
{"type": "image_url", "image_url": {"url": image_url}}
121127
]
122128
}],
123129
stream=True,
@@ -131,6 +137,7 @@ for chunk in response:
131137
```
132138

133139
**Поддерживаемые форматы изображений:**
140+
- Локальные файлы изображений (конвертируются в Base64): PNG, JPEG, GIF, WebP
134141
- URL изображений (HTTP/HTTPS)
135142
- Изображения в формате Base64 (`data:image/jpeg;base64,...` или `data:image/png;base64,...`)
136143

0 commit comments

Comments
 (0)