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
| Name | Required | Description | Default |
|---|---|---|---|
| text | Yes |
Implementation Reference
- src/mcp_deepinfra/server.py:266-286 (handler)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)}"
- src/mcp_deepinfra/server.py:264-265 (registration)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()
- src/mcp_deepinfra/server.py:41-41 (helper)Configuration for the default model used by the fill_mask tool."fill_mask": os.getenv("MODEL_FILL_MASK", "microsoft/DialoGPT-medium"),