Improve download of generated images, serve images in the api (#2391)

* Improve download of generated images, serve images in the api
Add support for conversation handling in the api

* Add orginal prompt to image response

* Add download images option in gui, fix loading model list in Airforce

* Add download images option in gui, fix loading model list in Airforce
This commit is contained in:
H Lohaus 2024-11-20 19:58:16 +01:00 committed by GitHub
parent c959d9b469
commit ffb4b0d162
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
29 changed files with 494 additions and 328 deletions

View file

@ -1,13 +1,17 @@
import requests
import json
import uuid
url = "http://localhost:1337/v1/chat/completions"
conversation_id = str(uuid.uuid4())
body = {
"model": "",
"provider": "",
"provider": "Copilot",
"stream": True,
"messages": [
{"role": "user", "content": "What can you do? Who are you?"}
]
{"role": "user", "content": "Hello, i am Heiner. How are you?"}
],
"conversation_id": conversation_id
}
response = requests.post(url, json=body, stream=True)
response.raise_for_status()
@ -21,4 +25,27 @@ for line in response.iter_lines():
print(json_data.get("choices", [{"delta": {}}])[0]["delta"].get("content", ""), end="")
except json.JSONDecodeError:
pass
print()
print()
print()
print()
body = {
"model": "",
"provider": "Copilot",
"stream": True,
"messages": [
{"role": "user", "content": "Tell me somethings about my name"}
],
"conversation_id": conversation_id
}
response = requests.post(url, json=body, stream=True)
response.raise_for_status()
for line in response.iter_lines():
if line.startswith(b"data: "):
try:
json_data = json.loads(line[6:])
if json_data.get("error"):
print(json_data)
break
print(json_data.get("choices", [{"delta": {}}])[0]["delta"].get("content", ""), end="")
except json.JSONDecodeError:
pass