poe API URL fixed

This commit is contained in:
Flatlogic Bot 2026-02-08 23:32:36 +00:00
parent f9ad3d1087
commit b627f4c632

View File

@ -3,6 +3,7 @@ import logging
import random import random
import hashlib import hashlib
from django.utils import timezone from django.utils import timezone
from django.utils.dateparse import parse_datetime
from datetime import timedelta from datetime import timedelta
from .models import AIConfiguration, AIChatHistory, SyncHistoryLog from .models import AIConfiguration, AIChatHistory, SyncHistoryLog
from .utils import decrypt_value from .utils import decrypt_value
@ -128,7 +129,7 @@ def fetch_merlin_history(api_key):
item['id'] = _generate_stable_id(item['title'], 'merlin') item['id'] = _generate_stable_id(item['title'], 'merlin')
return data return data
def fetch_poe_history(api_key): def fetch_poe_history(api_key):
if api_key == "YOUR_MOCK_KEY_OR_EMPTY": if api_key == "YOUR_MOCK_KEY_OR_EMPTY":
# For now, it's returning mock data: # For now, it's returning mock data:
data = [ data = [
@ -143,11 +144,13 @@ def fetch_merlin_history(api_key):
'last_date': timezone.now() - timedelta(hours=8) 'last_date': timezone.now() - timedelta(hours=8)
} }
] ]
return data # or return [] Or handle as error for item in data:
item['id'] = _generate_stable_id(item['title'], 'poe')
return data
# Calling an API endpoint (Replace URL with the actual Poe API you use) # Calling an API endpoint (Replace URL with the actual Poe API you use)
response = httpx.get( response = httpx.get(
"https://api.poe.com/v1/chats", "https://api.poe.com/v1",
headers={"Authorization": f"Bearer {api_key}"} headers={"Authorization": f"Bearer {api_key}"}
) )
response.raise_for_status() response.raise_for_status()
@ -157,7 +160,7 @@ def fetch_merlin_history(api_key):
'id': item['chatId'], 'id': item['chatId'],
'title': item['title'], 'title': item['title'],
'content': item['snippet'], 'content': item['snippet'],
'last_date': parse_date(item['updatedAt']) 'last_date': parse_datetime(item['updatedAt']) or timezone.now()
} for item in data['chats']] } for item in data['chats']]
def fetch_openrouter_history(api_key): def fetch_openrouter_history(api_key):