Configuration¶
TNH Scholar requires some initial configuration to function properly. This guide covers the essential configuration steps and options.
Environment Setup¶
OpenAI API Key¶
TNH Scholar's AI functionality requires an OpenAI API key. To configure this:
- Obtain an API key from OpenAI's platform
- Set the environment variable:
# Linux/Mac
export OPENAI_API_KEY='your-api-key-here'
# Windows
set OPENAI_API_KEY=your-api-key-here
In development configuration (where you have downloaded the tnh-scholar repository) you can also use a .env file in your project directory:
Directory Structure¶
TNH Scholar creates and uses the following directory structure:
Prompt Configuration¶
Prompt Directory¶
Prompts can be stored in:
- Repo-local default workspace:
./tnh-prompts/when running from thetnh-scholarrepo root - User override location:
~/.config/tnh-scholar/prompts/ - Custom location specified by
TNH_PROMPT_DIRenvironment variable
To use a custom prompt directory:
Default Prompts¶
The current prototype workflow uses the tracked repo-local tnh-prompts/ workspace.
Bundled runtime prompts remain available in src/tnh_scholar/runtime_assets/prompts/,
and ~/.config/tnh-scholar/prompts/ can be used for local overrides.
Configuration File¶
The system looks for configuration in this order:
- Command line arguments
- Environment variables
- Workspace config:
./.tnh-gen.json(or.vscode/tnh-scholar.json) - User-level config:
~/.config/tnh-scholar/tnh-gen.json
Example configuration file:
{
"prompt_catalog_dir": "/path/to/prompts",
"default_model": "gpt-5-mini",
"max_dollars": 0.30,
"max_input_chars": 120000,
"default_temperature": 1.0,
"api_key": "sk-..."
}
Initial Setup¶
The tnh-setup command automates configuration:
# Full setup
tnh-setup
# Skip specific steps
tnh-setup --skip-env # Skip API key check
tnh-setup --skip-prompts # Skip prompt setup guidance
This will:
- Create necessary directories
- Prepare the user prompt directory and report prompt locations
- Check for OpenAI API key
- Set up basic configuration