File size: 18,364 Bytes
5f32fbd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
@extends('panel.layout.app')
@section('title', __('API Keys'))
@section('titlebar_actions', '')
@section('titlebar_subtitle', __('Integrate your own personal OpenAI API Key and generate AI content.'))
@section('additional_css')
    <link
        href="{{ custom_theme_url('/assets/libs/select2/select2.min.css') }}"
        rel="stylesheet"
    />
@endsection
@section('content')
    <!-- Page body -->
    <div class="py-10">
        <div class="container-xl">
            <div class="row">
                <div class="col-md-8 mx-auto">
                    <form
                        class="@if (view()->exists('panel.admin.custom.layout.panel.header-top-bar')) bg-[--tblr-bg-surface] px-8 py-10 rounded-[--tblr-border-radius] @endif"
                        id="settings_form"
                        onsubmit="return apiKeysSettingsSave();"
                        enctype="multipart/form-data"
                    >
                        <h3 class="mb-[25px] text-[20px]">{{ __('Api Keys Setting') }}</h3>
                        @switch(setting('default_ai_engine', 'openai'))
                            @case('openai')
                                <div class="row">
                                    @if ($app_is_demo)
                                        <div class="col-md-12">
                                            <div class="mb-3">
                                                <label class="form-label">{{ __('OpenAI Api Keys Secret') }}</label>
                                                <input
                                                    class="form-control"
                                                    id="openai_api_secret"
                                                    type="text"
                                                    name="openai_api_secret"
                                                    readonly
                                                    placeholder="Paste your API Key here. Need help? Learn more about API Keys"
                                                >
                                            </div>
                                        </div>
                                    @else
                                        <div class="col-md-12">
                                            <div
                                                class="form-control mb-3 border-none p-0 [&_.select2-selection--multiple]:!rounded-[--tblr-border-radius] [&_.select2-selection--multiple]:!border-[--tblr-border-color] [&_.select2-selection--multiple]:!p-[1em_1.23em]">
                                                <label class="form-label">{{ __('OpenAi API Secret') }}</label>
                                                <select
                                                    class="form-control select2"
                                                    id="api_keys"
                                                    name="api_keys"
                                                    multiple
                                                >
                                                    @foreach (explode(',', $list) ?? [] as $secret)
                                                        <option
                                                            value="{{ $secret }}"
                                                            @if ($secret) selected @endif
                                                        >{{ $secret }}
                                                        </option>
                                                    @endforeach
                                                </select>
                                                <x-alert class="mt-2">
                                                    <p>
                                                        {{ __('You can enter as much API KEY as you want. Click "Enter" after each api key.') }}
                                                    </p>
                                                </x-alert>
                                                <x-alert class="mt-2">
                                                    <p>
                                                        {{ __('Please ensure that your OpenAI API key is fully functional and billing defined on your OpenAI account.') }}
                                                    </p>
                                                </x-alert>
                                                <a
                                                    class="btn btn-primary mb-2 mt-2 w-full"
                                                    href="{{ route('dashboard.user.settings.openai.test') }}"
                                                    target="_blank"
                                                >
                                                    {{ __('After Saving Setting, Click Here to Test Your Api Keys') }}
                                                </a>
                                            </div>
                                        </div>
                                    @endif
                                </div>
                            @break

                            @case('anthropic')
                                <div class="row">
                                    @if ($app_is_demo)
                                        <div class="col-md-12">
                                            <div class="mb-3">
                                                <label class="form-label">{{ __('Anthropic Api Keys Secret') }}</label>
                                                <input
                                                    class="form-control"
                                                    id="anthropic_api_secret"
                                                    type="text"
                                                    name="anthropic_api_secret"
                                                    readonly
                                                    placeholder="Paste your API Key here. Need help? Learn more about API Keys"
                                                >
                                            </div>
                                        </div>
                                    @else
                                        <div class="col-md-12">
                                            <div
                                                class="form-control mb-3 border-none p-0 [&_.select2-selection--multiple]:!rounded-[--tblr-border-radius] [&_.select2-selection--multiple]:!border-[--tblr-border-color] [&_.select2-selection--multiple]:!p-[1em_1.23em]">
                                                <label class="form-label">{{ __('Anthropic API Secret') }}</label>
                                                <select
                                                    class="form-control select2"
                                                    id="anthropic_api_keys"
                                                    name="anthropic_api_keys"
                                                    multiple
                                                >
                                                    @foreach (explode(',', $anthropic_api_keys) ?? [] as $secret)
                                                        <option
                                                            value="{{ $secret }}"
                                                            @if ($secret) selected @endif
                                                        >{{ $secret }}
                                                        </option>
                                                    @endforeach
                                                </select>
                                                <x-alert class="mt-2">
                                                    <p>
                                                        {{ __('You can enter as much API KEY as you want. Click "Enter" after each api key.') }}
                                                    </p>
                                                </x-alert>
                                                <x-alert class="mt-2">
                                                    <p>
                                                        {{ __('Please ensure that your Anthropic API key is fully functional and billing defined on your Anthropic account.') }}
                                                    </p>
                                                </x-alert>
                                                <a
                                                    class="btn btn-primary mb-2 mt-2 w-full"
                                                    href="{{ route('dashboard.user.settings.anthropic.test') }}"
                                                    target="_blank"
                                                >
                                                    {{ __('After Saving Setting, Click Here to Test Your Api Keys') }}
                                                </a>
                                            </div>
                                        </div>
                                    @endif
                                </div>
                            @break

                            @case('gemini')
                                <div class="row">
                                    @if ($app_is_demo)
                                        <div class="col-md-12">
                                            <div class="mb-3">
                                                <label class="form-label">{{ __('Gemini Api Keys Secret') }}</label>
                                                <input
                                                    class="form-control"
                                                    id="gemini_api_keys"
                                                    type="text"
                                                    name="gemini_api_keys"
                                                    readonly
                                                    placeholder="Paste your API Key here. Need help? Learn more about API Keys"
                                                >
                                            </div>
                                        </div>
                                    @else
                                        <div class="col-md-12">
                                            <div
                                                class="form-control mb-3 border-none p-0 [&_.select2-selection--multiple]:!rounded-[--tblr-border-radius] [&_.select2-selection--multiple]:!border-[--tblr-border-color] [&_.select2-selection--multiple]:!p-[1em_1.23em]">
                                                <label class="form-label">{{ __('Gemini API Secret') }}</label>
                                                <select
                                                    class="form-control select2"
                                                    id="gemini_api_keys"
                                                    name="gemini_api_keys"
                                                    multiple
                                                >
                                                    @foreach (explode(',', $gemini_api_keys) ?? [] as $secret)
                                                        <option
                                                            value="{{ $secret }}"
                                                            @if ($secret) selected @endif
                                                        >{{ $secret }}
                                                        </option>
                                                    @endforeach
                                                </select>
                                                <x-alert class="mt-2">
                                                    <p>
                                                        {{ __('You can enter as much API KEY as you want. Click "Enter" after each api key.') }}
                                                    </p>
                                                </x-alert>
                                                <x-alert class="mt-2">
                                                    <p>
                                                        {{ __('Please ensure that your Anthropic API key is fully functional and billing defined on your Anthropic account.') }}
                                                    </p>
                                                </x-alert>
                                                <a
                                                    class="btn btn-primary mb-2 mt-2 w-full"
                                                    href="{{ route('dashboard.user.settings.gemini.test') }}"
                                                    target="_blank"
                                                >
                                                    {{ __('After Saving Setting, Click Here to Test Your Api Keys') }}
                                                </a>
                                            </div>
                                        </div>
                                    @endif
                                </div>
                            @break

                            @default
                                <div class="row">
                                    @if ($app_is_demo)
                                        <div class="col-md-12">
                                            <div class="mb-3">
                                                <label class="form-label">{{ __('OpenAI Api Keys Secret') }}</label>
                                                <input
                                                    class="form-control"
                                                    id="openai_api_secret"
                                                    type="text"
                                                    name="openai_api_secret"
                                                    readonly
                                                    placeholder="Paste your API Key here. Need help? Learn more about API Keys"
                                                >
                                            </div>
                                        </div>
                                    @else
                                        <div class="col-md-12">
                                            <div
                                                class="form-control mb-3 border-none p-0 [&_.select2-selection--multiple]:!rounded-[--tblr-border-radius] [&_.select2-selection--multiple]:!border-[--tblr-border-color] [&_.select2-selection--multiple]:!p-[1em_1.23em]">
                                                <label class="form-label">{{ __('OpenAi API Secret') }}</label>
                                                <select
                                                    class="form-control select2"
                                                    id="api_keys"
                                                    name="api_keys"
                                                    multiple
                                                >
                                                    @foreach (explode(',', $list) ?? [] as $secret)
                                                        <option
                                                            value="{{ $secret }}"
                                                            @if ($secret) selected @endif
                                                        >{{ $secret }}
                                                        </option>
                                                    @endforeach
                                                </select>
                                                <x-alert class="mt-2">
                                                    <p>
                                                        {{ __('You can enter as much API KEY as you want. Click "Enter" after each api key.') }}
                                                    </p>
                                                </x-alert>
                                                <x-alert class="mt-2">
                                                    <p>
                                                        {{ __('Please ensure that your OpenAI API key is fully functional and billing defined on your OpenAI account.') }}
                                                    </p>
                                                </x-alert>
                                                <a
                                                    class="btn btn-primary mb-2 mt-2 w-full"
                                                    href="{{ route('dashboard.user.settings.openai.test') }}"
                                                    target="_blank"
                                                >
                                                    {{ __('After Saving Setting, Click Here to Test Your Api Keys') }}
                                                </a>
                                            </div>
                                        </div>
                                    @endif
                                </div>

                        @endswitch

                        <button
                            class="btn btn-primary mt-5 w-full"
                            id="settings_button"
                            form="settings_form"
                        >
                            {{ __('Save') }}
                        </button>
                    </form>
                </div>
            </div>
        </div>
    </div>
@endsection
@push('script')
    <script src="{{ custom_theme_url('/assets/js/panel/settings.js') }}"></script>
    <script src="{{ custom_theme_url('/assets/libs/select2/select2.min.js') }}"></script>
@endpush