var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
    return function (target, key) { decorator(target, key, paramIndex); }
};
import { Resolver, Mutation, Query, Arg, Ctx, ObjectType, Field, Int } from 'type-graphql';
import { LogError, LogStatus } from '@memberjunction/core';
import { AIPromptRunner } from '@memberjunction/ai-prompts';
import { AIPromptParams } from '@memberjunction/ai-core-plus';
import { ResolverBase } from '../generic/ResolverBase.js';
import { RequireSystemUser } from '../directives/RequireSystemUser.js';
import { AIEngine } from '@memberjunction/aiengine';
import { ChatParams, ChatMessageRole, GetAIAPIKey, BaseLLM } from '@memberjunction/ai';
import { MJGlobal } from '@memberjunction/global';
import { GetReadWriteProvider } from '../util.js';
let AIPromptRunResult = class AIPromptRunResult {
};
__decorate([
    Field(),
    __metadata("design:type", Boolean)
], AIPromptRunResult.prototype, "success", void 0);
__decorate([
    Field({ nullable: true }),
    __metadata("design:type", String)
], AIPromptRunResult.prototype, "output", void 0);
__decorate([
    Field({ nullable: true }),
    __metadata("design:type", String)
], AIPromptRunResult.prototype, "parsedResult", void 0);
__decorate([
    Field({ nullable: true }),
    __metadata("design:type", String)
], AIPromptRunResult.prototype, "error", void 0);
__decorate([
    Field({ nullable: true }),
    __metadata("design:type", Number)
], AIPromptRunResult.prototype, "executionTimeMs", void 0);
__decorate([
    Field({ nullable: true }),
    __metadata("design:type", Number)
], AIPromptRunResult.prototype, "tokensUsed", void 0);
__decorate([
    Field({ nullable: true }),
    __metadata("design:type", String)
], AIPromptRunResult.prototype, "promptRunId", void 0);
__decorate([
    Field({ nullable: true }),
    __metadata("design:type", String)
], AIPromptRunResult.prototype, "rawResult", void 0);
__decorate([
    Field({ nullable: true }),
    __metadata("design:type", String)
], AIPromptRunResult.prototype, "validationResult", void 0);
__decorate([
    Field({ nullable: true }),
    __metadata("design:type", String)
], AIPromptRunResult.prototype, "chatResult", void 0);
AIPromptRunResult = __decorate([
    ObjectType()
], AIPromptRunResult);
export { AIPromptRunResult };
let SimplePromptResult = class SimplePromptResult {
};
__decorate([
    Field(),
    __metadata("design:type", Boolean)
], SimplePromptResult.prototype, "success", void 0);
__decorate([
    Field({ nullable: true }),
    __metadata("design:type", String)
], SimplePromptResult.prototype, "result", void 0);
__decorate([
    Field({ nullable: true }),
    __metadata("design:type", String)
], SimplePromptResult.prototype, "resultObject", void 0);
__decorate([
    Field(),
    __metadata("design:type", String)
], SimplePromptResult.prototype, "modelName", void 0);
__decorate([
    Field({ nullable: true }),
    __metadata("design:type", String)
], SimplePromptResult.prototype, "error", void 0);
__decorate([
    Field({ nullable: true }),
    __metadata("design:type", Number)
], SimplePromptResult.prototype, "executionTimeMs", void 0);
SimplePromptResult = __decorate([
    ObjectType()
], SimplePromptResult);
export { SimplePromptResult };
let EmbedTextResult = class EmbedTextResult {
};
__decorate([
    Field(() => [[Number]]),
    __metadata("design:type", Array)
], EmbedTextResult.prototype, "embeddings", void 0);
__decorate([
    Field(),
    __metadata("design:type", String)
], EmbedTextResult.prototype, "modelName", void 0);
__decorate([
    Field(() => Int),
    __metadata("design:type", Number)
], EmbedTextResult.prototype, "vectorDimensions", void 0);
__decorate([
    Field({ nullable: true }),
    __metadata("design:type", String)
], EmbedTextResult.prototype, "error", void 0);
EmbedTextResult = __decorate([
    ObjectType()
], EmbedTextResult);
export { EmbedTextResult };
let RunAIPromptResolver = class RunAIPromptResolver extends ResolverBase {
    /**
     * Internal method that handles the core AI prompt execution logic.
     * This method is called by both the regular and system user resolvers.
     * @private
     */
    async executeAIPrompt(p, promptId, userPayload, data, overrideModelId, overrideVendorId, configurationId, skipValidation, templateData, responseFormat, temperature, topP, topK, minP, frequencyPenalty, presencePenalty, seed, stopSequences, includeLogProbs, topLogProbs, messages, rerunFromPromptRunID, systemPromptOverride) {
        const startTime = Date.now();
        try {
            LogStatus(`=== RUNNING AI PROMPT FOR ID: ${promptId} ===`);
            // Parse data contexts (JSON strings)
            let parsedData = {};
            let parsedTemplateData = {};
            if (data) {
                try {
                    parsedData = JSON.parse(data);
                }
                catch (parseError) {
                    return {
                        success: false,
                        error: `Invalid JSON in data: ${parseError.message}`,
                        executionTimeMs: Date.now() - startTime
                    };
                }
            }
            if (templateData) {
                try {
                    parsedTemplateData = JSON.parse(templateData);
                }
                catch (parseError) {
                    return {
                        success: false,
                        error: `Invalid JSON in template data: ${parseError.message}`,
                        executionTimeMs: Date.now() - startTime
                    };
                }
            }
            // Get current user from payload
            const currentUser = this.GetUserFromPayload(userPayload);
            if (!currentUser) {
                return {
                    success: false,
                    error: 'Unable to determine current user',
                    executionTimeMs: Date.now() - startTime
                };
            }
            // Load the AI prompt entity
            const promptEntity = await p.GetEntityObject('MJ: AI Prompts', currentUser);
            await promptEntity.Load(promptId);
            if (!promptEntity.IsSaved) {
                return {
                    success: false,
                    error: `AI Prompt with ID ${promptId} not found`,
                    executionTimeMs: Date.now() - startTime
                };
            }
            // Check if prompt is active
            if (promptEntity.Status !== 'Active') {
                return {
                    success: false,
                    error: `AI Prompt "${promptEntity.Name}" is not active (Status: ${promptEntity.Status})`,
                    executionTimeMs: Date.now() - startTime
                };
            }
            // Create AI prompt runner and execute
            const promptRunner = new AIPromptRunner();
            // Build execution parameters
            const promptParams = new AIPromptParams();
            promptParams.prompt = promptEntity;
            promptParams.data = parsedData;
            promptParams.templateData = parsedTemplateData;
            promptParams.configurationId = configurationId;
            promptParams.contextUser = currentUser;
            promptParams.skipValidation = skipValidation || false;
            promptParams.rerunFromPromptRunID = rerunFromPromptRunID;
            promptParams.systemPromptOverride = systemPromptOverride;
            // Set override if model or vendor ID provided
            if (overrideModelId || overrideVendorId) {
                promptParams.override = {
                    modelId: overrideModelId,
                    vendorId: overrideVendorId
                };
            }
            // Parse and set conversation messages if provided
            if (messages) {
                try {
                    promptParams.conversationMessages = JSON.parse(messages);
                }
                catch (parseError) {
                    // If parsing fails, treat as a simple user message
                    promptParams.conversationMessages = [{
                            role: 'user',
                            content: messages
                        }];
                }
            }
            // If responseFormat is provided, override the prompt's default response format
            if (responseFormat) {
                // We'll need to override the prompt's response format setting
                // This will be handled in the AIPromptRunner when it builds the ChatParams
                promptEntity.ResponseFormat = responseFormat;
            }
            // Build additional parameters for chat-specific settings
            const additionalParams = {};
            if (temperature != null)
                additionalParams.temperature = temperature;
            if (topP != null)
                additionalParams.topP = topP;
            if (topK != null)
                additionalParams.topK = topK;
            if (minP != null)
                additionalParams.minP = minP;
            if (frequencyPenalty != null)
                additionalParams.frequencyPenalty = frequencyPenalty;
            if (presencePenalty != null)
                additionalParams.presencePenalty = presencePenalty;
            if (seed != null)
                additionalParams.seed = seed;
            if (stopSequences != null)
                additionalParams.stopSequences = stopSequences;
            if (includeLogProbs != null)
                additionalParams.includeLogProbs = includeLogProbs;
            if (topLogProbs != null)
                additionalParams.topLogProbs = topLogProbs;
            // Only set additionalParameters if we have any
            if (Object.keys(additionalParams).length > 0) {
                promptParams.additionalParameters = additionalParams;
            }
            // Execute the prompt
            const result = await promptRunner.ExecutePrompt(promptParams);
            const executionTime = Date.now() - startTime;
            if (result.success) {
                LogStatus(`=== AI PROMPT RUN COMPLETED FOR: ${promptEntity.Name} (${executionTime}ms) ===`);
                return {
                    success: true,
                    output: result.rawResult,
                    parsedResult: typeof result.result === 'string' ? result.result : JSON.stringify(result.result),
                    rawResult: result.rawResult,
                    executionTimeMs: executionTime,
                    tokensUsed: result.tokensUsed,
                    promptRunId: result.promptRun?.ID,
                    validationResult: result.validationResult ? JSON.stringify(result.validationResult) : undefined,
                    chatResult: result.chatResult ? JSON.stringify(result.chatResult) : undefined
                };
            }
            else {
                LogError(`AI Prompt run failed for ${promptEntity.Name}: ${result.errorMessage}`);
                return {
                    success: false,
                    error: result.errorMessage,
                    executionTimeMs: executionTime,
                    promptRunId: result.promptRun?.ID,
                    chatResult: result.chatResult ? JSON.stringify(result.chatResult) : undefined
                };
            }
        }
        catch (error) {
            const executionTime = Date.now() - startTime;
            LogError(`AI Prompt run failed:`, undefined, error);
            return {
                success: false,
                error: error.message || 'Unknown error occurred',
                executionTimeMs: executionTime
            };
        }
    }
    /**
     * Public mutation for regular users to run AI prompts with authentication.
     */
    async RunAIPrompt(promptId, { userPayload, providers }, data, overrideModelId, overrideVendorId, configurationId, skipValidation, templateData, responseFormat, temperature, topP, topK, minP, frequencyPenalty, presencePenalty, seed, stopSequences, includeLogProbs, topLogProbs, messages, rerunFromPromptRunID, systemPromptOverride) {
        // Check API key scope authorization for prompt execution
        await this.CheckAPIKeyScopeAuthorization('prompt:execute', promptId, userPayload);
        const p = GetReadWriteProvider(providers);
        return this.executeAIPrompt(p, promptId, userPayload, data, overrideModelId, overrideVendorId, configurationId, skipValidation, templateData, responseFormat, temperature, topP, topK, minP, frequencyPenalty, presencePenalty, seed, stopSequences, includeLogProbs, topLogProbs, messages, rerunFromPromptRunID, systemPromptOverride);
    }
    /**
     * System user query for running AI prompts with elevated privileges.
     * Requires the @RequireSystemUser decorator to ensure only system users can access.
     */
    async RunAIPromptSystemUser(promptId, { userPayload, providers }, data, overrideModelId, overrideVendorId, configurationId, skipValidation, templateData, responseFormat, temperature, topP, topK, minP, frequencyPenalty, presencePenalty, seed, stopSequences, includeLogProbs, topLogProbs, messages, rerunFromPromptRunID, systemPromptOverride) {
        const p = GetReadWriteProvider(providers);
        return this.executeAIPrompt(p, promptId, userPayload, data, overrideModelId, overrideVendorId, configurationId, skipValidation, templateData, responseFormat, temperature, topP, topK, minP, frequencyPenalty, presencePenalty, seed, stopSequences, includeLogProbs, topLogProbs, messages, rerunFromPromptRunID, systemPromptOverride);
    }
    /**
     * Helper method to select a model for simple prompt execution based on preferences or power level
     * @private
     */
    async selectModelForSimplePrompt(preferredModels, modelPower, contextUser) {
        // Ensure AI Engine is configured
        await AIEngine.Instance.Config(false, contextUser);
        // Get all LLM models that have API keys
        const allModels = AIEngine.Instance.Models.filter(m => m.AIModelType?.trim().toLowerCase() === 'llm' &&
            m.IsActive === true);
        // Filter to only models with valid API keys
        const modelsWithKeys = [];
        for (const model of allModels) {
            const apiKey = GetAIAPIKey(model.DriverClass);
            if (apiKey && apiKey.trim().length > 0) {
                modelsWithKeys.push(model);
            }
        }
        if (modelsWithKeys.length === 0) {
            throw new Error('No AI models with valid API keys found');
        }
        // Try preferred models first if provided
        if (preferredModels && preferredModels.length > 0) {
            for (const preferred of preferredModels) {
                const model = modelsWithKeys.find(m => m.Name === preferred ||
                    m.APIName === preferred);
                if (model) {
                    LogStatus(`Selected preferred model: ${model.Name}`);
                    return model;
                }
            }
            LogStatus('No preferred models available, falling back to power selection');
        }
        // Sort by PowerRank for power-based selection
        modelsWithKeys.sort((a, b) => (b.PowerRank || 0) - (a.PowerRank || 0));
        let selectedModel;
        switch (modelPower) {
            case 'lowest':
                selectedModel = modelsWithKeys[modelsWithKeys.length - 1];
                break;
            case 'highest':
                selectedModel = modelsWithKeys[0];
                break;
            case 'medium':
            default:
                const midIndex = Math.floor(modelsWithKeys.length / 2);
                selectedModel = modelsWithKeys[midIndex];
                break;
        }
        LogStatus(`Selected model by power (${modelPower || 'medium'}): ${selectedModel.Name}`);
        return selectedModel;
    }
    /**
     * Helper method to select an embedding model by size
     * @private
     */
    selectEmbeddingModelBySize(modelSize) {
        const localModels = AIEngine.Instance.LocalEmbeddingModels;
        if (!localModels || localModels.length === 0) {
            throw new Error('No local embedding models available');
        }
        // Models are already sorted by PowerRank (highest first)
        switch (modelSize) {
            case 'small':
                return localModels[localModels.length - 1]; // Lowest power
            case 'medium':
            default:
                const midIndex = Math.floor(localModels.length / 2);
                return localModels[midIndex] || localModels[0];
        }
    }
    /**
     * Helper method to build chat messages from system prompt and optional message history
     * @private
     */
    buildChatMessages(systemPrompt, messagesJson) {
        const messages = [];
        // Add system prompt
        if (systemPrompt && systemPrompt.trim().length > 0) {
            messages.push({
                role: ChatMessageRole.system,
                content: systemPrompt
            });
        }
        // Add message history if provided
        if (messagesJson) {
            try {
                const parsedMessages = JSON.parse(messagesJson);
                if (Array.isArray(parsedMessages)) {
                    for (const msg of parsedMessages) {
                        if (msg.message && msg.role) {
                            messages.push({
                                role: msg.role === 'user' ? ChatMessageRole.user : ChatMessageRole.assistant,
                                content: msg.message
                            });
                        }
                    }
                }
                else if (messagesJson?.length > 0) {
                    // messages maybe just has a simple string in it so add
                    // as a single message
                    messages.push({
                        role: ChatMessageRole.user,
                        content: messagesJson
                    });
                }
            }
            catch (e) {
                if (messagesJson?.length > 0) {
                    // messages maybe just has a simple string in it so add
                    // as a single message
                    messages.push({
                        role: ChatMessageRole.user,
                        content: messagesJson
                    });
                }
                LogError('Failed to parse messages JSON', undefined, e);
            }
        }
        return messages;
    }
    /**
     * Helper method to format simple prompt result
     * @private
     */
    formatSimpleResult(chatResult, model, executionTime) {
        if (!chatResult || !chatResult.success) {
            return {
                success: false,
                error: chatResult?.errorMessage || 'Unknown error occurred',
                modelName: model.Name,
                executionTimeMs: executionTime
            };
        }
        const resultContent = chatResult.data?.choices?.[0]?.message?.content || '';
        // Try to extract JSON from the result
        let resultObject = null;
        try {
            // First try to parse the entire result as JSON
            resultObject = JSON.parse(resultContent);
        }
        catch (e) {
            // Try to find JSON within the text
            const jsonMatch = resultContent.match(/\{[\s\S]*\}|\[[\s\S]*\]/);
            if (jsonMatch) {
                try {
                    resultObject = JSON.parse(jsonMatch[0]);
                }
                catch (e2) {
                    // No valid JSON found
                }
            }
        }
        return {
            success: true,
            result: resultContent,
            resultObject: resultObject ? JSON.stringify(resultObject) : undefined,
            modelName: model.Name,
            executionTimeMs: executionTime
        };
    }
    /**
     * Execute a simple prompt without requiring a stored AI Prompt entity.
     * This is designed for interactive components that need quick AI responses.
     */
    async ExecuteSimplePrompt(systemPrompt, { userPayload }, messages, preferredModels, modelPower, responseFormat) {
        // Check API key scope authorization for simple prompt execution
        await this.CheckAPIKeyScopeAuthorization('prompt:execute', '*', userPayload);
        const startTime = Date.now();
        try {
            LogStatus(`=== EXECUTING SIMPLE PROMPT ===`);
            // Get current user
            const currentUser = this.GetUserFromPayload(userPayload);
            if (!currentUser) {
                return {
                    success: false,
                    error: 'Unable to determine current user',
                    modelName: 'Unknown',
                    executionTimeMs: Date.now() - startTime
                };
            }
            // Select model based on preferences or power level
            const model = await this.selectModelForSimplePrompt(preferredModels, modelPower || 'medium', currentUser);
            // Build chat messages
            const chatMessages = this.buildChatMessages(systemPrompt, messages);
            if (chatMessages.length === 0) {
                return {
                    success: false,
                    error: 'No messages to send to model',
                    modelName: model.Name,
                    executionTimeMs: Date.now() - startTime
                };
            }
            // Create LLM instance
            const apiKey = GetAIAPIKey(model.DriverClass);
            const llm = MJGlobal.Instance.ClassFactory.CreateInstance(BaseLLM, model.DriverClass, apiKey);
            if (!llm) {
                return {
                    success: false,
                    error: `Failed to create LLM instance for model ${model.Name}`,
                    modelName: model.Name,
                    executionTimeMs: Date.now() - startTime
                };
            }
            // Build chat parameters
            const chatParams = new ChatParams();
            chatParams.messages = chatMessages;
            chatParams.model = model.APIName;
            if (responseFormat) {
                // Cast to valid response format type
                chatParams.responseFormat = responseFormat;
            }
            // Execute the chat completion
            const result = await llm.ChatCompletion(chatParams);
            const executionTime = Date.now() - startTime;
            LogStatus(`=== SIMPLE PROMPT COMPLETED (${executionTime}ms) ===`);
            // Format and return the result
            return this.formatSimpleResult(result, model, executionTime);
        }
        catch (error) {
            const executionTime = Date.now() - startTime;
            LogError('Simple prompt execution failed:', undefined, error);
            return {
                success: false,
                error: error.message || 'Unknown error occurred',
                modelName: 'Unknown',
                executionTimeMs: executionTime
            };
        }
    }
    /**
     * System user query for executing simple prompts with elevated privileges
     */
    async ExecuteSimplePromptSystemUser(systemPrompt, { userPayload }, messages, preferredModels, modelPower, responseFormat) {
        // Reuse the same logic as the regular mutation
        return this.ExecuteSimplePrompt(systemPrompt, { userPayload }, messages, preferredModels, modelPower, responseFormat);
    }
    /**
     * Generate embeddings for text using local embedding models.
     * Designed for interactive components that need fast similarity calculations.
     */
    async EmbedText(textToEmbed, modelSize, { userPayload }) {
        // Check API key scope authorization for embedding generation
        await this.CheckAPIKeyScopeAuthorization('embedding:generate', '*', userPayload);
        try {
            LogStatus(`=== GENERATING EMBEDDINGS for ${textToEmbed.length} text(s) ===`);
            // Get current user
            const currentUser = this.GetUserFromPayload(userPayload);
            if (!currentUser) {
                return {
                    embeddings: [],
                    modelName: 'Unknown',
                    vectorDimensions: 0,
                    error: 'Unable to determine current user'
                };
            }
            // Ensure AI Engine is configured
            await AIEngine.Instance.Config(false, currentUser);
            // Select embedding model by size
            const model = this.selectEmbeddingModelBySize(modelSize);
            LogStatus(`Using embedding model: ${model.Name}`);
            // Process embeddings
            const embeddings = [];
            for (const text of textToEmbed) {
                if (!text || text.trim().length === 0) {
                    // Return zero vector for empty text
                    embeddings.push([]);
                    continue;
                }
                // Use AIEngine's EmbedText method
                const result = await AIEngine.Instance.EmbedText(model, text);
                if (result && result.vector && result.vector.length > 0) {
                    embeddings.push(result.vector);
                }
                else {
                    LogError(`Failed to generate embedding for text: ${text.substring(0, 50)}...`);
                    embeddings.push([]); // Add empty array for failed embeddings
                }
            }
            // Get vector dimensions from first successful embedding
            const vectorDimensions = embeddings.find(e => e.length > 0)?.length || 0;
            LogStatus(`=== EMBEDDINGS GENERATED: ${embeddings.length} vectors of ${vectorDimensions} dimensions ===`);
            return {
                embeddings,
                modelName: model.Name,
                vectorDimensions,
                error: undefined
            };
        }
        catch (error) {
            LogError('Embedding generation failed:', undefined, error);
            return {
                embeddings: [],
                modelName: 'Unknown',
                vectorDimensions: 0,
                error: error.message || 'Unknown error occurred'
            };
        }
    }
    /**
     * System user query for generating embeddings with elevated privileges
     */
    async EmbedTextSystemUser(textToEmbed, modelSize, { userPayload }) {
        // Reuse the same logic as the regular mutation
        return this.EmbedText(textToEmbed, modelSize, { userPayload });
    }
};
__decorate([
    Mutation(() => AIPromptRunResult),
    __param(0, Arg('promptId')),
    __param(1, Ctx()),
    __param(2, Arg('data', { nullable: true })),
    __param(3, Arg('overrideModelId', { nullable: true })),
    __param(4, Arg('overrideVendorId', { nullable: true })),
    __param(5, Arg('configurationId', { nullable: true })),
    __param(6, Arg('skipValidation', { nullable: true })),
    __param(7, Arg('templateData', { nullable: true })),
    __param(8, Arg('responseFormat', { nullable: true })),
    __param(9, Arg('temperature', { nullable: true })),
    __param(10, Arg('topP', { nullable: true })),
    __param(11, Arg('topK', () => Int, { nullable: true })),
    __param(12, Arg('minP', { nullable: true })),
    __param(13, Arg('frequencyPenalty', { nullable: true })),
    __param(14, Arg('presencePenalty', { nullable: true })),
    __param(15, Arg('seed', () => Int, { nullable: true })),
    __param(16, Arg('stopSequences', () => [String], { nullable: true })),
    __param(17, Arg('includeLogProbs', { nullable: true })),
    __param(18, Arg('topLogProbs', () => Int, { nullable: true })),
    __param(19, Arg('messages', { nullable: true })),
    __param(20, Arg('rerunFromPromptRunID', { nullable: true })),
    __param(21, Arg('systemPromptOverride', { nullable: true })),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String, Object, String, String, String, String, Boolean, String, String, Number, Number, Number, Number, Number, Number, Number, Array, Boolean, Number, String, String, String]),
    __metadata("design:returntype", Promise)
], RunAIPromptResolver.prototype, "RunAIPrompt", null);
__decorate([
    RequireSystemUser(),
    Query(() => AIPromptRunResult),
    __param(0, Arg('promptId')),
    __param(1, Ctx()),
    __param(2, Arg('data', { nullable: true })),
    __param(3, Arg('overrideModelId', { nullable: true })),
    __param(4, Arg('overrideVendorId', { nullable: true })),
    __param(5, Arg('configurationId', { nullable: true })),
    __param(6, Arg('skipValidation', { nullable: true })),
    __param(7, Arg('templateData', { nullable: true })),
    __param(8, Arg('responseFormat', { nullable: true })),
    __param(9, Arg('temperature', { nullable: true })),
    __param(10, Arg('topP', { nullable: true })),
    __param(11, Arg('topK', () => Int, { nullable: true })),
    __param(12, Arg('minP', { nullable: true })),
    __param(13, Arg('frequencyPenalty', { nullable: true })),
    __param(14, Arg('presencePenalty', { nullable: true })),
    __param(15, Arg('seed', () => Int, { nullable: true })),
    __param(16, Arg('stopSequences', () => [String], { nullable: true })),
    __param(17, Arg('includeLogProbs', { nullable: true })),
    __param(18, Arg('topLogProbs', () => Int, { nullable: true })),
    __param(19, Arg('messages', { nullable: true })),
    __param(20, Arg('rerunFromPromptRunID', { nullable: true })),
    __param(21, Arg('systemPromptOverride', { nullable: true })),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String, Object, String, String, String, String, Boolean, String, String, Number, Number, Number, Number, Number, Number, Number, Array, Boolean, Number, String, String, String]),
    __metadata("design:returntype", Promise)
], RunAIPromptResolver.prototype, "RunAIPromptSystemUser", null);
__decorate([
    Mutation(() => SimplePromptResult),
    __param(0, Arg('systemPrompt')),
    __param(1, Ctx()),
    __param(2, Arg('messages', { nullable: true })),
    __param(3, Arg('preferredModels', () => [String], { nullable: true })),
    __param(4, Arg('modelPower', { nullable: true })),
    __param(5, Arg('responseFormat', { nullable: true })),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String, Object, String, Array, String, String]),
    __metadata("design:returntype", Promise)
], RunAIPromptResolver.prototype, "ExecuteSimplePrompt", null);
__decorate([
    RequireSystemUser(),
    Query(() => SimplePromptResult),
    __param(0, Arg('systemPrompt')),
    __param(1, Ctx()),
    __param(2, Arg('messages', { nullable: true })),
    __param(3, Arg('preferredModels', () => [String], { nullable: true })),
    __param(4, Arg('modelPower', { nullable: true })),
    __param(5, Arg('responseFormat', { nullable: true })),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String, Object, String, Array, String, String]),
    __metadata("design:returntype", Promise)
], RunAIPromptResolver.prototype, "ExecuteSimplePromptSystemUser", null);
__decorate([
    Mutation(() => EmbedTextResult),
    __param(0, Arg('textToEmbed', () => [String])),
    __param(1, Arg('modelSize')),
    __param(2, Ctx()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Array, String, Object]),
    __metadata("design:returntype", Promise)
], RunAIPromptResolver.prototype, "EmbedText", null);
__decorate([
    RequireSystemUser(),
    Query(() => EmbedTextResult),
    __param(0, Arg('textToEmbed', () => [String])),
    __param(1, Arg('modelSize')),
    __param(2, Ctx()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Array, String, Object]),
    __metadata("design:returntype", Promise)
], RunAIPromptResolver.prototype, "EmbedTextSystemUser", null);
RunAIPromptResolver = __decorate([
    Resolver()
], RunAIPromptResolver);
export { RunAIPromptResolver };
//# sourceMappingURL=RunAIPromptResolver.js.map