embeddings
Generate vector embeddings for text inputs to enable semantic search, similarity analysis, and machine learning applications using DeepInfra's AI models.
Instructions
Generate embeddings for a list of texts using DeepInfra OpenAI-compatible API.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| inputs | Yes | ||
| model | No |
Implementation Reference
- src/mcp_deepinfra/server.py:84-96 (handler)Handler function for the embeddings tool. It is decorated with @app.tool() for registration in FastMCP and generates embeddings via DeepInfra's OpenAI client.@app.tool() async def embeddings(inputs: list[str]) -> str: """Generate embeddings for a list of texts using DeepInfra OpenAI-compatible API.""" model = DEFAULT_MODELS["embeddings"] try: response = await client.embeddings.create( model=model, input=inputs, ) embeddings_list = [item.embedding for item in response.data] return str(embeddings_list) except Exception as e: return f"Error generating embeddings: {type(e).__name__}: {str(e)}"
- src/mcp_deepinfra/server.py:83-83 (registration)Conditional check to enable and register the embeddings tool based on ENABLED_TOOLS configuration.if "all" in ENABLED_TOOLS or "embeddings" in ENABLED_TOOLS:
- src/mcp_deepinfra/server.py:31-42 (helper)Helper configuration dictionary defining default models for all tools, including the embeddings model.DEFAULT_MODELS = { "generate_image": os.getenv("MODEL_GENERATE_IMAGE", "Bria/Bria-3.2"), "text_generation": os.getenv("MODEL_TEXT_GENERATION", "meta-llama/Llama-2-7b-chat-hf"), "embeddings": os.getenv("MODEL_EMBEDDINGS", "sentence-transformers/all-MiniLM-L6-v2"), "speech_recognition": os.getenv("MODEL_SPEECH_RECOGNITION", "openai/whisper-large-v3"), "zero_shot_image_classification": os.getenv("MODEL_ZERO_SHOT_IMAGE_CLASSIFICATION", "openai/gpt-4o-mini"), "object_detection": os.getenv("MODEL_OBJECT_DETECTION", "openai/gpt-4o-mini"), "image_classification": os.getenv("MODEL_IMAGE_CLASSIFICATION", "openai/gpt-4o-mini"), "text_classification": os.getenv("MODEL_TEXT_CLASSIFICATION", "microsoft/DialoGPT-medium"), "token_classification": os.getenv("MODEL_TOKEN_CLASSIFICATION", "microsoft/DialoGPT-medium"), "fill_mask": os.getenv("MODEL_FILL_MASK", "microsoft/DialoGPT-medium"), }
- src/mcp_deepinfra/server.py:85-85 (schema)Function signature providing the input schema (list[str]) and output type (str) for the embeddings tool.async def embeddings(inputs: list[str]) -> str: