Skip to content

Commit

Permalink
Release 2.0.5-beta
Browse files Browse the repository at this point in the history
  • Loading branch information
SMKRV committed Dec 3, 2024
1 parent 5709bce commit f397bbf
Show file tree
Hide file tree
Showing 12 changed files with 1,116 additions and 573 deletions.
34 changes: 30 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ Transform your smart home experience with powerful AI assistance powered by mult
- Natural conversation flow

- 📝 **Enhanced Memory Management**:
- Persistent conversation history
- Context-aware responses
- Customizable history limits
- Model-specific filtering
- File-based conversation history storage
- Automatic history rotation
- Configurable history size limits
- Secure storage in Home Assistant

-**Performance Optimization**:
- Efficient token usage
Expand Down Expand Up @@ -188,6 +188,8 @@ sensor:
| `request_interval` | Float | ❌ | 1.0 | Delay between API requests |
| `api_endpoint` | URL | ⚠️ | Provider default | Custom API endpoint |
| `system_prompt` | String | ❌ | - | Default context for AI interactions |
| `max_history_size` | Integer | ❌ | 100 | Maximum number of conversation entries to store |
| `history_file_size` | Integer | ⚠️ | 1 | Maximum history file size in MB |

#### Sensor Configuration

Expand Down Expand Up @@ -344,6 +346,13 @@ automation:
# Tokens used in the AI's generated responses
{{ state_attr('sensor.ha_text_ai_gpt', 'Completion tokens') }} # 0
# Number of entries in current history file
{{ state_attr('sensor.ha_text_ai_gpt', 'History size') }} # 0
# Last few conversation entries (limited to 3 for performance)
{{ state_attr('sensor.ha_text_ai_gpt', 'conversation_history') }} # [...]
```

#### Last Interaction Details
Expand All @@ -370,6 +379,13 @@ automation:
{{ state_attr('sensor.ha_text_ai_gpt', 'Uptime') }} # 547,58
```

### History Storage
Conversation history stored in `.storage/ha_text_ai_history/` directory:
- Each instance has its own history file
- Files are automatically rotated when size limit is reached
- Archived history files are timestamped
- Default maximum file size: 1MB

### 💡 Pro Tips
- Always check attribute existence
- Use these attributes for monitoring and automation
Expand Down Expand Up @@ -402,6 +418,16 @@ A: Yes, your data is secure. The system operates entirely on your local machine,
**Q: How do context messages work?**
A: Context messages allow the AI to remember and reference previous conversation history. By default, 5 previous messages are included, but you can customize this from 1 to 20 messages to control the conversation depth and token usage.

**Q: Where is conversation history stored?**
A: History is stored in files under the `.storage/ha_text_ai_history/` directory, with automatic rotation and size management.

**Q: Can I access old conversation history?**
A: Yes, archived history files are stored with timestamps and can be accessed manually if needed.

**Q: How much history is kept?**
A: By default, up to 100 conversations are stored, but this can be configured. Files are automatically rotated when they reach 1MB.


## 🤝 Contributing

Contributions welcome! Please read our [Contributing Guide](CONTRIBUTING.md).
Expand Down
3 changes: 3 additions & 0 deletions custom_components/ha_text_ai/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@
CONF_IS_ANTHROPIC: Final = "is_anthropic"
CONF_CONTEXT_MESSAGES: Final = "context_messages"

ABSOLUTE_MAX_HISTORY_SIZE = 500
MAX_ENTRY_SIZE = 1 * 1024 * 1024

# Default values
DEFAULT_MODEL: Final = "gpt-4o-mini"
DEFAULT_TEMPERATURE: Final = 0.1
Expand Down
Loading

0 comments on commit f397bbf

Please sign in to comment.