Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/configs/constant.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ const new_agent_service = {
mistral: "mistral-small-latest",
gemini: "gemini-2.5-pro",
ai_ml: "gpt-oss-120b",
grok: "grok-4-fast"
grok: "grok-4-fast",
deepgram: "nova-3"
};

export { collectionNames, bridge_ids, redis_keys, cost_types, prebuilt_prompt_bridge_id, new_agent_service };
Expand Down
6 changes: 5 additions & 1 deletion src/controllers/apikey.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import {
callMistralApi,
callGeminiApi,
callAiMlApi,
callGrokApi
callGrokApi,
callDeepgramApi
} from "../services/utils/aiServices.js";
import { redis_keys, cost_types, new_agent_service } from "../configs/constant.js";
import { cleanupCache } from "../services/utils/redis.utils.js";
Expand Down Expand Up @@ -245,6 +246,9 @@ const checkApikey = async (apikey, service) => {
case "grok":
check = await callGrokApi(apikey);
break;
case "deepgram":
check = await callDeepgramApi(apikey);
break;
default:
const error = new Error("Invalid service provided");
error.statusCode = 400;
Expand Down
32 changes: 31 additions & 1 deletion src/services/utils/aiServices.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,4 +195,34 @@ async function callGrokApi(apiKey) {
}
}

export { callOpenAIModelsApi, callAnthropicApi, callGroqApi, callOpenRouterApi, callMistralApi, callGeminiApi, callAiMlApi, callGrokApi };
async function callDeepgramApi(apiKey) {
Comment thread
harshhsahu marked this conversation as resolved.
try {
const response = await fetch("https://api.deepgram.com/v1/projects", {
method: "GET",
headers: {
Authorization: `Token ${apiKey}`
}
});

if (!response.ok) {
throw new Error(`HTTP error! Status: ${response.status}`);
}

const data = await response.json();
return { success: true, data };
Comment thread
adityajunwal marked this conversation as resolved.
} catch (error) {
return { success: false, error: error.message };
}
}

export {
callOpenAIModelsApi,
callAnthropicApi,
callGroqApi,
callOpenRouterApi,
callMistralApi,
callGeminiApi,
callAiMlApi,
callGrokApi,
callDeepgramApi
};
3 changes: 2 additions & 1 deletion src/services/utils/getDefaultValue.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ const service_name = {
mistral: "mistral",
gemini: "gemini",
ai_ml: "ai_ml",
openai_completion: "openai_completion"
openai_completion: "openai_completion",
deepgram: "deepgram"
};

const validateFallBack = (fall_back_data) => {
Expand Down
52 changes: 51 additions & 1 deletion src/services/utils/modelValidation.utils.js
Comment thread
adityajunwal marked this conversation as resolved.
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,46 @@ async function validateOpenAIModel(modelName) {
}
}

/**
* Validates if a model is supported by Deepgram
* @param {string} modelName - The model name to validate
* @returns {Promise<boolean>} - True if model is supported, false otherwise
*/
async function validateDeepgramModel(modelName) {
try {
const apiKey = process.env.DEEPGRAM_API_KEY;

if (!apiKey) {
console.error("Missing DEEPGRAM_API_KEY for Deepgram model validation");
return false;
}

const response = await axios.get("https://api.deepgram.com/v1/models", {
headers: {
Authorization: `Token ${apiKey}`
}
});

if (response.status !== 200) {
console.error("Failed to fetch models from Deepgram:", response.status);
return false;
}

const sttModels = response.data?.stt || [];
const normalizedModelName = modelName.toLowerCase();

return sttModels.some((model) => {
const architecture = model.architecture?.toLowerCase();
const canonicalName = model.canonical_name?.toLowerCase();
const name = model.name?.toLowerCase();
return architecture === normalizedModelName || canonicalName === normalizedModelName || name === normalizedModelName;
});
} catch (error) {
console.error("Error validating Deepgram model:", error.message);
return false;
}
}

