theoforger / mastermind

An LLM-powered CLI tool to help you be a better spymaster in Codenames
GNU General Public License v3.0
3 stars 2 forks source link

Improve Error Message for Missing or Invalid .env Configuration #1

Closed mayank-Pareek closed 2 weeks ago

mayank-Pareek commented 2 weeks ago

Description:

When running the tool with an invalid or missing API key, base URL, or model ID in the .env file, the error message is unclear and doesn’t point to the root cause. Instead of indicating an issue with the configuration, the error suggests a decoding problem:

Error: reqwest::Error { kind: Decode, source: Error("missing field `choices`", line: 1, column: 95) }
error: process didn't exit successfully: `target\debug\mastermind.exe examples/avoid examples/link` (exit code: 1)

Screenshot:

image

Steps to Reproduce:

  1. Set up the .env file with either:

    • A wrong or missing API_KEY
    • A wrong or missing OPENAI_API_BASE_URL
    • A wrong or missing DEFAULT_MODEL_ID
  2. Run the following command:

    cargo run -- examples/avoid examples/link

    Expected Behavior:

    The error message should be more descriptive, indicating which specific configuration is missing or invalid. For example:

    Error: Invalid or missing API key for the Groq API. Please check your .env file and provide a valid key.

    Actual Behavior:

    The current error is related to missing fields (choices) and does not inform the user that the issue is due to an invalid or missing configuration.

Environment: