Refactor settings manager (#39)
Co-authored-by: Shubham Naik <shub@memgpt.ai>
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
import Letta from "@letta-ai/letta-client";
|
||||
import { loadSettings, updateSettings } from "../settings";
|
||||
import { settingsManager } from "../settings-manager";
|
||||
|
||||
export async function getClient() {
|
||||
const settings = await loadSettings();
|
||||
const settings = settingsManager.getSettings();
|
||||
|
||||
const apiKey = process.env.LETTA_API_KEY || settings.env?.LETTA_API_KEY;
|
||||
if (!apiKey) {
|
||||
@@ -34,7 +34,7 @@ export async function getClient() {
|
||||
}
|
||||
|
||||
if (needsUpdate) {
|
||||
await updateSettings({ env: updatedEnv });
|
||||
settingsManager.updateSettings({ env: updatedEnv });
|
||||
}
|
||||
|
||||
return new Letta({ apiKey, baseURL });
|
||||
|
||||
@@ -11,7 +11,7 @@ import {
|
||||
loadProjectSettings,
|
||||
updateProjectSettings,
|
||||
} from "../project-settings";
|
||||
import { loadSettings, updateSettings } from "../settings";
|
||||
import { settingsManager } from "../settings-manager";
|
||||
import { getToolNames } from "../tools/manager";
|
||||
import { getClient } from "./client";
|
||||
import { getDefaultMemoryBlocks } from "./memory";
|
||||
@@ -37,7 +37,7 @@ export async function createAgent(
|
||||
const defaultMemoryBlocks = await getDefaultMemoryBlocks();
|
||||
|
||||
// Load global shared memory blocks from user settings
|
||||
const settings = await loadSettings();
|
||||
const settings = settingsManager.getSettings();
|
||||
const globalSharedBlockIds = settings.globalSharedBlockIds;
|
||||
|
||||
// Load project-local shared blocks from project settings
|
||||
@@ -117,7 +117,7 @@ export async function createAgent(
|
||||
|
||||
// Save newly created global block IDs to user settings
|
||||
if (Object.keys(newGlobalBlockIds).length > 0) {
|
||||
await updateSettings({
|
||||
settingsManager.updateSettings({
|
||||
globalSharedBlockIds: {
|
||||
...globalSharedBlockIds,
|
||||
...newGlobalBlockIds,
|
||||
|
||||
Reference in New Issue
Block a user