Skip to main content
Glama

prem_chat_with_template

Generate chat responses using predefined Prem AI prompt templates by providing template IDs and parameter values for consistent AI interactions.

Instructions

Chat using a predefined Prem AI prompt template

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
template_idYesID of the prompt template to use
paramsYesParameters to fill in the template
modelNoOptional model to use
temperatureNoOptional temperature parameter
max_tokensNoOptional maximum tokens to generate

Implementation Reference

  • src/index.ts:186-234 (registration)
    Registration of the 'prem_chat_with_template' tool, including schema and inline handler function.
    this.server.tool(
      "prem_chat_with_template",
      "Chat using a predefined Prem AI prompt template",
      {
        template_id: z.string().describe("ID of the prompt template to use"),
        params: z.record(z.string()).describe("Parameters to fill in the template"),
        model: z.string().optional().describe("Optional model to use"),
        temperature: z.number().optional().describe("Optional temperature parameter"),
        max_tokens: z.number().optional().describe("Optional maximum tokens to generate")
      },
      async ({ template_id, params, model, temperature, max_tokens }) => {
        const requestId = `template-${Date.now()}-${Math.random().toString(36).substring(2, 7)}`;
        this.activeRequests.add(requestId);
        
        try {
          const chatRequest = {
            project_id: PROJECT_ID as string,
            messages: [{
              role: "user",
              template_id,
              params
            }],
            ...(model && { model }),
            ...(temperature && { temperature }),
            ...(max_tokens && { max_tokens })
          };
    
          const response = await this.client.chat.completions.create(chatRequest as any);
          const responseData = 'choices' in response ? response : { choices: [] };
    
          return {
            content: [{
              type: "text" as const,
              text: JSON.stringify(responseData, null, 2)
            }]
          };
        } catch (error) {
          return {
            content: [{
              type: "text" as const,
              text: `Template chat error: ${error instanceof Error ? error.message : String(error)}`
            }],
            isError: true
          };
        } finally {
          this.activeRequests.delete(requestId);
        }
      }
    );
  • Handler function for 'prem_chat_with_template' that constructs a chat request using the provided template_id and params, calls Prem AI's chat.completions.create, and returns the response.
    async ({ template_id, params, model, temperature, max_tokens }) => {
      const requestId = `template-${Date.now()}-${Math.random().toString(36).substring(2, 7)}`;
      this.activeRequests.add(requestId);
      
      try {
        const chatRequest = {
          project_id: PROJECT_ID as string,
          messages: [{
            role: "user",
            template_id,
            params
          }],
          ...(model && { model }),
          ...(temperature && { temperature }),
          ...(max_tokens && { max_tokens })
        };
    
        const response = await this.client.chat.completions.create(chatRequest as any);
        const responseData = 'choices' in response ? response : { choices: [] };
    
        return {
          content: [{
            type: "text" as const,
            text: JSON.stringify(responseData, null, 2)
          }]
        };
      } catch (error) {
        return {
          content: [{
            type: "text" as const,
            text: `Template chat error: ${error instanceof Error ? error.message : String(error)}`
          }],
          isError: true
        };
      } finally {
        this.activeRequests.delete(requestId);
      }
    }
  • Zod schema defining the input parameters for the 'prem_chat_with_template' tool.
    {
      template_id: z.string().describe("ID of the prompt template to use"),
      params: z.record(z.string()).describe("Parameters to fill in the template"),
      model: z.string().optional().describe("Optional model to use"),
      temperature: z.number().optional().describe("Optional temperature parameter"),
      max_tokens: z.number().optional().describe("Optional maximum tokens to generate")
    },
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the action ('Chat') but lacks details on permissions, rate limits, response format, or potential side effects. For a tool with multiple parameters and no annotation coverage, this is a significant gap in transparency.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that directly states the tool's purpose without unnecessary words. It's front-loaded and appropriately sized, making it easy for an agent to parse quickly.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (5 parameters, nested objects, no output schema) and lack of annotations, the description is incomplete. It doesn't explain return values, error conditions, or behavioral nuances, leaving the agent with insufficient context for effective use.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema fully documents all parameters. The description adds no additional meaning beyond implying template-based chat, which is already covered by the schema's parameter descriptions. This meets the baseline for high schema coverage without extra value.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb ('Chat') and resource ('using a predefined Prem AI prompt template'), making the purpose understandable. However, it doesn't explicitly differentiate from sibling tools like 'chat' or 'prem_upload_document', which would require more specific language about template-based versus direct chat functionality.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention sibling tools like 'chat' or 'prem_upload_document', nor does it specify prerequisites such as needing a pre-existing template or appropriate parameters. This leaves the agent without clear usage context.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/ucalyptus/prem-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server