Home Assistant Integration with File #79
Open
+746
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issue: #72
Changes Overview
🔧 Core SDK Enhancement
File:
src/xai_sdk/tools.py(+25 lines)attachment_search()function - New server-side tool for searching uploaded file attachmentslimit(optional) - Maximum number of search results to return📝 New Examples
Files:
examples/aio/home_assistant_integration.py(+361 lines)examples/sync/home_assistant_integration.py(+360 lines)Key Features Implemented
🏠 Home Assistant Integration
attachment_searchtool to query device information🛠️ SDK Limitation Workarounds
system(file())limitation🐛 Error Handling & Debugging
Technical Implementation
File Structure
Key Functions
attachment_search(limit=None)- Creates attachment search toolupload_context_files()- Handles file upload and cleanuphandle_home_assistant_query()- Processes queries with file attachmentsdemo_attachment_search()- Demonstrates search functionalitySample Usage
Problem Resolution
Original Issues Addressed
system(file())- Workaround using user message file attachmentstools = file()- Proper tool parameter usage with attachment_searchTesting & Validation
Impact & Benefits