MCPcopy Index your code
hub / github.com/PromtEngineer/localGPT / get_messages

Method get_messages

backend/database.py:184–204  ·  view source on GitHub ↗

Get all messages for a session

(self, session_id: str, limit: int = 100)

Source from the content-addressed store, hash-verified

182 return message_id
183
184 def get_messages(self, session_id: str, limit: int = 100) -> List[Dict]:
185 """Get all messages for a session"""
186 conn = sqlite3.connect(self.db_path)
187 conn.row_factory = sqlite3.Row
188
189 cursor = conn.execute('''
190 SELECT id, content, sender, timestamp, metadata
191 FROM messages
192 WHERE session_id = ?
193 ORDER BY timestamp ASC
194 LIMIT ?
195 ''', (session_id, limit))
196
197 messages = []
198 for row in cursor.fetchall():
199 message = dict(row)
200 message['metadata'] = json.loads(message['metadata'])
201 messages.append(message)
202
203 conn.close()
204 return messages
205
206 def get_conversation_history(self, session_id: str) -> List[Dict]:
207 """Get conversation history in the format expected by Ollama"""

Callers 3

database.pyFile · 0.80
handle_get_sessionMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected