Skip to main content
Glama

fill_mask

Complete text with missing words using AI. This tool predicts and fills masked tokens in sentences to generate coherent text.

Instructions

Fill masked tokens in text using DeepInfra OpenAI-compatible API.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
textYes

Implementation Reference

  • The handler function that implements the fill_mask tool logic. It constructs a prompt to fill in masked text using the completions API with a specified model and returns the generated response.
    async def fill_mask(text: str) -> str: """Fill masked tokens in text using DeepInfra OpenAI-compatible API.""" model = DEFAULT_MODELS["fill_mask"] prompt = f"""Fill in the [MASK] token in the following text with the most appropriate word. Provide the completed sentence and explain your choice. Text: {text} Response format: {{"filled_text": "completed sentence", "chosen_word": "word", "explanation": "reasoning"}}""" try: response = await client.completions.create( model=model, prompt=prompt, max_tokens=200, temperature=0.1, ) if response.choices: return response.choices[0].text else: return "Unable to fill mask" except Exception as e: return f"Error filling mask: {type(e).__name__}: {str(e)}"
  • Conditional block that registers the fill_mask tool with the FastMCP server using the @app.tool() decorator if enabled via ENABLED_TOOLS.
    if "all" in ENABLED_TOOLS or "fill_mask" in ENABLED_TOOLS: @app.tool()
  • Configuration for the default model used by the fill_mask tool.
    "fill_mask": os.getenv("MODEL_FILL_MASK", "microsoft/DialoGPT-medium"),

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/phuihock/mcp-deeinfra'

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