返回提交历史
Modified
g4f/api/__init__.py
+4
-0
Modified
g4f/gui/client/static/js/chat.v1.js
+7
-3
XFEstudio/gpt4free
Fix unittests
344034fe
代码差异
2 个文件
+11
-3
@@ -408,11 +408,15 @@ class Api:
408
408
@self.app.post("/v1/media/generate", responses=responses)
409
409
@self.app.post("/v1/images/generate", responses=responses)
410
410
@self.app.post("/v1/images/generations", responses=responses)
411
@self.app.post("/api/{provider}/images/generations", responses=responses)
411
412
async def generate_image(
412
413
request: Request,
413
414
config: ImageGenerationConfig,
415
provider: str = None,
414
416
credentials: Annotated[HTTPAuthorizationCredentials, Depends(Api.security)] = None
415
417
):
418
if config.provider is None:
419
config.provider = provider
416
420
if credentials is not None and credentials.credentials != "secret":
417
421
config.api_key = credentials.credentials
418
422
try:
@@ -1641,7 +1641,7 @@ const remove_message = async (conversation_id, index) => {
1641
1641
}
1642
1642
conversation.items = new_items;
1643
1643
await save_conversation(conversation_id, conversation);
1644
if (window.chat_id) {
1644
if (window.chat_id && window.conversation_id == window.start_id) {
1645
1645
const url = `${window.share_url}/backend-api/v2/chat/${window.chat_id}`;
1646
1646
await fetch(url, {
1647
1647
method: 'POST',
@@ -1717,7 +1717,7 @@ const add_message = async (
1717
1717
conversation.items = new_messages;
1718
1718
}
1719
1719
await save_conversation(conversation_id, conversation);
1720
if (window.chat_id) {
1720
if (window.chat_id && conversation_id == window.start_id) {
1721
1721
const url = `${window.share_url}/backend-api/v2/chat/${window.chat_id}`;
1722
1722
fetch(url, {
1723
1723
method: 'POST',
@@ -2112,7 +2112,11 @@ window.addEventListener('load', async function() {
2112
2112
return;
2113
2113
}
2114
2114
const response = await fetch(`${window.share_url}/backend-api/v2/chat/${window.chat_id}`, {
2115
headers: {'accept': 'application/json', 'if-none-match': conversation.updated},
2115
headers: {
2116
'accept': 'application/json',
2117
'if-none-match': conversation.updated,
2118
'x-conversation-id': conversation.id,
2119
},
2116
2120
});
2117
2121
if (response.status == 200) {
2118
2122
const new_conversation = await response.json();