@@ -49,13 +49,6 @@ export async function indexIssue(issue: Issue | RestIssue, repository: { owner:
49
49
const text = chunkIssue ( issue )
50
50
const issueHash = hash ( text )
51
51
52
- // const res = await storage.getItem<StoredEmbeddings>(storageKey)
53
- // if (res && (res.mtime <= issueUpdatedTime || res.hash === issueHash)) {
54
- // return res.embeddings
55
- // }
56
-
57
- const embeddings = await generateEmbedding ( text )
58
-
59
52
const issueMetadata : IssueMetadata = {
60
53
owner : repository . owner . login ,
61
54
repository : repository . name ,
@@ -66,6 +59,25 @@ export async function indexIssue(issue: Issue | RestIssue, repository: { owner:
66
59
labels : issue . labels ?. map ( l => typeof l === 'string' ? l : JSON . stringify ( { name : l . name , color : l . color } ) ) ,
67
60
}
68
61
62
+ const res = await storage . getItem < StoredEmbeddings > ( storageKey )
63
+ if ( res && ( res . mtime <= issueUpdatedTime || res . hash === issueHash ) ) {
64
+ return await Promise . all ( [
65
+ vectorize ?. insert ( [ {
66
+ id : storageKey ,
67
+ values : res . embeddings ,
68
+ metadata : issueMetadata ,
69
+ } ] ) ,
70
+ storage . setItem ( storageKey , {
71
+ metadata : issueMetadata ,
72
+ mtime : issueUpdatedTime ,
73
+ hash : issueHash ,
74
+ embeddings : res . embeddings ,
75
+ } ) ,
76
+ ] )
77
+ }
78
+
79
+ const embeddings = await generateEmbedding ( text )
80
+
69
81
await Promise . all ( [
70
82
vectorize ?. insert ( [ {
71
83
id : storageKey ,
0 commit comments