-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from outl1ne/pricing
feat: add cost metrics to OpenAI requests resource
- Loading branch information
Showing
18 changed files
with
299 additions
and
7 deletions.
There are no files selected for viewing
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 |
---|---|---|
|
@@ -6,6 +6,10 @@ This is currently an **unstable** package, breaking changes are to be expected. | |
|
||
If you need any features to be implemented or bump its priority in our backlog then feel free to make an inquiry via email at [email protected]. | ||
|
||
## Screenshots | ||
|
||
![Screenshot](resources/media/screenshot1.png) | ||
|
||
## Requirements | ||
|
||
- `php: >=8.1` | ||
|
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
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,102 @@ | ||
{ | ||
"models": { | ||
"gpt-4-0125-preview": { | ||
"input": 0.01, | ||
"output": 0.03 | ||
}, | ||
"gpt-4-1106-preview": { | ||
"input": 0.01, | ||
"output": 0.03 | ||
}, | ||
"gpt-4-1106-vision-preview": { | ||
"input": 0.01, | ||
"output": 0.03 | ||
}, | ||
"gpt-4": { | ||
"input": 0.03, | ||
"output": 0.06 | ||
}, | ||
"gpt-4-32k": { | ||
"input": 0.06, | ||
"output": 0.12 | ||
}, | ||
"gpt-3.5-turbo-0125": { | ||
"input": 0.0005, | ||
"output": 0.0015 | ||
}, | ||
"gpt-3.5-turbo-instruct": { | ||
"input": 0.0015, | ||
"output": 0.002 | ||
}, | ||
"gpt-3.5-turbo-1106": { | ||
"input": 0.001, | ||
"output": 0.002 | ||
}, | ||
"gpt-3.5-turbo-0613": { | ||
"input": 0.0015, | ||
"output": 0.002 | ||
}, | ||
"gpt-3.5-turbo-16k-0613": { | ||
"input": 0.003, | ||
"output": 0.004 | ||
}, | ||
"gpt-3.5-turbo-0301": { | ||
"input": 0.0015, | ||
"output": 0.002 | ||
} | ||
}, | ||
"assistants": { | ||
"code-interpreter": { | ||
"input": 0.03 | ||
}, | ||
"retrieval": { | ||
"input": 0.2 | ||
} | ||
}, | ||
"fine-tuning": { | ||
"gpt-3.5-turbo": { | ||
"training": 0.008, | ||
"input": 0.003, | ||
"output": 0.006 | ||
}, | ||
"davinci-002": { | ||
"training": 0.006, | ||
"input": 0.012, | ||
"output": 0.012 | ||
}, | ||
"babbage-002": { | ||
"training": 0.0004, | ||
"input": 0.0016, | ||
"output": 0.0016 | ||
} | ||
}, | ||
"embedding": { | ||
"text-embedding-3-small": 0.00002, | ||
"text-embedding-3-large": 0.00013, | ||
"ada-v2": 0.0001 | ||
}, | ||
"base-models": { | ||
"davinci-002": 0.002, | ||
"babbage-002": 0.0004 | ||
}, | ||
"image": { | ||
"dall-e-3": { | ||
"standard-1024-1024": 0.04, | ||
"standard-1024-1792": 0.08, | ||
"standard-1792-1024": 0.08, | ||
"hd-1024-1024": 0.08, | ||
"hd-1024-1792": 0.12, | ||
"hd-1792-1024": 0.12 | ||
}, | ||
"dall-e-2": { | ||
"1024-1024": 0.02, | ||
"512-512": 0.018, | ||
"256-256": 0.016 | ||
} | ||
}, | ||
"audio": { | ||
"whisper": 0.006, | ||
"tts": 0.015, | ||
"tts-hd": 0.03 | ||
} | ||
} |
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
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
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
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
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
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
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,56 @@ | ||
<?php | ||
|
||
namespace Outl1ne\NovaOpenAI\Nova; | ||
|
||
use Laravel\Nova\Nova; | ||
use Laravel\Nova\Metrics\Trend; | ||
use Laravel\Nova\Http\Requests\NovaRequest; | ||
use Outl1ne\NovaOpenAI\Models\OpenAIRequest; | ||
|
||
class CostMetrics extends Trend | ||
{ | ||
/** | ||
* Calculate the value of the metric. | ||
* | ||
* @param \Laravel\Nova\Http\Requests\NovaRequest $request | ||
* @return mixed | ||
*/ | ||
public function calculate(NovaRequest $request) | ||
{ | ||
return $this->sumByDays($request, OpenAIRequest::class, 'cost')->prefix('$'); | ||
} | ||
|
||
/** | ||
* Get the ranges available for the metric. | ||
* | ||
* @return array | ||
*/ | ||
public function ranges() | ||
{ | ||
return [ | ||
30 => Nova::__('30 Days'), | ||
60 => Nova::__('60 Days'), | ||
90 => Nova::__('90 Days'), | ||
]; | ||
} | ||
|
||
/** | ||
* Determine the amount of time the results of the metric should be cached. | ||
* | ||
* @return \DateTimeInterface|\DateInterval|float|int|null | ||
*/ | ||
public function cacheFor() | ||
{ | ||
return now()->addMinutes(1); | ||
} | ||
|
||
/** | ||
* Get the URI key for the metric. | ||
* | ||
* @return string | ||
*/ | ||
public function uriKey() | ||
{ | ||
return 'cost-metrics'; | ||
} | ||
} |
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
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
Oops, something went wrong.