Skip to content

Commit

Permalink
Merge pull request elizaOS#926 from dylan1951/add-nano-gpt-provider
Browse files Browse the repository at this point in the history
feat: Add NanoGPT provider
  • Loading branch information
odilitime authored Dec 11, 2024
2 parents a882883 + e9a9699 commit 3afd61c
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 0 deletions.
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
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 @@ -151,6 +151,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 @@ -1243,6 +1244,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

0 comments on commit 3afd61c

Please sign in to comment.