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:
- Default location:
~/.config/tnh_scholar/prompts/ - Custom location specified by
TNH_PROMPT_DIRenvironment variable
To use a custom prompt directory:
Default Prompts¶
The system includes several default prompts:
- default_punctuate.md
- default_section.md
- default_line_translation.md
- default_xml_format.md
- default_xml_paragraph_format.md
These can be downloaded during setup or manually added later.
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.10,
"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 download
This will:
- Create necessary directories
- Offer to download default prompts
- Check for OpenAI API key
- Set up basic configuration