Add chat image upload support
This commit is contained in:
33
README.md
33
README.md
@@ -69,6 +69,39 @@ with ChatClient(api_key="fastgpt-xxxxx") as client:
|
||||
)
|
||||
```
|
||||
|
||||
### Chat with an Image
|
||||
|
||||
Upload the image to FastGPT's chat file storage first, then reference the returned URL in a chat message.
|
||||
|
||||
```python
|
||||
from fastgpt_client import ChatClient
|
||||
|
||||
app_id = "your-app-id"
|
||||
chat_id = "my_conversation_123"
|
||||
|
||||
with ChatClient(api_key="fastgpt-xxxxx", base_url="http://localhost:3000") as client:
|
||||
image = client.upload_chat_image(
|
||||
appId=app_id,
|
||||
chatId=chat_id,
|
||||
file_path="example.png",
|
||||
)
|
||||
|
||||
response = client.create_chat_completion(
|
||||
chatId=chat_id,
|
||||
messages=[
|
||||
{
|
||||
"role": "user",
|
||||
"content": [
|
||||
{"type": "text", "text": "Please describe this image."},
|
||||
{"type": "image_url", "image_url": {"url": image["url"]}},
|
||||
],
|
||||
}
|
||||
],
|
||||
)
|
||||
|
||||
print(response.json()["choices"][0]["message"]["content"])
|
||||
```
|
||||
|
||||
### Using Variables
|
||||
|
||||
```python
|
||||
|
||||
Reference in New Issue
Block a user