Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit b0e076a

Browse filesBrowse files
committed
Update README
1 parent 4b9f108 commit b0e076a
Copy full SHA for b0e076a

File tree

Expand file treeCollapse file tree

1 file changed

+45
-0
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+45
-0
lines changed

‎README.md

Copy file name to clipboardExpand all lines: README.md
+45Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,51 @@ OpenAI::assertSent(Completions::class, function (string $method, array $paramete
126126

127127
For more testing examples, take a look at the [openai-php/client](https://github.com/openai-php/client#testing) repository.
128128

129+
## Laravel Pulse
130+
131+
This package provides a [Laravel Pulse](https://pulse.laravel.com) card to show statistics about your OpenAI usage.
132+
133+
The card supports two metrics:
134+
- **Requests per user**: Shows the number of requests per user.
135+
- **Requests per endpoint**: Shows the number of requests per endpoint.
136+
137+
### Installation
138+
139+
First, make sure Laravel Pulse is [installed](https://laravel.com/docs/10.x/pulse#installation).
140+
141+
Next, you need to register the recorder in your `config/pulse.php` file:
142+
143+
```php
144+
'recorders' => [
145+
// ...
146+
147+
\OpenAI\Laravel\Pulse\Recorders\OpenAIRequests::class => [
148+
'enabled' => env('PULSE_OPENAI_REQUESTS_ENABLED', true),
149+
'sample_rate' => env('PULSE_OPENAI_REQUESTS_SAMPLE_RATE', 1),
150+
'ignore' => [],
151+
'groups' => [
152+
'/(.*)\/(asst_|file-|ft-|msg_|run_|step_|thread_)[0-9a-zA-Z]*(.*)/' => '\1/\2*\3',
153+
],
154+
],
155+
],
156+
```
157+
158+
### Usage
159+
160+
Finally, add the card to your pulse `dashboard.blade.php` or any other Blade file.
161+
162+
```blade
163+
<livewire:openai.pulse.requests />
164+
```
165+
166+
If you want to be specific about the metric to show, you can pass it as `type`:
167+
168+
```blade
169+
<livewire:openai.pulse.requests type="endpoint" />
170+
171+
<livewire:openai.pulse.requests type="user" />
172+
```
173+
129174
---
130175

131176
OpenAI PHP for Laravel is an open-sourced software licensed under the **[MIT license](https://opensource.org/licenses/MIT)**.

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.