Files
hack/tools/scripts/llm-key-hunter/results/_cache/content/adrianavarrete_raycast-ai-actions.json

1 line
35 KiB
JSON

{"repo": "adrianavarrete/raycast-ai-actions", "files": {"src/shared/utils.ts": {"8790975665c338af0895204fcc0e3fb9a085f4fc": {"t": 1785746031.4564326, "n": 3436, "h": "3514be09490d075d", "c": "import { Toast, getPreferenceValues, showToast } from '@raycast/api'\nimport { MODEL_OWNERS, MODELS, TOKEN_PRICING } from './constants'\nimport { OpenAiClient } from './api/openai/openai_client'\nimport { round } from 'lodash'\nimport { AnthropicClient } from './api/anthropic/anthropic_client'\n\ntype Model = {\n\tmodelOwner: string\n\tmodelName: string\n\tmodelCode: string\n}\n\nexport function getModel(commandCustomModelName: string): Model {\n\tif (commandCustomModelName) {\n\t\treturn {\n\t\t\tmodelOwner: MODELS[commandCustomModelName].OWNER,\n\t\t\tmodelName: MODELS[commandCustomModelName].NAME,\n\t\t\tmodelCode: MODELS[commandCustomModelName].CODE\n\t\t}\n\t}\n\n\tconst { defaultModelName } = getPreferenceValues()\n\n\treturn {\n\t\tmodelOwner: MODELS[defaultModelName].OWNER,\n\t\tmodelName: MODELS[defaultModelName].NAME,\n\t\tmodelCode: MODELS[defaultModelName].CODE\n\t}\n}\n\nexport async function showCustomToastError({ message }: { message: string }) {\n\tawait showToast(Toast.Style.Failure, `Error: ${message}`)\n}\n\nexport async function showToastApiKeyError({ modelOwner }: { modelOwner: string }) {\n\tawait showToast(Toast.Style.Failure, `Error: Configure the API Key for ${modelOwner}`)\n}\n\nexport async function showToastModelError() {\n\tawait showToast(Toast.Style.Failure, `Error: Model has not been set`)\n}\n\nexport async function showToastSelectedTextError() {\n\tawait showToast(Toast.Style.Failure, `Error: Text has not been selected`)\n}\nexport function isApiKeyConfigured(modelOwner: string) {\n\tconst { openaiApiKey, anthropicApiKey, deepSeekApiKey } = getPreferenceValues()\n\n\tswitch (modelOwner) {\n\t\tcase MODEL_OWNERS.OPEN_AI:\n\t\t\treturn Boolean(openaiApiKey)\n\t\tcase MODEL_OWNERS.ANTHROPIC:\n\t\t\treturn Boolean(anthropicApiKey)\n\t\tcase MODEL_OWNERS.DEEPSEEK:\n\t\t\treturn Boolean(deepSeekApiKey)\n\t\tdefault:\n\t\t\treturn false\n\t}\n}\n\nexport function getAiAPIClient(modelOwner: string) {\n\tif (modelOwner === MODEL_OWNERS.OPEN_AI) {\n\t\tconst { openaiApiKey } = getPreferenceValues()\n\t\tif (!openaiApiKey) showToastApiKeyError({ modelOwner: MODEL_OWNERS.OPEN_AI })\n\n\t\treturn new OpenAiClient({ apiKey: openaiApiKey })\n\t}\n\tif (modelOwner === MODEL_OWNERS.DEEPSEEK) {\n\t\tconst { deepSeekApiKey } = getPreferenceValues()\n\t\tif (!deepSeekApiKey) showToastApiKeyError({ modelOwner: MODEL_OWNERS.DEEPSEEK })\n\t\treturn new OpenAiClient({ apiKey: deepSeekApiKey, baseURL: 'https://api.deepseek.com' })\n\t}\n\tconst { anthropicApiKey } = getPreferenceValues()\n\tif (!anthropicApiKey) showToastApiKeyError({ modelOwner: MODEL_OWNERS.ANTHROPIC })\n\n\treturn new AnthropicClient({ apiKey: anthropicApiKey })\n}\n\nexport function countToken({ text }: { text: string }) {\n\tconst numberOfWords = text.split(' ').length\n\t// On average 1 token is 0,75 words https://help.openai.com/en/articles/4936856-what-are-tokens-and-how-to-count-them\n\tconst averageWordsTokens = 0.75\n\treturn Math.round(numberOfWords / averageWordsTokens)\n}\n\nexport function estimatePrice({\n\tpromptTokenCount,\n\tresponseTokenCount,\n\tmodelCode\n}: {\n\tpromptTokenCount: number\n\tresponseTokenCount: number\n\tmodelCode: string\n}) {\n\tconst promptPrice = (promptTokenCount * TOKEN_PRICING[modelCode].INPUT) / 1000000\n\tconst resultPrice = (responseTokenCount * TOKEN_PRICING[modelCode].OUTPUT) / 1000000\n\tconst totalPrice = promptPrice + resultPrice\n\n\treturn totalPrice\n}\n\nexport function parsePrice(number: number) {\n\tconst ONE_DOLLAR = 1\n\tif (number < ONE_DOLLAR) {\n\t\treturn `${round(number * 100, 4)} cents`\n\t}\n\treturn `${round(number, 2)} $`\n}\n"}, "84c362aabfbe191a2b5e369c0637fff736b2c611": {"t": 1785759027.2115433, "n": 3083, "h": "9f9bf5221b0cb548", "c": "import { Toast, getPreferenceValues, showToast } from '@raycast/api'\nimport { MODEL_OWNERS, MODELS, TOKEN_PRICING } from './constants'\nimport { OpenAiClient } from './api/openai/openai_client'\nimport { round } from 'lodash'\nimport { AnthropicClient } from './api/anthropic/anthropic_client'\n\ntype Model = {\n\tmodelOwner: string\n\tmodelName: string\n\tmodelCode: string\n}\n\nexport function getModel(commandCustomModelName: string): Model {\n\tif (commandCustomModelName) {\n\t\treturn {\n\t\t\tmodelOwner: MODELS[commandCustomModelName].OWNER,\n\t\t\tmodelName: MODELS[commandCustomModelName].NAME,\n\t\t\tmodelCode: MODELS[commandCustomModelName].CODE\n\t\t}\n\t}\n\n\tconst { defaultModelName } = getPreferenceValues()\n\n\treturn {\n\t\tmodelOwner: MODELS[defaultModelName].OWNER,\n\t\tmodelName: MODELS[defaultModelName].NAME,\n\t\tmodelCode: MODELS[defaultModelName].CODE\n\t}\n}\n\nexport async function showCustomToastError({ message }: { message: string }) {\n\tawait showToast(Toast.Style.Failure, `Error: ${message}`)\n}\n\nexport async function showToastApiKeyError({ modelOwner }: { modelOwner: string }) {\n\tawait showToast(Toast.Style.Failure, `Error: Configure the API Key for ${modelOwner}`)\n}\n\nexport async function showToastModelError() {\n\tawait showToast(Toast.Style.Failure, `Error: Model has not been set`)\n}\n\nexport async function showToastSelectedTextError() {\n\tawait showToast(Toast.Style.Failure, `Error: Text has not been selected`)\n}\nexport function isApiKeyConfigured(modelOwner: string) {\n\tconst { openaiApiKey, anthropicApiKey } = getPreferenceValues()\n\n\tswitch (modelOwner) {\n\t\tcase MODEL_OWNERS.OPEN_AI:\n\t\t\treturn Boolean(openaiApiKey)\n\t\tcase MODEL_OWNERS.ANTHROPIC:\n\t\t\treturn Boolean(anthropicApiKey)\n\t\tdefault:\n\t\t\treturn false\n\t}\n}\n\nexport function getAiAPIClient(modelOwner: string) {\n\tif (modelOwner === MODEL_OWNERS.OPEN_AI) {\n\t\tconst { openaiApiKey } = getPreferenceValues()\n\t\tif (!openaiApiKey) showToastApiKeyError({ modelOwner: MODEL_OWNERS.OPEN_AI })\n\n\t\treturn new OpenAiClient({ apiKey: openaiApiKey })\n\t}\n\tconst { anthropicApiKey } = getPreferenceValues()\n\tif (!anthropicApiKey) showToastApiKeyError({ modelOwner: MODEL_OWNERS.ANTHROPIC })\n\n\treturn new AnthropicClient({ apiKey: anthropicApiKey })\n}\n\nexport function countToken({ text }: { text: string }) {\n\tconst numberOfWords = text.split(' ').length\n\t// On average 1 token is 0,75 words https://help.openai.com/en/articles/4936856-what-are-tokens-and-how-to-count-them\n\tconst averageWordsTokens = 0.75\n\treturn Math.round(numberOfWords / averageWordsTokens)\n}\n\nexport function estimatePrice({\n\tpromptTokenCount,\n\tresponseTokenCount,\n\tmodelCode\n}: {\n\tpromptTokenCount: number\n\tresponseTokenCount: number\n\tmodelCode: string\n}) {\n\tconst promptPrice = (promptTokenCount * TOKEN_PRICING[modelCode].INPUT) / 1000000\n\tconst resultPrice = (responseTokenCount * TOKEN_PRICING[modelCode].OUTPUT) / 1000000\n\tconst totalPrice = promptPrice + resultPrice\n\n\treturn totalPrice\n}\n\nexport function parsePrice(number: number) {\n\tconst ONE_DOLLAR = 1\n\tif (number < ONE_DOLLAR) {\n\t\treturn `${round(number * 100, 4)} cents`\n\t}\n\treturn `${round(number, 2)} $`\n}\n"}, "87bfe96dd5c52e4b1ad87208c7834c8d2dc64f05": {"t": 1785759028.3685346, "n": 2886, "h": "fcba55d67f0f5693", "c": "import { Toast, getPreferenceValues, showToast } from '@raycast/api'\nimport { MODEL_OWNERS, MODELS, TOKEN_PRICING } from './constants'\nimport { OpenAiClient } from './api/openai/openai_client'\nimport { round } from 'lodash'\nimport { AnthropicClient } from './api/anthropic/anthropic_client'\n\ntype Model = {\n\tmodelOwner: string\n\tmodelName: string\n\tmodelCode: string\n}\n\nexport function getModel(): Model {\n\tconst { defaultModelName } = getPreferenceValues()\n\n\treturn {\n\t\tmodelOwner: MODELS[defaultModelName].OWNER,\n\t\tmodelName: MODELS[defaultModelName].NAME,\n\t\tmodelCode: MODELS[defaultModelName].CODE\n\t}\n}\n\nexport async function showCustomToastError({ message }: { message: string }) {\n\tawait showToast(Toast.Style.Failure, `Error: ${message}`)\n}\n\nexport async function showToastApiKeyError({ modelOwner }: { modelOwner: string }) {\n\tawait showToast(Toast.Style.Failure, `Error: Configure the API Key for ${modelOwner}`)\n}\n\nexport async function showToastModelError() {\n\tawait showToast(Toast.Style.Failure, `Error: Model has not been set`)\n}\n\nexport async function showToastSelectedTextError() {\n\tawait showToast(Toast.Style.Failure, `Error: Text has not been selected`)\n}\nexport function isApiKeyConfigured() {\n\tconst { openaiApiKey, anthropicApiKey } = getPreferenceValues()\n\tconst { modelOwner } = getModel()\n\n\tswitch (modelOwner) {\n\t\tcase MODEL_OWNERS.OPEN_AI:\n\t\t\treturn Boolean(openaiApiKey)\n\t\tcase MODEL_OWNERS.ANTHROPIC:\n\t\t\treturn Boolean(anthropicApiKey)\n\t\tdefault:\n\t\t\treturn false\n\t}\n}\n\nexport function getAiAPIClient() {\n\tconst { modelOwner } = getModel()\n\tif (modelOwner === MODEL_OWNERS.OPEN_AI) {\n\t\tconst { openaiApiKey } = getPreferenceValues()\n\t\tif (!openaiApiKey) showToastApiKeyError({ modelOwner: MODEL_OWNERS.OPEN_AI })\n\n\t\treturn new OpenAiClient({ apiKey: openaiApiKey })\n\t}\n\tconst { anthropicApiKey } = getPreferenceValues()\n\tif (!anthropicApiKey) showToastApiKeyError({ modelOwner: MODEL_OWNERS.ANTHROPIC })\n\n\treturn new AnthropicClient({ apiKey: anthropicApiKey })\n}\n\nexport function countToken({ text }: { text: string }) {\n\tconst numberOfWords = text.split(' ').length\n\t// On average 1 token is 0,75 words https://help.openai.com/en/articles/4936856-what-are-tokens-and-how-to-count-them\n\tconst averageWordsTokens = 0.75\n\treturn Math.round(numberOfWords / averageWordsTokens)\n}\n\nexport function estimatePrice({\n\tpromptTokenCount,\n\tresponseTokenCount\n}: {\n\tpromptTokenCount: number\n\tresponseTokenCount: number\n}) {\n\tconst { modelCode } = getModel()\n\tconst promptPrice = (promptTokenCount * TOKEN_PRICING[modelCode].INPUT) / 1000000\n\tconst resultPrice = (responseTokenCount * TOKEN_PRICING[modelCode].OUTPUT) / 1000000\n\tconst totalPrice = promptPrice + resultPrice\n\n\treturn totalPrice\n}\n\nexport function parsePrice(number: number) {\n\tconst ONE_DOLLAR = 1\n\tif (number < ONE_DOLLAR) {\n\t\treturn `${round(number * 100, 4)} cents`\n\t}\n\treturn `${round(number, 2)} $`\n}\n"}, "9bf5b5ae043810ad7bd0f96783547c755657836a": {"t": 1785759030.125822, "n": 2869, "h": "65515e72b70d577e", "c": "import { Toast, getPreferenceValues, showToast } from '@raycast/api'\nimport { MODEL_OWNERS, MODELS, TOKEN_PRICING } from './constants'\nimport { OpenAiClient } from './api/openai_client'\nimport { round } from 'lodash'\nimport { AnthropicClient } from './api/anthropic_client'\n\ntype Model = {\n\tmodelOwner: string\n\tmodelName: string\n\tmodelCode: string\n}\n\nexport function getModel(): Model {\n\tconst { defaultModelName } = getPreferenceValues()\n\n\treturn {\n\t\tmodelOwner: MODELS[defaultModelName].OWNER,\n\t\tmodelName: MODELS[defaultModelName].NAME,\n\t\tmodelCode: MODELS[defaultModelName].CODE\n\t}\n}\n\nexport async function showCustomToastError({ message }: { message: string }) {\n\tawait showToast(Toast.Style.Failure, `Error: ${message}`)\n}\n\nexport async function showToastApiKeyError({ modelOwner }: { modelOwner: string }) {\n\tawait showToast(Toast.Style.Failure, `Error: Configure the API Key for ${modelOwner}`)\n}\n\nexport async function showToastModelError() {\n\tawait showToast(Toast.Style.Failure, `Error: Model has not been set`)\n}\n\nexport async function showToastSelectedTextError() {\n\tawait showToast(Toast.Style.Failure, `Error: Text has not been selected`)\n}\nexport function isApiKeyConfigured() {\n\tconst { openaiApiKey, anthropicApiKey } = getPreferenceValues()\n\tconst { modelOwner } = getModel()\n\n\tswitch (modelOwner) {\n\t\tcase MODEL_OWNERS.OPEN_AI:\n\t\t\treturn Boolean(openaiApiKey)\n\t\tcase MODEL_OWNERS.ANTHROPIC:\n\t\t\treturn Boolean(anthropicApiKey)\n\t\tdefault:\n\t\t\treturn false\n\t}\n}\n\nexport function getAiAPIClient() {\n\tconst { modelOwner } = getModel()\n\tif (modelOwner === MODEL_OWNERS.OPEN_AI) {\n\t\tconst { openaiApiKey } = getPreferenceValues()\n\t\tif (!openaiApiKey) showToastApiKeyError({ modelOwner: MODEL_OWNERS.OPEN_AI })\n\n\t\treturn new OpenAiClient({ apiKey: openaiApiKey })\n\t}\n\tconst { anthropicApiKey } = getPreferenceValues()\n\tif (!anthropicApiKey) showToastApiKeyError({ modelOwner: MODEL_OWNERS.ANTHROPIC })\n\n\treturn new AnthropicClient({ apiKey: anthropicApiKey })\n}\n\nexport function countToken({ text }: { text: string }) {\n\tconst numberOfWords = text.split(' ').length\n\t// On average 1 token is 0,75 words https://help.openai.com/en/articles/4936856-what-are-tokens-and-how-to-count-them\n\tconst averageWordsTokens = 0.75\n\treturn Math.round(numberOfWords / averageWordsTokens)\n}\n\nexport function estimatePrice({\n\tpromptTokenCount,\n\tresponseTokenCount\n}: {\n\tpromptTokenCount: number\n\tresponseTokenCount: number\n}) {\n\tconst { modelCode } = getModel()\n\tconst promptPrice = (promptTokenCount * TOKEN_PRICING[modelCode].INPUT) / 1000000\n\tconst resultPrice = (responseTokenCount * TOKEN_PRICING[modelCode].OUTPUT) / 1000000\n\tconst totalPrice = promptPrice + resultPrice\n\n\treturn totalPrice\n}\n\nexport function parsePrice(number: number) {\n\tconst ONE_DOLLAR = 1\n\tif (number < ONE_DOLLAR) {\n\t\treturn `${round(number * 100, 4)} cents`\n\t}\n\treturn `${round(number, 2)} $`\n}\n"}, "1fb98566d03a1b7e1388a4e7de610db6c08946ec": {"t": 1785759031.410568, "n": 2786, "h": "2dad8c501909946d", "c": "import { Toast, getPreferenceValues, showToast } from '@raycast/api'\nimport { MODEL_OWNERS, MODELS, TOKEN_PRICING } from './constants'\nimport { OpenAiClient } from './api/openai_client'\nimport { round } from 'lodash'\nimport { AnthropicClient } from './api/anthropic_client'\n\ntype Model = {\n\tmodelOwner: string\n\tmodelName: string\n\tmodelCode: string\n}\n\nexport function getModel(): Model {\n\tconst { defaultModelName } = getPreferenceValues()\n\n\treturn {\n\t\tmodelOwner: MODELS[defaultModelName].OWNER,\n\t\tmodelName: MODELS[defaultModelName].NAME,\n\t\tmodelCode: MODELS[defaultModelName].CODE\n\t}\n}\n\nexport async function showCustomToastError({ message }: { message: string }) {\n\tawait showToast(Toast.Style.Failure, `Error: ${message}`)\n}\n\nexport async function showToastApiKeyError({ modelOwner }: { modelOwner: string }) {\n\tawait showToast(Toast.Style.Failure, `Error: Configure the API Key for ${modelOwner}`)\n}\n\nexport async function showToastModelError() {\n\tawait showToast(Toast.Style.Failure, `Error: Model has not been set`)\n}\n\nexport async function showToastSelectedTextError() {\n\tawait showToast(Toast.Style.Failure, `Error: Text has not been selected`)\n}\nexport function isApiKeyConfigured() {\n\tconst { openaiApiKey } = getPreferenceValues()\n\tconst { modelOwner } = getModel()\n\n\tswitch (modelOwner) {\n\t\tcase MODEL_OWNERS.OPEN_AI:\n\t\t\treturn Boolean(openaiApiKey)\n\t\tdefault:\n\t\t\treturn false\n\t}\n}\n\nexport function getAiAPIClient() {\n\tconst { modelOwner } = getModel()\n\tif (modelOwner === MODEL_OWNERS.OPEN_AI) {\n\t\tconst { openaiApiKey } = getPreferenceValues()\n\t\tif (!openaiApiKey) showToastApiKeyError({ modelOwner: MODEL_OWNERS.OPEN_AI })\n\n\t\treturn new OpenAiClient({ apiKey: openaiApiKey })\n\t}\n\tconst { anthropicApiKey } = getPreferenceValues()\n\tif (!anthropicApiKey) showToastApiKeyError({ modelOwner: MODEL_OWNERS.ANTHROPIC })\n\n\treturn new AnthropicClient({ apiKey: anthropicApiKey })\n}\n\nexport function countToken({ text }: { text: string }) {\n\tconst numberOfWords = text.split(' ').length\n\t// On average 1 token is 0,75 words https://help.openai.com/en/articles/4936856-what-are-tokens-and-how-to-count-them\n\tconst averageWordsTokens = 0.75\n\treturn Math.round(numberOfWords / averageWordsTokens)\n}\n\nexport function estimatePrice({\n\tpromptTokenCount,\n\tresponseTokenCount\n}: {\n\tpromptTokenCount: number\n\tresponseTokenCount: number\n}) {\n\tconst { modelCode } = getModel()\n\tconst promptPrice = (promptTokenCount * TOKEN_PRICING[modelCode].INPUT) / 1000000\n\tconst resultPrice = (responseTokenCount * TOKEN_PRICING[modelCode].OUTPUT) / 1000000\n\tconst totalPrice = promptPrice + resultPrice\n\n\treturn totalPrice\n}\n\nexport function parsePrice(number: number) {\n\tconst ONE_DOLLAR = 1\n\tif (number < ONE_DOLLAR) {\n\t\treturn `${round(number * 100, 4)} cents`\n\t}\n\treturn `${round(number, 2)} $`\n}\n"}, "a5934b604fd57cd63f1a1f3cabf2e59331676cfa": {"t": 1785759032.741747, "n": 2451, "h": "37d6d6b6ac36f6ac", "c": "import { Toast, getPreferenceValues, showToast } from '@raycast/api'\nimport { MODEL_OWNERS, MODELS, TOKEN_PRICING } from './constants'\nimport { OpenAiClient } from './api/openai_client'\nimport { round } from 'lodash'\n\ntype Model = {\n\tmodelOwner: string\n\tmodelName: string\n\tmodelCode: string\n}\n\nexport function getModel(): Model {\n\tconst { defaultModelName } = getPreferenceValues()\n\n\treturn {\n\t\tmodelOwner: MODELS[defaultModelName].OWNER,\n\t\tmodelName: MODELS[defaultModelName].NAME,\n\t\tmodelCode: MODELS[defaultModelName].CODE\n\t}\n}\n\nexport async function showCustomToastError({ message }: { message: string }) {\n\tawait showToast(Toast.Style.Failure, `Error: ${message}`)\n}\n\nexport async function showToastApiKeyError({ modelOwner }: { modelOwner: string }) {\n\tawait showToast(Toast.Style.Failure, `Error: Configure the API Key for ${modelOwner}`)\n}\n\nexport async function showToastModelError() {\n\tawait showToast(Toast.Style.Failure, `Error: Model has not been set`)\n}\n\nexport async function showToastSelectedTextError() {\n\tawait showToast(Toast.Style.Failure, `Error: Text has not been selected`)\n}\nexport function isApiKeyConfigured() {\n\tconst { openaiApiKey } = getPreferenceValues()\n\tconst { modelOwner } = getModel()\n\n\tswitch (modelOwner) {\n\t\tcase MODEL_OWNERS.OPEN_AI:\n\t\t\treturn Boolean(openaiApiKey)\n\t\tdefault:\n\t\t\treturn false\n\t}\n}\n\nexport function getAiAPIClient() {\n\tconst { openaiApiKey } = getPreferenceValues()\n\tif (!openaiApiKey) showToastApiKeyError({ modelOwner: MODEL_OWNERS.OPEN_AI })\n\n\treturn new OpenAiClient({ apiKey: openaiApiKey })\n}\n\nexport function countToken({ text }: { text: string }) {\n\tconst numberOfWords = text.split(' ').length\n\t// On average 1 token is 0,75 words https://help.openai.com/en/articles/4936856-what-are-tokens-and-how-to-count-them\n\tconst averageWordsTokens = 0.75\n\treturn Math.round(numberOfWords / averageWordsTokens)\n}\n\nexport function estimatePrice({\n\tpromptTokenCount,\n\tresponseTokenCount\n}: {\n\tpromptTokenCount: number\n\tresponseTokenCount: number\n}) {\n\tconst { modelCode } = getModel()\n\tconst promptPrice = (promptTokenCount * TOKEN_PRICING[modelCode].INPUT) / 1000000\n\tconst resultPrice = (responseTokenCount * TOKEN_PRICING[modelCode].OUTPUT) / 1000000\n\tconst totalPrice = promptPrice + resultPrice\n\n\treturn totalPrice\n}\n\nexport function parsePrice(number: number) {\n\tconst ONE_DOLLAR = 1\n\tif (number < ONE_DOLLAR) {\n\t\treturn `${round(number * 100, 4)} cents`\n\t}\n\treturn `${round(number, 2)} $`\n}\n"}, "085951ec1902f8e4c755a76a5f89da793cc4197d": {"t": 1785759033.9799738, "n": 2604, "h": "368f210ac022bd5b", "c": "import { Toast, getPreferenceValues, showToast } from '@raycast/api'\nimport { MODEL_OWNERS, OPEN_AI_MODELS, OPEN_AI_TOKEN_PRICING } from './constants'\nimport { OpenAiClient } from './api/openai_client'\nimport { values, round } from 'lodash'\n\ntype Model = {\n\tmodelOwner: string\n\tmodel: string\n}\n\nexport function getModel(): Model {\n\tconst { defaultModel } = getPreferenceValues()\n\n\tif (values(OPEN_AI_MODELS).some(model => model === defaultModel)) {\n\t\treturn { modelOwner: MODEL_OWNERS.OPEN_AI, model: defaultModel }\n\t}\n\treturn { modelOwner: '', model: '' }\n}\n\nexport async function showCustomToastError({ message }: { message: string }) {\n\tawait showToast(Toast.Style.Failure, `Error: ${message}`)\n}\n\nexport async function showToastApiKeyError({ modelOwner }: { modelOwner: string }) {\n\tawait showToast(Toast.Style.Failure, `Error: Configure the API Key for ${modelOwner}`)\n}\n\nexport async function showToastModelError() {\n\tawait showToast(Toast.Style.Failure, `Error: Model has not been set`)\n}\n\nexport async function showToastSelectedTextError() {\n\tawait showToast(Toast.Style.Failure, `Error: Text has not been selected`)\n}\nexport function isApiKeyConfigured({ modelOwner }: { modelOwner: string }) {\n\tconst { openaiApiKey } = getPreferenceValues()\n\n\tswitch (modelOwner) {\n\t\tcase MODEL_OWNERS.OPEN_AI:\n\t\t\treturn Boolean(openaiApiKey)\n\t\tdefault:\n\t\t\treturn false\n\t}\n}\n\nexport function getAiAPIClient() {\n\tconst { openaiApiKey } = getPreferenceValues()\n\tif (!openaiApiKey) showToastApiKeyError({ modelOwner: MODEL_OWNERS.OPEN_AI })\n\n\treturn new OpenAiClient({ apiKey: openaiApiKey })\n}\n\nexport function countToken({ text }: { text: string }) {\n\tconst numberOfWords = text.split(' ').length\n\t// On average 1 token is 0,75 words https://help.openai.com/en/articles/4936856-what-are-tokens-and-how-to-count-them\n\tconst averageWordsTokens = 0.75\n\treturn Math.round(numberOfWords / averageWordsTokens)\n}\n\nexport function estimatePrice({\n\tpromptTokenCount,\n\tresponseTokenCount\n}: {\n\tpromptTokenCount: number\n\tresponseTokenCount: number\n}) {\n\tconst { defaultModel } = getPreferenceValues()\n\tif (values(OPEN_AI_MODELS).some(model => model === defaultModel)) {\n\t\tconst promptPrice = (promptTokenCount * OPEN_AI_TOKEN_PRICING[defaultModel].INPUT) / 1000000\n\t\tconst resultPrice = (responseTokenCount * OPEN_AI_TOKEN_PRICING[defaultModel].OUTPUT) / 1000000\n\t\tconst totalPrice = promptPrice + resultPrice\n\n\t\treturn totalPrice\n\t}\n\treturn 0\n}\n\nexport function parsePrice(number: number) {\n\tconst ONE_DOLLAR = 1\n\tif (number < ONE_DOLLAR) {\n\t\treturn `${round(number * 100, 4)} cents`\n\t}\n\treturn `${round(number, 2)} $`\n}\n"}, "f052b0774321924b26d6803004489dc88e90b399": {"t": 1785759035.1813998, "n": 2649, "h": "731eb8b5d79f0724", "c": "import { Toast, getPreferenceValues, showToast } from '@raycast/api'\nimport { MODEL_OWNERS, OPEN_AI_MODELS, OPEN_AI_TOKEN_PRICING } from './constants'\nimport { OpenAiClient } from './api/openai_client'\nimport { values, round } from 'lodash'\n\ntype Model = {\n\tmodelOwner: string\n\tmodel: string\n}\n\nexport function getModel(): Model {\n\tconst { defaultModel } = getPreferenceValues()\n\n\tif (values(OPEN_AI_MODELS).some(model => model === defaultModel)) {\n\t\treturn { modelOwner: MODEL_OWNERS.OPEN_AI, model: defaultModel }\n\t}\n\treturn { modelOwner: '', model: '' }\n}\n\nexport async function showCustomToastError({ message }: { message: string }) {\n\tawait showToast(Toast.Style.Failure, `Error: ${message}`)\n}\n\nexport async function showToastApiKeyError({ modelOwner }: { modelOwner: string }) {\n\tawait showToast(Toast.Style.Failure, `Error: Configure the API Key for ${modelOwner}`)\n}\n\nexport async function showToastModelError() {\n\tawait showToast(Toast.Style.Failure, `Error: Model has not been set`)\n}\n\nexport async function showToastSelectedTextError() {\n\tawait showToast(Toast.Style.Failure, `Error: Text has not been selected`)\n}\nexport function isApiKeyConfigured({ modelOwner }: { modelOwner: string }) {\n\tconst { openaiApiKey } = getPreferenceValues()\n\n\tswitch (modelOwner) {\n\t\tcase MODEL_OWNERS.OPEN_AI:\n\t\t\treturn Boolean(openaiApiKey)\n\t\tdefault:\n\t\t\treturn false\n\t}\n}\n\nexport function getAiAPIClient() {\n\tconst { openaiApiKey } = getPreferenceValues()\n\tif (!openaiApiKey) showToastApiKeyError({ modelOwner: MODEL_OWNERS.OPEN_AI })\n\n\treturn new OpenAiClient({ apiKey: openaiApiKey })\n}\n\nexport function countToken({ text }: { text: string }) {\n\tconst numberOfWords = text.split(' ').length\n\t// On average 1 token is 0,75 words https://help.openai.com/en/articles/4936856-what-are-tokens-and-how-to-count-them\n\tconst averageWordsTokens = 0.75\n\treturn Math.round(numberOfWords / averageWordsTokens)\n}\n\nexport function estimatePrice({\n\tpromptTokenCount,\n\tresponseTokenCount\n}: {\n\tpromptTokenCount: number\n\tresponseTokenCount: number\n}) {\n\tconst { defaultModel } = getPreferenceValues()\n\tif (values(OPEN_AI_MODELS).some(model => model === defaultModel)) {\n\t\tconst promptPrice = (promptTokenCount * OPEN_AI_TOKEN_PRICING[defaultModel].INPUT) / 1000000\n\t\tconst resultPrice = (responseTokenCount * OPEN_AI_TOKEN_PRICING[defaultModel].OUTPUT) / 1000000\n\t\tconst totalPrice = promptPrice + resultPrice\n\n\t\treturn totalPrice\n\t}\n\treturn 0\n}\n\nexport function parsePrice(number: number) {\n\tconsole.log(`@@@@@ number pricing`, number)\n\tconst ONE_DOLLAR = 1\n\tif (number < ONE_DOLLAR) {\n\t\treturn `${round(number, 5) * 100} cents`\n\t}\n\treturn `${round(number, 2)} $`\n}\n"}, "abce438cfaa984b351962c96ef7a5d85d7b878f2": {"t": 1785759036.5559547, "n": 2370, "h": "38083b548f6ad162", "c": "import { Toast, getPreferenceValues, showToast } from '@raycast/api'\nimport { MODEL_OWNERS, OPEN_AI_MODELS, OPEN_AI_TOKEN_PRICING } from './constants'\nimport { OpenAiClient } from './api/openai_client'\nimport { values, round } from 'lodash'\n\ntype Model = {\n\tmodelOwner: string\n\tmodel: string\n}\n\nexport function getModel(): Model {\n\tconst { defaultModel } = getPreferenceValues()\n\n\tif (values(OPEN_AI_MODELS).some(model => model === defaultModel)) {\n\t\treturn { modelOwner: MODEL_OWNERS.OPEN_AI, model: defaultModel }\n\t}\n\treturn { modelOwner: '', model: '' }\n}\n\nexport async function showToastApiKeyError({ modelOwner }: { modelOwner: string }) {\n\tawait showToast(Toast.Style.Failure, `Error: Configure the API Key for ${modelOwner}`)\n}\n\nexport async function showToastModelError() {\n\tawait showToast(Toast.Style.Failure, `Error: Model has not been set`)\n}\n\nexport async function showToastSelectedTextError() {\n\tawait showToast(Toast.Style.Failure, `Error: Text has not been selected`)\n}\nexport function isApiKeyConfigured({ modelOwner }: { modelOwner: string }) {\n\tconst { openaiApiKey } = getPreferenceValues()\n\n\tswitch (modelOwner) {\n\t\tcase MODEL_OWNERS.OPEN_AI:\n\t\t\treturn Boolean(openaiApiKey)\n\t\tdefault:\n\t\t\treturn false\n\t}\n}\n\nexport function getAiAPIClient() {\n\tconst { openaiApiKey } = getPreferenceValues()\n\tif (!openaiApiKey) showToastApiKeyError({ modelOwner: MODEL_OWNERS.OPEN_AI })\n\n\treturn new OpenAiClient({ apiKey: openaiApiKey })\n}\n\nexport function countToken({ text }: { text: string }) {\n\tconst numberOfWords = text.split(' ').length\n\t// On average 1 token is 0,75 words https://help.openai.com/en/articles/4936856-what-are-tokens-and-how-to-count-them\n\tconst averageWordsTokens = 0.75\n\treturn Math.round(numberOfWords / averageWordsTokens)\n}\n\nexport function estimatePrice({\n\tpromptTokenCount,\n\tresponseTokenCount\n}: {\n\tpromptTokenCount: number\n\tresponseTokenCount: number\n}) {\n\tconst { defaultModel } = getPreferenceValues()\n\tif (values(OPEN_AI_MODELS).some(model => model === defaultModel)) {\n\t\tconst promptPrice = (promptTokenCount * OPEN_AI_TOKEN_PRICING[defaultModel].INPUT) / 1000000\n\t\tconst resultPrice = (responseTokenCount * OPEN_AI_TOKEN_PRICING[defaultModel].OUTPUT) / 1000000\n\t\tconst totalPrice = promptPrice + resultPrice\n\t\tif (totalPrice < 1) {\n\t\t\treturn `${round(totalPrice * 100, 4)} cents`\n\t\t}\n\t\treturn `${totalPrice} $`\n\t}\n\treturn ''\n}\n"}, "6fea499574341a66a0e19602ba1f1c4d919ba94f": {"t": 1785759037.8294282, "n": 2290, "h": "05e1f55af8730648", "c": "import { Toast, getPreferenceValues, showToast } from '@raycast/api'\nimport { MODEL_OWNERS, OPEN_AI_MODELS, OPEN_AI_TOKEN_PRICING } from './constants'\nimport { OpenAiClient } from './api/openai_client'\nimport { values, round } from 'lodash'\n\ntype Model = {\n\tmodelOwner: string\n\tmodel: string\n}\n\nexport function getModel(): Model {\n\tconst { defaultModel } = getPreferenceValues()\n\n\tif (values(OPEN_AI_MODELS).some(model => model === defaultModel)) {\n\t\treturn { modelOwner: MODEL_OWNERS.OPEN_AI, model: defaultModel }\n\t}\n\treturn { modelOwner: '', model: '' }\n}\n\nexport async function showToastApiKeyError({ modelOwner }: { modelOwner: string }) {\n\tawait showToast(Toast.Style.Failure, `Error: Configure the API Key for ${modelOwner}`)\n}\n\nexport async function showToastModelError() {\n\tawait showToast(Toast.Style.Failure, `Error: Model has not been set`)\n}\n\nexport async function showToastSelectedTextError() {\n\tawait showToast(Toast.Style.Failure, `Error: Text has not been selected`)\n}\nexport function isApiKeyConfigured({ modelOwner }: { modelOwner: string }) {\n\tconst { openaiApiKey } = getPreferenceValues()\n\n\tswitch (modelOwner) {\n\t\tcase MODEL_OWNERS.OPEN_AI:\n\t\t\treturn Boolean(openaiApiKey)\n\t\tdefault:\n\t\t\treturn false\n\t}\n}\n\nexport function getAiAPIClient() {\n\tconst { openaiApiKey } = getPreferenceValues()\n\treturn new OpenAiClient({ apiKey: openaiApiKey })\n}\n\nexport function countToken({ text }: { text: string }) {\n\tconst numberOfWords = text.split(' ').length\n\t// On average 1 token is 0,75 words https://help.openai.com/en/articles/4936856-what-are-tokens-and-how-to-count-them\n\tconst averageWordsTokens = 0.75\n\treturn Math.round(numberOfWords / averageWordsTokens)\n}\n\nexport function estimatePrice({\n\tpromptTokenCount,\n\tresponseTokenCount\n}: {\n\tpromptTokenCount: number\n\tresponseTokenCount: number\n}) {\n\tconst { defaultModel } = getPreferenceValues()\n\tif (values(OPEN_AI_MODELS).some(model => model === defaultModel)) {\n\t\tconst promptPrice = (promptTokenCount * OPEN_AI_TOKEN_PRICING[defaultModel].INPUT) / 1000000\n\t\tconst resultPrice = (responseTokenCount * OPEN_AI_TOKEN_PRICING[defaultModel].OUTPUT) / 1000000\n\t\tconst totalPrice = promptPrice + resultPrice\n\t\tif (totalPrice < 1) {\n\t\t\treturn `${round(totalPrice * 100, 4)} cents`\n\t\t}\n\t\treturn `${totalPrice} $`\n\t}\n\treturn ''\n}\n"}, "59c87af60033bbf38ae831d983676a25a1dbe294": {"t": 1785759040.0479455, "n": 1608, "h": "64e42eaf7e522300", "c": "import { Toast, getPreferenceValues, showToast } from '@raycast/api'\nimport { MODEL_OWNERS, OPEN_AI_MODELS } from './constants'\nimport { OpenAiClient } from './api/openai_client'\n\ntype Model = {\n\tmodelOwner: string\n\tmodel: string\n}\n\nexport function getModel(): Model {\n\tconst { defaultModel } = getPreferenceValues()\n\n\tif (OPEN_AI_MODELS.some(model => model === defaultModel)) {\n\t\treturn { modelOwner: MODEL_OWNERS.OPEN_AI, model: defaultModel }\n\t}\n\treturn { modelOwner: '', model: '' }\n}\n\nexport async function showToastApiKeyError({ modelOwner }: { modelOwner: string }) {\n\tawait showToast(Toast.Style.Failure, `Error: Configure the API Key for ${modelOwner}`)\n}\n\nexport async function showToastModelError() {\n\tawait showToast(Toast.Style.Failure, `Error: Model has not been set`)\n}\n\nexport async function showToastSelectedTextError() {\n\tawait showToast(Toast.Style.Failure, `Error: Text has not been selected`)\n}\nexport function isApiKeyConfigured({ modelOwner }: { modelOwner: string }) {\n\tconst { openaiApiKey } = getPreferenceValues()\n\n\tswitch (modelOwner) {\n\t\tcase MODEL_OWNERS.OPEN_AI:\n\t\t\treturn Boolean(openaiApiKey)\n\t\tdefault:\n\t\t\treturn false\n\t}\n}\n\nexport function getAiAPIClient() {\n\tconst { openaiApiKey } = getPreferenceValues()\n\treturn new OpenAiClient({ apiKey: openaiApiKey })\n}\n\nexport function countToken({ text }: { text: string }) {\n\tconst numberOfWords = text.split(' ').length\n\t// On average 1 token is 0,75 words https://help.openai.com/en/articles/4936856-what-are-tokens-and-how-to-count-them\n\tconst averageWordsTokens = 0.75\n\treturn Math.round(numberOfWords / averageWordsTokens)\n}\n"}, "15637588d4a5f39c729392cc69f5028a306e7cdf": {"t": 1785759041.2043688, "n": 1295, "h": "53e5ab526d734e7b", "c": "import { Toast, getPreferenceValues, showToast } from '@raycast/api'\nimport { MODEL_OWNERS, OPEN_AI_MODELS } from './constants'\nimport { OpenAiClient } from './api/openai_client'\n\ntype Model = {\n\tmodelOwner: string\n\tmodel: string\n}\n\nexport function getModel(): Model {\n\tconst { defaultModel } = getPreferenceValues()\n\n\tif (OPEN_AI_MODELS.some(model => model === defaultModel)) {\n\t\treturn { modelOwner: MODEL_OWNERS.OPEN_AI, model: defaultModel }\n\t}\n\treturn { modelOwner: '', model: '' }\n}\n\nexport async function showToastApiKeyError({ modelOwner }: { modelOwner: string }) {\n\tawait showToast(Toast.Style.Failure, `Error: Configure the API Key for ${modelOwner}`)\n}\n\nexport async function showToastModelError() {\n\tawait showToast(Toast.Style.Failure, `Error: Model has not been set`)\n}\n\nexport async function showToastSelectedTextError() {\n\tawait showToast(Toast.Style.Failure, `Error: Text has not been selected`)\n}\nexport function isApiKeyConfigured({ modelOwner }: { modelOwner: string }) {\n\tconst { openaiApiKey } = getPreferenceValues()\n\n\tswitch (modelOwner) {\n\t\tcase MODEL_OWNERS.OPEN_AI:\n\t\t\treturn Boolean(openaiApiKey)\n\t\tdefault:\n\t\t\treturn false\n\t}\n}\n\nexport function getAiAPIClient() {\n\tconst { openaiApiKey } = getPreferenceValues()\n\treturn new OpenAiClient({ apiKey: openaiApiKey })\n}\n"}, "3258d5c3ecf0210af0bac358bc337c198bd9f01e": {"t": 1785759043.1865683, "n": 977, "h": "5d83b7e511b5b1d1", "c": "import { Toast, getPreferenceValues, showToast } from '@raycast/api'\nimport { MODEL_OWNERS, OPEN_AI_MODELS } from './constants'\n\ntype Model = {\n\tmodelOwner: string\n\tmodel: string\n}\n\nexport function getModel(): Model {\n\tconst { defaultModel } = getPreferenceValues()\n\n\tif (OPEN_AI_MODELS.some(model => model === defaultModel)) {\n\t\treturn { modelOwner: MODEL_OWNERS.OPEN_AI, model: defaultModel }\n\t}\n\treturn { modelOwner: '', model: '' }\n}\n\nexport async function showToastApiKeyError({ modelOwner }: { modelOwner: string }) {\n\tawait showToast(Toast.Style.Failure, `Error: Configure the API Key for ${modelOwner}`)\n}\n\nexport async function showToastModelError() {\n\tawait showToast(Toast.Style.Failure, `Error: Model has not been set`)\n}\n\nexport function isApiKeyConfigured({ modelOwner }: { modelOwner: string }) {\n\tconst { openaiApiKey } = getPreferenceValues()\n\n\tswitch (modelOwner) {\n\t\tcase MODEL_OWNERS.OPEN_AI:\n\t\t\treturn Boolean(openaiApiKey)\n\t\tdefault:\n\t\t\treturn false\n\t}\n}\n"}, "e82322aee769ab6ad2359d84e2c49edcbd252a2f": {"t": 1785759044.3960617, "n": 977, "h": "f5b611c100583bae", "c": "import { Toast, getPreferenceValues, showToast } from '@raycast/api'\nimport { MODEL_OWNERS, OPEN_AI_MODELS } from './constants'\n\ntype Model = {\n\tmodelOwner: string\n\tmodel: string\n}\n\nexport function getModel(): Model {\n\tconst { defaultModel } = getPreferenceValues()\n\n\tif (OPEN_AI_MODELS.some(model => model === defaultModel)) {\n\t\treturn { modelOwner: MODEL_OWNERS.OPEN_AI, model: defaultModel }\n\t}\n\treturn { modelOwner: '', model: '' }\n}\n\nexport async function showToastApiKeyError({ modelOwner }: { modelOwner: string }) {\n\tawait showToast(Toast.Style.Failure, `Error: Configure the API Key for ${modelOwner}`)\n}\n\nexport async function showToastModelError() {\n\tawait showToast(Toast.Style.Failure, `Error: Model has not been set`)\n}\n\nexport function isApiKeyConfigured({ modelOwner }: { modelOwner: string }) {\n\tconst { openAiApiKey } = getPreferenceValues()\n\n\tswitch (modelOwner) {\n\t\tcase MODEL_OWNERS.OPEN_AI:\n\t\t\treturn Boolean(openAiApiKey)\n\t\tdefault:\n\t\t\treturn false\n\t}\n}\n"}}}}