Skip to content

Commit

Permalink
Merge pull request elizaOS#915 from second-state/perf/gaianet-config
Browse files Browse the repository at this point in the history
feat: update gaianet config
  • Loading branch information
lalalune authored Dec 8, 2024
2 parents 172ae81 + 9903db8 commit dfe4eff
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 6 deletions.
11 changes: 11 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,18 @@ HEURIST_IMAGE_MODEL=
# Gaianet Configuration
GAIANET_MODEL=
GAIANET_SERVER_URL=

SMALL_GAIANET_MODEL= # Default: llama3b
SMALL_GAIANET_SERVER_URL= # Default: https://llama3b.gaia.domains/v1

MEDIUM_GAIANET_MODEL= # Default: llama
MEDIUM_GAIANET_SERVER_URL= # Default: https://llama8b.gaia.domains/v1

LARGE_GAIANET_MODEL= # Default: qwen72b
LARGE_GAIANET_SERVER_URL= # Default: https://qwen72b.gaia.domains/v1

GAIANET_EMBEDDING_MODEL=
USE_GAIANET_EMBEDDING= # Set to TRUE for GAIANET/768, leave blank for local

# EVM
EVM_PRIVATE_KEY=
Expand Down
7 changes: 5 additions & 2 deletions packages/core/src/embedding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export const getEmbeddingConfig = () => ({
: settings.USE_OLLAMA_EMBEDDING?.toLowerCase() === "true"
? 1024 // Ollama mxbai-embed-large
:settings.USE_GAIANET_EMBEDDING?.toLowerCase() === "true"
? 1536 // GaiaNet
? 768 // GaiaNet
: 384, // BGE
model:
settings.USE_OPENAI_EMBEDDING?.toLowerCase() === "true"
Expand Down Expand Up @@ -196,7 +196,10 @@ export async function embed(runtime: IAgentRuntime, input: string) {
model: config.model,
endpoint:
runtime.character.modelEndpointOverride ||
models[ModelProviderName.GAIANET].endpoint,
models[ModelProviderName.GAIANET].endpoint ||
settings.SMALL_GAIANET_SERVER_URL ||
settings.MEDIUM_GAIANET_SERVER_URL ||
settings.LARGE_GAIANET_SERVER_URL,
apiKey: settings.GAIANET_API_KEY || runtime.token,
dimensions: config.dimensions,
});
Expand Down
18 changes: 18 additions & 0 deletions packages/core/src/generation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,24 @@ export async function generateText({
}
case ModelProviderName.GAIANET: {
elizaLogger.debug("Initializing GAIANET model.");

var baseURL = models[provider].endpoint;
if(!baseURL){
switch(modelClass){
case ModelClass.SMALL:
baseURL = settings.SMALL_GAIANET_SERVER_URL || "https://llama3b.gaia.domains/v1";
break;
case ModelClass.MEDIUM:
baseURL = settings.MEDIUM_GAIANET_SERVER_URL || "https://llama8b.gaia.domains/v1";
break;
case ModelClass.LARGE:
baseURL = settings.LARGE_GAIANET_SERVER_URL || "https://qwen72b.gaia.domains/v1";
break;
}
}

elizaLogger.debug("Using GAIANET model with baseURL:", baseURL);

const openai = createOpenAI({ apiKey, baseURL: endpoint });

const { text: openaiResponse } = await aiGenerateText({
Expand Down
8 changes: 4 additions & 4 deletions packages/core/src/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -341,11 +341,11 @@ export const models: Models = {
repetition_penalty: 0.4,
temperature: 0.7,
},
endpoint: settings.GAIANET_SERVER_URL || "http://localhost:8080/v1",
endpoint: settings.GAIANET_SERVER_URL,
model: {
[ModelClass.SMALL]: settings.GAIANET_MODEL || "llama3.2",
[ModelClass.MEDIUM]: settings.GAIANET_MODEL || "llama3.2",
[ModelClass.LARGE]: settings.GAIANET_MODEL || "llama3.2",
[ModelClass.SMALL]: settings.GAIANET_MODEL || settings.SMALL_GAIANET_MODEL || "llama3b",
[ModelClass.MEDIUM]: settings.GAIANET_MODEL || settings.MEDIUM_GAIANET_MODEL || "llama",
[ModelClass.LARGE]: settings.GAIANET_MODEL || settings.LARGE_GAIANET_MODEL || "qwen72b",
[ModelClass.EMBEDDING]:
settings.GAIANET_EMBEDDING_MODEL || "nomic-embed",
},
Expand Down

0 comments on commit dfe4eff

Please sign in to comment.