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/patterns/ - Custom location specified by
TNH_PATTERN_DIRenvironment variable (note: uses legacy "PATTERN" name for backwards compatibility)
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
- Project-level config:
./.tnh-fab.yaml - User-level config:
~/.config/tnh_scholar/tnh-fab/config.yaml
Example configuration file:
defaults:
language: auto
output_format: txt
punctuate:
pattern: default_punctuate # Config key name retained for compatibility
style: APA
review_count: 3
section:
pattern: default_section # Config key name retained for compatibility
review_count: 3
translate:
pattern: default_line_translation # Config key name retained for compatibility
target_language: en
style: "American Dharma Teaching"
context_lines: 3
review_count: 3
process:
wrap_document: true
patterns: # Config section name retained for compatibility
path: ~/.config/tnh_scholar/patterns
logging:
level: INFO
file: ~/.tnh-fab.log
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-patterns # Skip prompt download
This will:
- Create necessary directories
- Offer to download default prompts
- Check for OpenAI API key
- Set up basic configuration