강의

멘토링

로드맵

Inflearn Community Q&A

rlatprua46662's profile image
rlatprua46662

asked

Complete AI Agent Development All-in-One (w. LangGraph, Google ADK, CrewAI)

Granting Memory Capabilities to Agents, Developing Long-term Memory Features (w. Firebase)

firestore query 문제

Written on

·

30

0

def get_conversation_context(self, limit=10): 
    docs = list( 
        self.db.collection(self.collection_name) 
        .order_by("timestamp", direction="ASCENDING") 
        .limit(limit) 
        .stream() 
    ) 
    if not docs: 
        return "이전 대화 없음" context = "=== 최근 대화 기록 ===\n" 
    for i, chat in enumerate(docs, 1): 
        context += f"{i}. 사용자: {chat.get("user_message")}\n" 
        context += f" 봇: {chat.get("bot_response")}\n\n" 
        return context

이 함수에서 timestamp로 정렬해서 가져오는데 최근 대화 10건을 가져오려면 ASCENDING이 아닌 DESCENDING으로 최근 대화내역을 가져와서 reverse로 다시 순서를 오래된 순으로 교체해줘야 맞는거 아닌가요?

python

Answer

This question is waiting for answers
Be the first to answer!
rlatprua46662's profile image
rlatprua46662

asked

Ask a question