Add human-led conversation learning loop
This commit is contained in:
1 parent
bc42c55555
commit
687abab82b
52 files changed
+2112
-53
No files matched your search
@@ -43,6 +43,7 @@ interface SendRow {
|
||||
matrix_text_event_id: string | null;
|
||||
mxc_uri: string | null;
|
||||
error: string | null;
|
||||
initiated_by: 'automation' | 'human';
|
||||
}
|
||||
|
||||
export interface CreateMediaLibraryAsset {
|
||||
@@ -164,18 +165,19 @@ export class MediaLibraryRepository {
|
||||
conversationId: string,
|
||||
incomingKey: string,
|
||||
requestKind: MediaRequestKind,
|
||||
initiatedBy: 'automation' | 'human' = 'automation',
|
||||
now = Date.now(),
|
||||
): MediaLibrarySend | null {
|
||||
try {
|
||||
this.db.prepare(`
|
||||
INSERT INTO media_library_sends (
|
||||
asset_id, asset_sha256, account_id, conversation_id, incoming_key, request_kind,
|
||||
status, requested_at
|
||||
status, requested_at, initiated_by
|
||||
)
|
||||
SELECT asset_id, sha256, ?, ?, ?, ?, 'pending', ?
|
||||
SELECT asset_id, sha256, ?, ?, ?, ?, 'pending', ?, ?
|
||||
FROM media_library_assets
|
||||
WHERE asset_id = ? AND deleted_at IS NULL AND enabled = 1
|
||||
`).run(accountId, conversationId, incomingKey, requestKind, now, assetId);
|
||||
`).run(accountId, conversationId, incomingKey, requestKind, now, initiatedBy, assetId);
|
||||
return this.getSend(accountId, conversationId, incomingKey) ?? null;
|
||||
} catch (error) {
|
||||
if (error instanceof Error && /UNIQUE constraint failed/.test(error.message)) return null;
|
||||
@@ -253,5 +255,6 @@ function mapSend(row: SendRow): MediaLibrarySend {
|
||||
matrixTextEventId: row.matrix_text_event_id,
|
||||
mxcUri: row.mxc_uri,
|
||||
error: row.error,
|
||||
initiatedBy: row.initiated_by,
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user