| 1792 | 1792 | `)); |
| 1793 | 1793 | } |
| 1794 | 1794 | |
| 1795 | +function getNanoGptModelTemplate(option) { |
| 1796 | + const model = model_list.find(x => x.id === option?.element?.value); |
| 1797 | + |
| 1798 | + if (!option.id || !model) { |
| 1799 | + return option.text; |
| 1800 | + } |
| 1801 | + |
| 1802 | + const inputPrice = model.pricing?.prompt; |
| 1803 | + const outputPrice = model.pricing?.completion; |
| 1804 | + |
| 1805 | + let price = 'Unknown'; |
| 1806 | + if (inputPrice !== undefined && outputPrice !== undefined) { |
| 1807 | + // Check if both prices are 0 (free model) |
| 1808 | + if (inputPrice === 0 && outputPrice === 0) { |
| 1809 | + price = 'Free'; |
| 1810 | + } else { |
| 1811 | + price = `$${Math.round(inputPrice * 100) / 100}/$${Math.round(outputPrice * 100) / 100} in/out Mtoken`; |
| 1812 | + } |
| 1813 | + } |
| 1814 | + |
| 1815 | + const contextLength = model.context_length || 'Unknown'; |
| 1816 | + |
| 1817 | + return $((` |
| 1818 | + <div class="flex-container alignItemsBaseline" title="${DOMPurify.sanitize(model.id)}"> |
| 1819 | + <strong>${DOMPurify.sanitize(model.id)}</strong> | ${contextLength} ctx | <small>${price}</small> |
| 1820 | + </div> |
| 1821 | + `)); |
| 1822 | +} |
| 1823 | + |
| 1795 | 1824 | function calculateChutesCost() { |
| 1796 | 1825 | if (oai_settings.chat_completion_source !== chat_completion_sources.CHUTES) { |
| 1797 | 1826 | return; |