Open
Conversation
- Add attachment_search() function to tools.py for server-side file search - Create comprehensive Home Assistant examples (sync and async versions) - Implement file-based context management with error handling - Add debugging capabilities for tool calls and responses - Demonstrate workarounds for SDK limitations (file usage in messages) - Include sample device data and interactive query interface
| ``` | ||
| """ | ||
| return chat_pb2.Tool( | ||
| attachment_search=chat_pb2.AttachmentSearch(limit=limit) if limit is not None else chat_pb2.AttachmentSearch() |
There was a problem hiding this comment.
You don't need the conditional here
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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