这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

@timothycarambat
Copy link
Member

resolves #364

@review-agent-prime
Copy link

server/utils/AiProviders/anthropic/index.js, server/utils/AiProviders/openAi/index.js

It's a good practice to set a default model for the AI providers in case the environment variable is not set. This will prevent the application from crashing due to an undefined model. However, it would be better to move the default model to a constant at the top of the file for better readability and maintainability.
Create Issue

    const DEFAULT_ANTHROPIC_MODEL = "claude-2";
    const DEFAULT_OPENAI_MODEL = "gpt-3.5-turbo";

    // Then use these constants when setting the model
    this.model = process.env.ANTHROPIC_MODEL_PREF || DEFAULT_ANTHROPIC_MODEL;
    this.model = process.env.OPEN_MODEL_PREF || DEFAULT_OPENAI_MODEL;

server/utils/AiProviders/openAi/index.js

It's a good practice to use the class property this.model instead of the environment variable process.env.OPEN_MODEL_PREF when checking if the model is valid. This is because the class property this.model has already been set with the environment variable or the default model. This makes the code more readable and less error-prone.
Create Issue

    if (!(await this.isValidChatCompletionModel(this.model)))

@timothycarambat timothycarambat merged commit 8743be6 into master Nov 13, 2023
@timothycarambat timothycarambat deleted the 364-model-assumption-fix branch November 13, 2023 23:17
cabwds pushed a commit to cabwds/anything-llm that referenced this pull request Jul 3, 2025
* assume default model where appropriate

* merge with master and fix other model refs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

OpenAI - Model undefined on onboarding complete

2 participants