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

Add Galadriel LLM Inference Provider #651

Merged
merged 10 commits into from
Nov 29, 2024
3 changes: 3 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -153,3 +153,6 @@ COINBASE_GENERATED_WALLET_HEX_SEED=
# TEE Configuration
DSTACK_SIMULATOR_ENDPOINT=
WALLET_SECRET_SALT=secret_salt

# Galadriel Configuration
GALADRIEL_API_KEY=gal-* # Get from https://dashboard.galadriel.com/
5 changes: 5 additions & 0 deletions agent/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,11 @@ export function getTokenForProvider(
character.settings?.secrets?.GROQ_API_KEY ||
settings.GROQ_API_KEY
);
case ModelProviderName.GALADRIEL:
return (
character.settings?.secrets?.GALADRIEL_API_KEY ||
settings.GALADRIEL_API_KEY
);
}
}

Expand Down
25 changes: 25 additions & 0 deletions packages/core/src/generation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,31 @@ export async function generateText({
break;
}

case ModelProviderName.GALADRIEL: {
elizaLogger.debug("Initializing Galadriel model.");
const galadriel = createOpenAI({
apiKey: apiKey,
baseURL: endpoint,
});

const { text: galadrielResponse } = await aiGenerateText({
model: galadriel.languageModel(model),
prompt: context,
system:
runtime.character.system ??
settings.SYSTEM_PROMPT ??
undefined,
temperature: temperature,
maxTokens: max_response_length,
frequencyPenalty: frequency_penalty,
presencePenalty: presence_penalty,
});

response = galadrielResponse;
elizaLogger.debug("Received response from Galadriel model.");
break;
}

default: {
const errorMessage = `Unsupported provider: ${provider}`;
elizaLogger.error(errorMessage);
Expand Down
17 changes: 17 additions & 0 deletions packages/core/src/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,23 @@ export const models: Models = {
[ModelClass.IMAGE]: "PepeXL",
},
},
[ModelProviderName.GALADRIEL]: {
endpoint: "https://api.galadriel.com/v1",
settings: {
stop: [],
maxInputTokens: 128000,
maxOutputTokens: 8192,
frequency_penalty: 0.5,
presence_penalty: 0.5,
temperature: 0.8,
},
model: {
[ModelClass.SMALL]: "llama3.1:70b",
[ModelClass.MEDIUM]: "llama3.1:70b",
[ModelClass.LARGE]: "llama3.1:405b",
[ModelClass.EMBEDDING]: "gte-large-en-v1.5",
},
},
};

export function getModel(provider: ModelProviderName, type: ModelClass) {
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 @@ -199,6 +199,7 @@ export type Models = {
[ModelProviderName.OPENROUTER]: Model;
[ModelProviderName.OLLAMA]: Model;
[ModelProviderName.HEURIST]: Model;
[ModelProviderName.GALADRIEL]: Model;
};

/**
Expand All @@ -218,6 +219,7 @@ export enum ModelProviderName {
OPENROUTER = "openrouter",
OLLAMA = "ollama",
HEURIST = "heurist",
GALADRIEL = "galadriel"
}

/**
Expand Down
2 changes: 1 addition & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.