💡 All-in-one AI framework for semantic search, LLM orchestration and language model workflows
Python agentsaiai-agentsembeddingsinformation-retrievallanguage-modellarge-language-modelsllmnlppythonragretrieval-augmented-generationsearchsearch-enginesemantic-searchsentence-embeddingstransformerstxtaivector-databasevector-search
Add write tool, closes #1061
davidmezzettid2b37580059b
diff --git a/src/python/txtai/agent/tool/write.py b/src/python/txtai/agent/tool/write.pynew file mode 100644index 00000000..6cbc9e8c--- /dev/null+++ b/src/python/txtai/agent/tool/write.py@@ -0,0 +1,42 @@+"""+Write imports+"""++from smolagents import Tool+++class WriteTool(Tool):+ """+ The WriteTool writes file content.+ """++ # pylint: disable=W0231+ def __init__(self):+ """+ Creates a WriteTool.+ """++ # Tool parameters+ self.name = "write"+ self.description = "Implementation of a file write tool. Writes content to file."+ self.inputs = {+ "path": {"type": "string", "description": "Output file path"},+ "content": {"type": "string", "description": "File content to write"},+ }+ self.output_type = "any"++ # Validate parameters and initialize tool+ super().__init__()++ # pylint: disable=W0221+ def forward(self, path, content):+ """+ Writes content to path.++ Args:+ path: output file path+ content: content to write+ """++ with open(path, "w", encoding="utf-8") as f:+ f.write(content)