/**
* Validates if a model is supported by a specific service
* @param {string} service - The service name (e.g., 'open_router', 'anthropic', 'openai')
Expand All @@ -172,10 +212,20 @@ async function validateModel(service, modelName) {
return await validateGroqModel(modelName);
case "mistral":
return await validateMistralModel(modelName);
case "deepgram":
return await validateDeepgramModel(modelName);
default:
console.warn(`No validation method available for service: ${service}`);
return true; // Default to true for services without validation
}
}

export { validateModel, validateOpenRouterModel, validateAnthropicModel, validateOpenAIModel, validateGroqModel, validateMistralModel };
export {
validateModel,
validateOpenRouterModel,
validateAnthropicModel,
validateOpenAIModel,
validateGroqModel,
validateMistralModel,
validateDeepgramModel
};
2 changes: 1 addition & 1 deletion src/validation/joi_validation/agentConfig.validation.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ const updateBridgeSchema = Joi.object({
})
.unknown(true)
.optional(),
service: Joi.string().valid("openai", "anthropic", "groq", "open_router", "mistral", "gemini", "ai_ml", "grok").optional(),
service: Joi.string().valid("openai", "anthropic", "groq", "open_router", "mistral", "gemini", "ai_ml", "grok", "deepgram").optional(),
apikey_object_id: Joi.object()
.pattern(Joi.string(), Joi.string().pattern(/^[0-9a-fA-F]{24}$/))
.optional(),
Expand Down
4 changes: 2 additions & 2 deletions src/validation/joi_validation/apikey.validation.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const saveApikey = {
.keys({
name: Joi.string().required(),
apikey: Joi.string().required(),
service: Joi.string().valid("openai", "gemini", "anthropic", "groq", "open_router", "mistral", "ai_ml", "grok").required(),
service: Joi.string().valid("openai", "gemini", "anthropic", "groq", "open_router", "mistral", "ai_ml", "grok", "deepgram").required(),
apikey_limit: Joi.number().min(0).precision(6).optional(),
apikey_usage: Joi.number().min(0).precision(6).optional(),
apikey_limit_reset_period: Joi.string().valid("monthly", "weekly", "daily").optional(),
Expand Down Expand Up @@ -34,7 +34,7 @@ const updateApikey = {
.keys({
name: Joi.string().optional(),
apikey: Joi.string().optional(),
service: Joi.string().valid("openai", "gemini", "anthropic", "groq", "open_router", "mistral", "ai_ml", "grok").optional(),
service: Joi.string().valid("openai", "gemini", "anthropic", "groq", "open_router", "mistral", "ai_ml", "grok", "deepgram").optional(),
apikey_limit: Joi.number().min(0).precision(6).optional(),
apikey_usage: Joi.number().min(0).precision(6).optional(),
apikey_limit_reset_period: Joi.string().valid("monthly", "weekly", "daily").optional(),
Expand Down
15 changes: 9 additions & 6 deletions src/validation/joi_validation/modelConfig.validation.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Joi from "joi";

const modelConfigSchema = Joi.object({
service: Joi.string().valid("openai", "openai_response", "gemini", "anthropic", "groq", "open_router", "mistral", "ai_ml").optional(),
service: Joi.string().valid("openai", "openai_response", "gemini", "anthropic", "groq", "open_router", "mistral", "ai_ml", "deepgram").optional(),
model_name: Joi.string()
.pattern(/^[^\s]+$/)
.message("model_name must not contain spaces")
Expand All @@ -13,7 +13,7 @@ const modelConfigSchema = Joi.object({
}).unknown(true);

const saveUserModelConfigurationBodySchema = Joi.object({
service: Joi.string().valid("openai", "openai_response", "gemini", "anthropic", "groq", "open_router", "mistral", "ai_ml").required(),
service: Joi.string().valid("openai", "openai_response", "gemini", "anthropic", "groq", "open_router", "mistral", "ai_ml", "deepgram").required(),
model_name: Joi.string()
.pattern(/^[^\s]+$/)
.message("model_name must not contain spaces")
Expand All @@ -29,15 +29,18 @@ const deleteUserModelConfigurationQuerySchema = Joi.object({
model_name: Joi.string().required().messages({
"any.required": "model_name is required"
}),
service: Joi.string().valid("openai", "openai_response", "gemini", "anthropic", "groq", "open_router", "mistral", "ai_ml").required().messages({
"any.required": "service is required"
})
service: Joi.string()
.valid("openai", "openai_response", "gemini", "anthropic", "groq", "open_router", "mistral", "ai_ml", "deepgram")
.required()
.messages({
"any.required": "service is required"
})
}).unknown(true);

// Legacy schema for backward compatibility
const UserModelConfigSchema = Joi.object({
org_id: Joi.string().required(),
service: Joi.string().valid("openai", "openai_response", "gemini", "anthropic", "groq", "open_router", "mistral", "ai_ml").required(),
service: Joi.string().valid("openai", "openai_response", "gemini", "anthropic", "groq", "open_router", "mistral", "ai_ml", "deepgram").required(),
model_name: Joi.string()
.pattern(/^[^\s]+$/)
.message("model_name must not contain spaces")
Expand Down