-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
move hyp settings for local model invocation to env variables (#495)
- Loading branch information
Showing
4 changed files
with
102 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* Copyright 2024 Hypermode Inc. | ||
* Licensed under the terms of the Apache License, Version 2.0 | ||
* See the LICENSE file that accompanied this code for further details. | ||
* | ||
* SPDX-FileCopyrightText: 2024 Hypermode Inc. <[email protected]> | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import * as path from "node:path"; | ||
import * as fs from "node:fs"; | ||
import * as utils from "./fs.js"; | ||
import chalk from "chalk"; | ||
|
||
function getHypEnvDir(): string { | ||
return path.join(process.env.HOME || "", ".hypermode"); | ||
} | ||
|
||
function getSettingsFilePath(): string { | ||
return path.join(getHypEnvDir(), "settings.json"); | ||
} | ||
|
||
type HypSettings = { | ||
email?: string; | ||
jwt?: string; | ||
orgId?: string; | ||
}; | ||
|
||
export async function readSettingsJson(): Promise<HypSettings> { | ||
const path = getSettingsFilePath(); | ||
const content = await utils.readFile(path, "utf-8"); | ||
|
||
const settings: HypSettings = {}; | ||
|
||
try { | ||
const jsonContent = JSON.parse(content); | ||
settings.email = jsonContent.HYP_EMAIL; | ||
settings.jwt = jsonContent.HYP_JWT; | ||
settings.orgId = jsonContent.HYP_ORG_ID; | ||
} catch (e) { | ||
console.warn(chalk.yellow("Error reading " + path), e); | ||
} | ||
|
||
return settings; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters