WordDocumentAgentTools Class
Provides agent tools for core document lifecycle management and file I/O operations. Handles document creation, loading, export, and basic manager.
Inherited Members
Namespace: Syncfusion.AI.AgentTools.Word
Assembly: Syncfusion.DocumentSDK.AI.AgentTools.dll
Syntax
public class WordDocumentAgentTools : AgentToolBase
Constructors
WordDocumentAgentTools(WordDocumentManager, String)
Initializes a new instance of the WordDocumentAgentTools class.
Declaration
public WordDocumentAgentTools(WordDocumentManager manager, string outputDirectory = null)
Parameters
| Type | Name | Description |
|---|---|---|
| WordDocumentManager | manager | The document manager for managing Word documents. |
| System.String | outputDirectory | The default output directory for exporting documents. If null or empty, uses current directory. |
Methods
CreateDocument(String, String)
Creates a new Word document in the manager or loads from file.
Declaration
[Tool(Name = "CreateDocument", Description = "Create or load a Word document in memory. filePath - Use the path to create a WordDocument instance; if it is null, create an empty document. password - If the document is encrypted, provide the password. Returns the documentid of a newly created document.")]
public AgentToolResult CreateDocument([ToolParameter(Description = "Use the path to create a WordDocument instance; if it is null, create an empty document")] string filePath = null, [ToolParameter(Description = "If the document is encrypted, provide the password")] string password = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | filePath | Optional file path to load an existing document. If null, creates an empty document. |
| System.String | password | Optional password if the document is encrypted. |
Returns
| Type | Description |
|---|---|
| AgentToolResult | Result containing the document ID. |
ExportDocument(String, String, String)
Exports the document to the file system in the specified format.
Declaration
[Tool(Name = "ExportDocument", Description = "Exports the document to the file system in the specified format. Supported formats: DOCX, DOC, RTF, HTML, TXT, MD.")]
public AgentToolResult ExportDocument([ToolParameter(Description = "The ID of the document to export")] string documentId, [ToolParameter(Description = "The file name or full path to export to. If only filename is provided, uses the output directory.")] string filePath, [ToolParameter(Description = "The format: Docx, Doc, Rtf, Html, Txt, Md")] string formatType = "Docx")
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | documentId | The ID of the document to be exported. |
| System.String | filePath | The file name or full path where the exported document will be saved |
| System.String | formatType | The export format: 'Docx', 'Doc', 'Rtf', 'Html', 'Md' or 'Txt'. Default is 'Docx'. |
Returns
| Type | Description |
|---|---|
| AgentToolResult | Result indicating whether the export operation succeeded or failed. |
GetAllDocuments()
Returns all document IDs in memory.
Declaration
[Tool(Name = "GetAllDocuments", Description = "Returns all documentid of the Word document instance that are available in main memory.")]
public AgentToolResult GetAllDocuments()
Returns
| Type | Description |
|---|---|
| AgentToolResult | Result containing array of document IDs. |
RemoveDocument(String)
Removes a document from memory.
Declaration
[Tool(Name = "RemoveDocument", Description = "Removes a specific document from memory by ID. Returns true if the document was removed, false otherwise.")]
public AgentToolResult RemoveDocument([ToolParameter(Description = "The ID of the document to remove")] string documentId)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | documentId | The ID of the document to be removed. |
Returns
| Type | Description |
|---|---|
| AgentToolResult | Result indicating whether the document was removed successfully or if it was not found. |
SetActiveDocument(String)
Sets the active document context.
Declaration
[Tool(Name = "SetActiveDocument", Description = "Changes the active document context by ID. The active document is used as the default when no document ID is specified in other operations.")]
public AgentToolResult SetActiveDocument([ToolParameter(Description = "The ID of the document to set as active")] string documentId)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | documentId | The ID of the document to set as active. |
Returns
| Type | Description |
|---|---|
| AgentToolResult | Result indicating whether the active document was set successfully or if it was not found. |