forked from CorentinTh/it-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix CorentinTh#1334
- Loading branch information
Showing
6 changed files
with
77 additions
and
0 deletions.
There are no files selected for viewing
15 changes: 15 additions & 0 deletions
15
src/tools/gpt-token-estimator/gpt-token-estimator.e2e.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { test, expect } from '@playwright/test'; | ||
|
||
test.describe('Tool - Gpt token estimator', () => { | ||
test.beforeEach(async ({ page }) => { | ||
await page.goto('/gpt-token-estimator'); | ||
}); | ||
|
||
test('Has correct title', async ({ page }) => { | ||
await expect(page).toHaveTitle('Gpt token estimator - IT Tools'); | ||
}); | ||
|
||
test('', async ({ page }) => { | ||
|
||
}); | ||
}); |
6 changes: 6 additions & 0 deletions
6
src/tools/gpt-token-estimator/gpt-token-estimator.service.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { expect, describe, it } from 'vitest'; | ||
// import { } from './gpt-token-estimator.service'; | ||
// | ||
// describe('gpt-token-estimator', () => { | ||
// | ||
// }) |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<script setup lang="ts"> | ||
import { GPTTokens } from 'gpt-tokens'; | ||
import TextareaCopyable from '@/components/TextareaCopyable.vue'; | ||
const inputText = ref(''); | ||
const outputTokenCosts = computed(() => { | ||
try { | ||
const usageInfo = new GPTTokens({ | ||
model: 'gpt-3.5-turbo-1106', | ||
messages: [ | ||
{ role: 'system', content: 'You are a helpful, pattern-following assistant that translates corporate jargon into plain English.' }, | ||
{ role: 'user', content: 'This late pivot means we don\'t have time to boil the ocean for the client deliverable.' }, | ||
], | ||
}); | ||
console.info('Used tokens: ', usageInfo.usedTokens); | ||
console.info('Used USD: ', usageInfo.usedUSD); | ||
} | ||
catch (e: any) { | ||
} | ||
}); | ||
</script> | ||
|
||
<template> | ||
<div> | ||
<c-input-text | ||
v-model:value="inputHtml" | ||
multiline raw-text | ||
placeholder="Your Html content..." | ||
rows="8" | ||
autofocus | ||
label="Your Html to convert (can paste from clipboard):" | ||
paste-html | ||
/> | ||
|
||
<n-divider /> | ||
|
||
<n-form-item label="Output markdown:"> | ||
<TextareaCopyable :value="outputMarkdown" /> | ||
</n-form-item> | ||
</div> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { CurrencyDollar } from '@vicons/tabler'; | ||
import { defineTool } from '../tool'; | ||
|
||
export const tool = defineTool({ | ||
name: 'GPT Token Estimator', | ||
path: '/gpt-token-estimator', | ||
description: 'OpenAI GPT Token Estimator', | ||
keywords: ['gpt', 'token', 'estimator'], | ||
component: () => import('./gpt-token-estimator.vue'), | ||
icon: CurrencyDollar, | ||
createdAt: new Date('2024-08-15'), | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters