返回提交历史
Modified
g4f/Provider/PollinationsAI.py
+3
-3
Modified
g4f/gui/client/static/js/chat.v1.js
+7
-4
XFEstudio/gpt4free
Limit URL length for PollinationsAI
f723e92a
代码差异
2 个文件
+10
-7
@@ -239,11 +239,11 @@ class PollinationsAI(AsyncGeneratorProvider, ProviderModelMixin):
239
239
}, aspect_ratio)
240
240
query = "&".join(f"{k}={quote_plus(str(v))}" for k, v in params.items() if v is not None)
241
241
url = f"{cls.image_api_endpoint}prompt/{quote_plus(prompt)}?{query}"
242
242
url = url[:8192] # Limit URL length
243
243
async with ClientSession(headers=DEFAULT_HEADERS, connector=get_connector(proxy=proxy)) as session:
244
async with session.get(url, allow_redirects=True) as response:
244
async with session.get(url, allow_redirects=False) as response:
245
245
await raise_for_status(response)
246
yield ImageResponse(url, prompt)
246
yield ImageResponse(response.headers.get("location", str(response.url)), prompt)
247
247
248
248
@classmethod
249
249
async def _generate_text(
@@ -829,7 +829,7 @@ async function add_message_chunk(message, message_id, provider, scroll, finish_m
829
829
for (const [key, value] of Object.entries(message.conversation)) {
830
830
conversation.data[key] = value;
831
831
}
832
await save_conversation(conversation_id, conversation, false);
832
await save_conversation(conversation_id, conversation);
833
833
} else if (message.type == "provider") {
834
834
provider_storage[message_id] = message.provider;
835
835
let provider_el = content_map.content.querySelector('.provider');
@@ -1619,7 +1619,7 @@ const remove_message = async (conversation_id, index) => {
1619
1619
await save_conversation(conversation_id, conversation);
1620
1620
if (window.chat_id) {
1621
1621
const url = `/backend-api/v2/chat/${window.chat_id}`;
1622
response = await fetch(url, {
1622
await fetch(url, {
1623
1623
method: 'POST',
1624
1624
headers: {'content-type': 'application/json'},
1625
1625
body: data,
@@ -2037,6 +2037,9 @@ chatPrompt.addEventListener("input", function() {
2037
2037
});
2038
2038
2039
2039
window.addEventListener('load', async function() {
2040
if (!window.chat_id) {
2041
return;
2042
}
2040
2043
if (!window.conversation_id) {
2041
2044
window.conversation_id = window.chat_id;
2042
2045
}
@@ -2045,7 +2048,7 @@ window.addEventListener('load', async function() {
2045
2048
});
2046
2049
if (response.ok) {
2047
2050
let conversation = await response.json();
2048
if (window.chat_id && (!window.conversation_id || conversation.id == window.conversation_id)) {
2051
if (!window.conversation_id || conversation.id == window.conversation_id) {
2049
2052
window.conversation_id = conversation.id;
2050
2053
await load_conversation(conversation);
2051
2054
appStorage.setItem(
@@ -2086,7 +2089,7 @@ window.addEventListener('load', async function() {
2086
2089
2087
2090
window.addEventListener('DOMContentLoaded', async function() {
2088
2091
await on_load();
2089
if (!window.conversation_id == "{{chat_id}}") {
2092
if (window.conversation_id == "{{conversation_id}}") {
2090
2093
window.conversation_id = uuid();
2091
2094
} else {
2092
2095
await on_api();