Skip to content

Commit d44a661

Browse files
author
mike dupont
committed
now running
1 parent d95412c commit d44a661

File tree

8 files changed

+446
-242
lines changed

8 files changed

+446
-242
lines changed

.nvmrc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v23.3.0
1+
v23.9.0

packages/adapter-sqlite/src/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -1114,6 +1114,7 @@ const sqliteDatabaseAdapter: Adapter = {
11141114
})
11151115
.catch((error) => {
11161116
elizaLogger.error("Failed to connect to SQLite:", error);
1117+
throw error;
11171118
});
11181119

11191120
return db;

packages/core/src/embedding.ts

+4
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,10 @@ export async function embed(runtime: IAgentRuntime, input: string) {
293293
elizaLogger.log("No input to retrieve cached embedding for");
294294
return null;
295295
}
296+
if (! runtime.messageManager) {
297+
elizaLogger.log("No message manager");
298+
return null;
299+
}
296300

297301
const similaritySearchResult =
298302
await runtime.messageManager.getCachedEmbeddings(input);

packages/core/src/memory.ts

+4
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,10 @@ export class MemoryManager implements IMemoryManager {
114114
levenshtein_score: number;
115115
}[]
116116
> {
117+
if (!this.runtime.databaseAdapter){
118+
throw Error("Database adapter not initialized");
119+
120+
}
117121
return await this.runtime.databaseAdapter.getCachedEmbeddings({
118122
query_table_name: this.tableName,
119123
query_threshold: 2,

pnpm-lock.yaml

+84-84
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

scripts/jsdoc-automation/src/AIService/AIService.ts

+154-151
Original file line numberDiff line numberDiff line change
@@ -259,10 +259,13 @@ export class AIService {
259259
console.log("KM",this.runtime.knowledgeManager)
260260
console.log("Before",this.runtime.memoryManagers)
261261
this.runtime.memoryManagers.set(this.runtime.knowledgeManager.tableName, this.runtime.knowledgeManager);
262+
this.runtime.messageManager =this.runtime.knowledgeManager;
263+
262264
try {
263265
this.runtime.databaseAdapter = dbadapter.init(this.runtime);
264266
} catch (error) {
265267
console.error("Failed to initialize database adapter:", error);
268+
throw error;
266269
}
267270
console.log("After",this.runtime.memoryManagers)
268271
}
@@ -363,164 +366,164 @@ function contentToUuid(content:string):UUID {
363366
return uuid as `${string}-${string}-${string}-${string}-${string}`;
364367
}
365368

366-
async function process_text(this: any, agentId: string, userName: string, name: string, sUserId: string | undefined,
367-
sRoomId: string, text:string, agents: Map<string, any>) {
368-
const roomId = stringToUuid(
369-
sRoomId ?? "default-room-" + agentId
370-
);
371-
const userId = stringToUuid(sUserId ?? "user");
372-
373-
let runtime = agents.get(agentId);
374-
375-
if (!runtime) {
376-
console.error(
377-
`Runtime not found for agentId: ${agentId}`
378-
);
379-
return;
380-
}
381-
382-
await runtime.ensureConnection(
383-
userId,
384-
roomId,
385-
userName,
386-
name,
387-
"direct"
388-
);
369+
// async function process_text(this: any, agentId: string, userName: string, name: string, sUserId: string | undefined,
370+
// sRoomId: string, text:string, agents: Map<string, any>) {
371+
// const roomId = stringToUuid(
372+
// sRoomId ?? "default-room-" + agentId
373+
// );
374+
// const userId = stringToUuid(sUserId ?? "user");
375+
376+
// let runtime = agents.get(agentId);
377+
378+
// if (!runtime) {
379+
// console.error(
380+
// `Runtime not found for agentId: ${agentId}`
381+
// );
382+
// return;
383+
// }
384+
385+
// await runtime.ensureConnection(
386+
// userId,
387+
// roomId,
388+
// userName,
389+
// name,
390+
// "direct"
391+
// );
389392

390393

391-
// if empty text, directly return
392-
if (!text) {
393-
console.error("Empty text");
394-
return;
395-
}
396-
397-
const messageId = stringToUuid(Date.now().toString());
398-
399-
const attachments: Media[] = [];
400-
// if (req.file) {
401-
// const filePath = path.join(
402-
// process.cwd(),
403-
// "data",
404-
// "uploads",
405-
// req.file.filename
406-
// );
407-
// attachments.push({
408-
// id: Date.now().toString(),
409-
// url: filePath,
410-
// title: req.file.originalname,
411-
// source: "direct",
412-
// description: `Uploaded file: ${req.file.originalname}`,
413-
// text: "",
414-
// contentType: req.file.mimetype,
415-
// });
416-
// }
417-
418-
const content: Content = {
419-
text,
420-
attachments,
421-
source: "direct",
422-
inReplyTo: "0-0-0-0-0",
423-
};
424-
425-
const userMessage = {
426-
content,
427-
userId,
428-
roomId,
429-
agentId: runtime.agentId,
430-
};
431-
432-
const memory: Memory = {
433-
id: contentToUuid(content.text), // stringToUuid(messageId + "-" + userId),
434-
...userMessage,
435-
agentId: runtime.agentId,
436-
userId,
437-
roomId,
438-
content,
439-
createdAt: Date.now(),
440-
};
441-
442-
443-
444-
await runtime.messageManager.addEmbeddingToMemory(memory);
445-
await runtime.messageManager.createMemory(memory);
446-
447-
let state = await runtime.composeState(userMessage, {
448-
agentName: runtime.character.name,
449-
});
450-
451-
const context = composeContext({
452-
state,
453-
template: messageHandlerTemplate,
454-
});
455-
456-
const response = await generateMessageResponse({
457-
runtime: runtime,
458-
context,
459-
modelClass: ModelClass.LARGE,
460-
});
461-
462-
if (!response) {
463-
// res.status(500).send(
464-
/// "No response from generateMessageResponse"
465-
console.error("No response from generateMessageResponse");
466-
//);
467-
return;
468-
}
394+
// // if empty text, directly return
395+
// if (!text) {
396+
// console.error("Empty text");
397+
// return;
398+
// }
399+
400+
// const messageId = stringToUuid(Date.now().toString());
401+
402+
// const attachments: Media[] = [];
403+
// // if (req.file) {
404+
// // const filePath = path.join(
405+
// // process.cwd(),
406+
// // "data",
407+
// // "uploads",
408+
// // req.file.filename
409+
// // );
410+
// // attachments.push({
411+
// // id: Date.now().toString(),
412+
// // url: filePath,
413+
// // title: req.file.originalname,
414+
// // source: "direct",
415+
// // description: `Uploaded file: ${req.file.originalname}`,
416+
// // text: "",
417+
// // contentType: req.file.mimetype,
418+
// // });
419+
// // }
420+
421+
// const content: Content = {
422+
// text,
423+
// attachments,
424+
// source: "direct",
425+
// inReplyTo: "0-0-0-0-0",
426+
// };
469427

470-
// save response to memory
471-
const responseMessage: Memory = {
472-
id: stringToUuid(messageId + "-" + runtime.agentId),
473-
...userMessage,
474-
userId: runtime.agentId,
475-
content: response,
476-
embedding: getEmbeddingZeroVector(),
477-
createdAt: Date.now(),
478-
};
479-
480-
await runtime.messageManager.createMemory(responseMessage);
481-
482-
state = await runtime.updateRecentMessageState(state);
483-
484-
let message = null as Content | null;
485-
486-
await runtime.processActions(
487-
memory,
488-
[responseMessage],
489-
state,
490-
async (newMessages: Content | null) => {
491-
message = newMessages;
492-
return [memory];
493-
}
494-
);
428+
// const userMessage = {
429+
// content,
430+
// userId,
431+
// roomId,
432+
// agentId: runtime.agentId,
433+
// };
495434

496-
await runtime.evaluate(memory, state);
435+
// const memory: Memory = {
436+
// id: contentToUuid(content.text), // stringToUuid(messageId + "-" + userId),
437+
// ...userMessage,
438+
// agentId: runtime.agentId,
439+
// userId,
440+
// roomId,
441+
// content,
442+
// createdAt: Date.now(),
443+
// };
497444

498-
// Check if we should suppress the initial message
499-
const action = runtime.actions.find(
500-
(a: { name: string | undefined; }) => a.name === response.action
501-
);
502-
const shouldSuppressInitialMessage =
503-
action?.suppressInitialMessage;
445+
504446

505-
if (!shouldSuppressInitialMessage) {
506-
if (message) {
507-
//res.json([response, message]);
508-
console.log([response, message]);
509-
} else {
510-
//res.json([response]);
511-
console.log([response]);
447+
// await runtime.messageManager.addEmbeddingToMemory(memory);
448+
// await runtime.messageManager.createMemory(memory);
449+
450+
// let state = await runtime.composeState(userMessage, {
451+
// agentName: runtime.character.name,
452+
// });
453+
454+
// const context = composeContext({
455+
// state,
456+
// template: messageHandlerTemplate,
457+
// });
458+
459+
// const response = await generateMessageResponse({
460+
// runtime: runtime,
461+
// context,
462+
// modelClass: ModelClass.LARGE,
463+
// });
464+
465+
// if (!response) {
466+
// // res.status(500).send(
467+
// /// "No response from generateMessageResponse"
468+
// console.error("No response from generateMessageResponse");
469+
// //);
470+
// return;
471+
// }
472+
473+
// // save response to memory
474+
// const responseMessage: Memory = {
475+
// id: stringToUuid(messageId + "-" + runtime.agentId),
476+
// ...userMessage,
477+
// userId: runtime.agentId,
478+
// content: response,
479+
// embedding: getEmbeddingZeroVector(),
480+
// createdAt: Date.now(),
481+
// };
512482

513-
}
514-
} else {
515-
if (message) {
516-
//res.json([message]);
517-
console.log([message]);
518-
} else {
519-
//res.json([]);
520-
console.log([]);
521-
}
522-
}
523-
}
483+
// await runtime.messageManager.createMemory(responseMessage);
484+
485+
// state = await runtime.updateRecentMessageState(state);
486+
487+
// let message = null as Content | null;
488+
489+
// await runtime.processActions(
490+
// memory,
491+
// [responseMessage],
492+
// state,
493+
// async (newMessages: Content | null) => {
494+
// message = newMessages;
495+
// return [memory];
496+
// }
497+
// );
498+
499+
// await runtime.evaluate(memory, state);
500+
501+
// // Check if we should suppress the initial message
502+
// const action = runtime.actions.find(
503+
// (a: { name: string | undefined; }) => a.name === response.action
504+
// );
505+
// const shouldSuppressInitialMessage =
506+
// action?.suppressInitialMessage;
507+
508+
// if (!shouldSuppressInitialMessage) {
509+
// if (message) {
510+
// //res.json([response, message]);
511+
// console.log([response, message]);
512+
// } else {
513+
// //res.json([response]);
514+
// console.log([response]);
515+
516+
// }
517+
// } else {
518+
// if (message) {
519+
// //res.json([message]);
520+
// console.log([message]);
521+
// } else {
522+
// //res.json([]);
523+
// console.log([]);
524+
// }
525+
// }
526+
// }
524527

525528
// interface IMemoryManager {
526529
// runtime: string;

scripts/jsdoc-automation/src/IGitManager.ts

+22
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,28 @@ export interface CreatePullRequestOptions {
1212
/**
1313
* Manages operations related to interacting with a Git repository using the GitHub API.
1414
*/
15+
// Helper interface definitions
16+
interface CommitFileChange {
17+
filename: string;
18+
status: string;
19+
additions: number;
20+
deletions: number;
21+
changes: number;
22+
}
23+
24+
interface CommitInfo {
25+
commit: {
26+
hash: string;
27+
date: string;
28+
message: string;
29+
author: {
30+
name: string;
31+
email: string;
32+
};
33+
};
34+
files: CommitFileChange[];
35+
}
36+
1537
export interface IGitManager {
1638

1739
getFilesInPullRequest(

0 commit comments

Comments
 (0)