MCPcopy Create free account
hub / github.com/AutoForgeAI/autoforge / get_conversation

Function get_conversation

server/services/assistant_database.py:201–225  ·  view source on GitHub ↗

Get a conversation with all its messages.

(project_dir: Path, conversation_id: int)

Source from the content-addressed store, hash-verified

199
200
201def get_conversation(project_dir: Path, conversation_id: int) -> Optional[dict]:
202 """Get a conversation with all its messages."""
203 session = get_session(project_dir)
204 try:
205 conversation = session.query(Conversation).filter(Conversation.id == conversation_id).first()
206 if not conversation:
207 return None
208 return {
209 "id": conversation.id,
210 "project_name": conversation.project_name,
211 "title": conversation.title,
212 "created_at": conversation.created_at.isoformat() if conversation.created_at else None,
213 "updated_at": conversation.updated_at.isoformat() if conversation.updated_at else None,
214 "messages": [
215 {
216 "id": m.id,
217 "role": m.role,
218 "content": m.content,
219 "timestamp": m.timestamp.isoformat() if m.timestamp else None,
220 }
221 for m in sorted(conversation.messages, key=lambda x: x.timestamp or datetime.min)
222 ],
223 }
224 finally:
225 session.close()
226
227
228def delete_conversation(project_dir: Path, conversation_id: int) -> bool:

Callers 1

get_project_conversationFunction · 0.85

Calls 2

get_sessionFunction · 0.70
closeMethod · 0.45

Tested by

no test coverage detected