Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add NanoGPT provider #926

Merged
merged 4 commits into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ GOOGLE_GENERATIVE_AI_API_KEY= # Gemini API key

ALI_BAILIAN_API_KEY= # Ali Bailian API Key
VOLENGINE_API_KEY= # VolEngine API Key
NANOGPT_API_KEY= # NanoGPT API Key

HYPERBOLIC_API_KEY= # Hyperbolic API Key
HYPERBOLIC_MODEL=
Expand Down Expand Up @@ -96,6 +97,11 @@ MEDIUM_GROQ_MODEL= # Default: llama-3.3-70b-versatile
LARGE_GROQ_MODEL= # Default: llama-3.2-90b-vision-preview
EMBEDDING_GROQ_MODEL= # Default: llama-3.1-8b-instant

# NanoGPT Configuration
HashWarlock marked this conversation as resolved.
Show resolved Hide resolved
SMALL_NANOGPT_MODEL= # Default: gpt-4o-mini
MEDIUM_NANOGPT_MODEL= # Default: gpt-4o
LARGE_NANOGPT_MODEL= # Default: gpt-4o

#LlamaLocal Configuration
LLAMALOCAL_PATH= # Default: "" which is the current directory in plugin-node/dist/ which gets destroyed and recreated on every build

Expand Down
5 changes: 5 additions & 0 deletions agent/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,11 @@ export function getTokenForProvider(
character.settings?.secrets?.VOLENGINE_API_KEY ||
settings.VOLENGINE_API_KEY
);
case ModelProviderName.NANOGPT:
return (
character.settings?.secrets?.NANOGPT_API_KEY ||
settings.NANOGPT_API_KEY
);
case ModelProviderName.HYPERBOLIC:
return (
character.settings?.secrets?.HYPERBOLIC_API_KEY ||
Expand Down
2 changes: 2 additions & 0 deletions packages/core/src/generation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ export async function generateText({
case ModelProviderName.ALI_BAILIAN:
case ModelProviderName.VOLENGINE:
case ModelProviderName.LLAMACLOUD:
case ModelProviderName.NANOGPT:
case ModelProviderName.HYPERBOLIC:
case ModelProviderName.TOGETHER: {
elizaLogger.debug("Initializing OpenAI model.");
Expand Down Expand Up @@ -1215,6 +1216,7 @@ export async function handleProvider(
case ModelProviderName.VOLENGINE:
case ModelProviderName.LLAMACLOUD:
case ModelProviderName.TOGETHER:
case ModelProviderName.NANOGPT:
return await handleOpenAI(options);
case ModelProviderName.ANTHROPIC:
return await handleAnthropic(options);
Expand Down
16 changes: 16 additions & 0 deletions packages/core/src/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,22 @@ export const models: Models = {
[ModelClass.EMBEDDING]: "doubao-embedding",
},
},
[ModelProviderName.NANOGPT]: {
endpoint: "https://nano-gpt.com/api/v1",
settings: {
stop: [],
maxInputTokens: 128000,
maxOutputTokens: 8192,
frequency_penalty: 0.0,
presence_penalty: 0.0,
temperature: 0.6,
},
model: {
[ModelClass.SMALL]: settings.SMALL_NANOGPT_MODEL || "gpt-4o-mini",
[ModelClass.MEDIUM]: settings.MEDIUM_NANOGPT_MODEL || "gpt-4o",
[ModelClass.LARGE]: settings.LARGE_NANOGPT_MODEL || "gpt-4o",
}
},
[ModelProviderName.HYPERBOLIC]: {
endpoint: "https://api.hyperbolic.xyz/v1",
settings: {
Expand Down
2 changes: 2 additions & 0 deletions packages/core/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ export type Models = {
[ModelProviderName.GAIANET]: Model;
[ModelProviderName.ALI_BAILIAN]: Model;
[ModelProviderName.VOLENGINE]: Model;
[ModelProviderName.NANOGPT]: Model;
[ModelProviderName.HYPERBOLIC]: Model;
};

Expand All @@ -231,6 +232,7 @@ export enum ModelProviderName {
GAIANET = "gaianet",
ALI_BAILIAN = "ali_bailian",
VOLENGINE = "volengine",
NANOGPT = "nanogpt",
HYPERBOLIC = "hyperbolic",
}

Expand Down
Loading