Skip to main content
This guide provides an overview for getting started with WRITER tools. For detailed documentation of all WRITER features and configurations, head to the WRITER docs.

Overview

Integration details

Features

ChatWriter supports several tool types: function, graph, translation, and web_search.
Important limitation: You can only use one WRITER tool (translation, graph, web_search, llm, image, vision) at a time. While you can’t combine multiple WRITER tools, you can use one WRITER tool alongside multiple custom function tools.

Function

Functions are the most common type of tool, which allows the LLM to call external APIs, fetch data from databases, and generally perform any external action you want to do. Visit WRITER’s tool calling docs for additional information.

Graph

The Graph tool uses WRITER’s Knowledge Graph, which is a graph-based retrieval-augmented generation (RAG) system. When using this tool, developers provide a graph ID that references their specific Knowledge Graph. The model then uses this graph to find relevant information and generate accurate answers to questions in the prompt. This allows the model to access and utilize custom knowledge bases during conversations. For more details, see WRITER’s Knowledge Graph API docs.

Translation

The translation tool allows you to translate text during a conversation with a Palmyra model. While Palmyra X models can perform translation tasks, they are not optimized for these tasks and may not perform well without correct prompting. See WRITER’s translation API docs for more information. The web search tool allows you to search the web for current information during a conversation with a Palmyra model. While Palmyra models have extensive knowledge, they may not have access to the most current information or real-time data. The web search tool enables your AI assistant to find up-to-date information, news, and facts from the web. See WRITER’s web search API docs for more information.

Setup

Sign up for WRITER AI Studio to generate an API key (you can follow this Quickstart). Then, set the WRITER_API_KEY environment variable:

Usage

You can bind graph or function tools to ChatWriter.

Graph Tools

To bind graph tools, first create and initialize a GraphTool instance with the graph_ids you want to use as sources:

Translation Tools

The translation tool allows you to translate text during a conversation with a Palmyra model. While Palmyra X models can perform translation tasks, they are not optimized for these tasks and may not perform well without correct prompting. To use the translation tool, import and initialize the built-in TranslationTool:

Web Search Tools

The web search tool allows you to search the web for current information during a conversation with a Palmyra model. While Palmyra models have extensive knowledge, they may not have access to the most current information or real-time data. The web search tool enables your AI assistant to find up-to-date information, news, and facts from the web. To use the web search tool, import and initialize the built-in WebSearchTool:

Instantiation

Binding tools

Important note: WRITER only allows a single WRITER tool (translation, graph, web_search, llm, image, vision) to be bound at a time. You cannot bind multiple WRITER tools simultaneously. However, you can bind multiple custom function tools along with one WRITER tool.
If you need to use different WRITER tools, you have several options: Option 1: Rebind tools for each conversation:
Option 2: Use separate ChatWriter instances:

Invocation

The model will automatically choose the tool during invocation with all modes (streaming/non-streaming, sync/async).
In the case of function tools, you will receive an assistant message with the tool call request.
Then you can manually handle tool call request, send to model and receive final response:
With a GraphTool, the model will call it remotely and return usage info in the additional_kwargs under the graph_data key:
The content attribute contains the final response:

Chaining

The WRITER Graph tool works differently from other tools; when used, the WRITER server automatically handles calling the Knowledge Graph and generating responses using RAG. Because of this automated server-side handling, you cannot invoke the GraphTool independently or use it as part of a LangChain chain. You must use the GraphTool directly with a ChatWriter instance as shown in the examples above.

API reference

For detailed documentation of all GraphTool features and configurations, head to the API reference.