PluginProbe
BotWriter – AI Writer & SEO Content Generator / trunk
BotWriter – AI Writer & SEO Content Generator vtrunk
3.4.10 3.4.9 3.4.8 3.4.7 3.4.6 3.4.4 3.4.2 3.4.1 3.4.0 3.3.9 3.3.8 3.3.7 3.3.6 3.3.5 3.3.4 3.3.3 3.3.2 3.3.1 3.3.0 3.2.8 trunk 1.3.0 1.3.1 1.3.2 1.3.3 All 51 releases
botwriter / includes / settings / groq.php

groq.php in BotWriter – AI Writer & SEO Content Generator trunk, at includes/settings/groq.php

196 lines 9.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Groq Provider Settings
4 *
5 * @package BotWriter
6 */
7
8 if (!defined('ABSPATH')) {
9 exit;
10 }
11
12 /**
13 * Get Groq provider info
14 */
15 function botwriter_get_groq_info() {
16 return [
17 'name' => 'Groq',
18 'description' => __('Ultra-fast LPU inference. The fastest AI API available - up to 10x faster than competitors!', 'botwriter'),
19 'website' => 'https://groq.com',
20 'api_url' => 'https://console.groq.com/keys',
21 'docs_url' => 'https://console.groq.com/docs/quickstart',
22 'pricing_url' => 'https://groq.com/pricing/',
23 'free_credits' => __('FREE TIER: Generous free usage with rate limits!', 'botwriter'),
24 'pricing_summary' => [
25 'llama-3.3-70b' => '$0.59/1M input, $0.79/1M output',
26 'llama-3.1-8b' => '$0.05/1M input, $0.08/1M output',
27 'llama-4-scout' => '$0.11/1M input, $0.34/1M output',
28 'mixtral-8x7b' => '$0.24/1M input, $0.24/1M output',
29 ],
30 'features' => [
31 __('🚀 FASTEST API - up to 1000+ tokens/second!', 'botwriter'),
32 __('Free tier with generous limits', 'botwriter'),
33 __('Custom LPU (Language Processing Unit) hardware', 'botwriter'),
34 __('Low latency - real-time applications', 'botwriter'),
35 __('Open-source models (Llama, Mixtral)', 'botwriter'),
36 __('Pay-as-you-go, no commitments', 'botwriter'),
37 ],
38 'pros' => [
39 __('Incredibly fast - 10x faster', 'botwriter'),
40 __('Very affordable pricing', 'botwriter'),
41 __('Great free tier', 'botwriter'),
42 __('No idle charges', 'botwriter'),
43 ],
44 'cons' => [
45 __('Only runs open-source models', 'botwriter'),
46 __('No image generation', 'botwriter'),
47 __('Smaller model selection', 'botwriter'),
48 ],
49 ];
50 }
51
52 /**
53 * Render Groq settings tab content
54 */
55 function botwriter_render_groq_settings($settings, $is_active) {
56 $info = botwriter_get_groq_info();
57 ?>
58 <div class="provider-config-section">
59 <div class="provider-config-card">
60 <h4><?php esc_html_e('API Configuration', 'botwriter'); ?></h4>
61 <div class="form-row">
62 <label><?php esc_html_e('API Key:', 'botwriter'); ?></label>
63 <div class="api-key-wrapper">
64 <input type="password" name="botwriter_groq_api_key" class="form-control api-key-input"
65 value="<?php echo esc_attr(botwriter_decrypt_api_key(get_option('botwriter_groq_api_key'))); ?>"
66 placeholder="gsk_...">
67 <button type="button" class="button toggle-api-key"><?php esc_html_e('Show', 'botwriter'); ?></button>
68 <button type="button" class="button button-secondary test-api-key" data-provider="groq">
69 <span class="dashicons dashicons-yes-alt"></span> <?php esc_html_e('Test API Key & Update Models', 'botwriter'); ?>
70 </button>
71 <span class="test-api-result"></span>
72 </div>
73 <p class="description"><?php esc_html_e('Your Groq API key starts with "gsk_"', 'botwriter'); ?></p>
74 <?php botwriter_api_key_transmission_notice(); ?>
75 </div>
76 <div class="form-row">
77 <label><?php esc_html_e('Model:', 'botwriter'); ?></label>
78 <div class="model-select-wrapper">
79 <?php botwriter_render_model_select('groq', 'botwriter_groq_model', $settings['botwriter_groq_model']); ?>
80 <button type="button" class="button button-secondary test-model" data-provider="groq">
81 <span class="dashicons dashicons-controls-play"></span> <?php esc_html_e('Test Model', 'botwriter'); ?>
82 </button>
83 <span class="test-model-result"></span>
84 </div>
85 </div>
86 </div>
87
88 <div class="provider-info-card highlight-speed">
89 <h4><span class="dashicons dashicons-info-outline"></span> <?php esc_html_e('How to Get Your API Key', 'botwriter'); ?></h4>
90 <div class="speed-banner">
91 <span class="dashicons dashicons-performance"></span>
92 <strong><?php esc_html_e('⚡ The FASTEST AI API on the planet!', 'botwriter'); ?></strong>
93 </div>
94 <ol class="setup-steps">
95 <li><?php esc_html_e('Go to', 'botwriter'); ?> <a href="https://console.groq.com/" target="_blank">console.groq.com</a> <?php esc_html_e('and sign up', 'botwriter'); ?></li>
96 <li><?php esc_html_e('Navigate to', 'botwriter'); ?> <a href="https://console.groq.com/keys" target="_blank"><?php esc_html_e('API Keys', 'botwriter'); ?></a></li>
97 <li><?php esc_html_e('Click "Create API Key"', 'botwriter'); ?></li>
98 <li><?php esc_html_e('Copy the key (starts with "gsk_") and paste it above', 'botwriter'); ?></li>
99 </ol>
100 <div class="info-tip success">
101 <span class="dashicons dashicons-yes-alt"></span>
102 <p><?php esc_html_e('No credit card required for the free tier! Start generating content immediately.', 'botwriter'); ?></p>
103 </div>
104 </div>
105
106 <div class="provider-pricing-card">
107 <h4><span class="dashicons dashicons-money-alt"></span> <?php esc_html_e('Pricing Overview', 'botwriter'); ?></h4>
108
109 <div class="pricing-highlight free-highlight">
110 <span class="free-credits-badge large"><?php esc_html_e('🎉 FREE TIER', 'botwriter'); ?></span>
111 <p><?php echo esc_html($info['free_credits']); ?></p>
112 </div>
113
114 <table class="pricing-table">
115 <thead>
116 <tr>
117 <th><?php esc_html_e('Model', 'botwriter'); ?></th>
118 <th><?php esc_html_e('Cost (per 1M tokens)', 'botwriter'); ?></th>
119 </tr>
120 </thead>
121 <tbody>
122 <?php foreach ($info['pricing_summary'] as $model => $price): ?>
123 <tr>
124 <td><code><?php echo esc_html($model); ?></code></td>
125 <td><?php echo esc_html($price); ?></td>
126 </tr>
127 <?php endforeach; ?>
128 </tbody>
129 </table>
130
131 <div class="cost-saving-tip">
132 <span class="dashicons dashicons-performance"></span>
133 <strong><?php esc_html_e('Speed Stats:', 'botwriter'); ?></strong>
134 <?php esc_html_e('Llama 3.3 70B: ~394 tokens/sec! Llama 3.1 8B: ~840 tokens/sec!', 'botwriter'); ?>
135 </div>
136
137 <p class="pricing-note">
138 <a href="<?php echo esc_url($info['pricing_url']); ?>" target="_blank" class="button button-secondary">
139 <span class="dashicons dashicons-external"></span> <?php esc_html_e('View Full Pricing', 'botwriter'); ?>
140 </a>
141 </p>
142 </div>
143
144 <div class="provider-features-card">
145 <h4><span class="dashicons dashicons-star-filled"></span> <?php esc_html_e('Features & Benefits', 'botwriter'); ?></h4>
146 <ul class="features-list">
147 <?php foreach ($info['features'] as $feature): ?>
148 <li><span class="dashicons dashicons-yes-alt"></span> <?php echo esc_html($feature); ?></li>
149 <?php endforeach; ?>
150 </ul>
151
152 <div class="pros-cons">
153 <div class="pros">
154 <h5><?php esc_html_e('Pros', 'botwriter'); ?></h5>
155 <ul>
156 <?php foreach ($info['pros'] as $pro): ?>
157 <li><span class="dashicons dashicons-plus-alt2"></span> <?php echo esc_html($pro); ?></li>
158 <?php endforeach; ?>
159 </ul>
160 </div>
161 <div class="cons">
162 <h5><?php esc_html_e('Cons', 'botwriter'); ?></h5>
163 <ul>
164 <?php foreach ($info['cons'] as $con): ?>
165 <li><span class="dashicons dashicons-minus"></span> <?php echo esc_html($con); ?></li>
166 <?php endforeach; ?>
167 </ul>
168 </div>
169 </div>
170 </div>
171
172 <div class="provider-links-card">
173 <h4><span class="dashicons dashicons-admin-links"></span> <?php esc_html_e('Useful Links', 'botwriter'); ?></h4>
174 <div class="links-grid">
175 <a href="<?php echo esc_url($info['api_url']); ?>" target="_blank" class="link-item">
176 <span class="dashicons dashicons-admin-network"></span>
177 <?php esc_html_e('Get API Key', 'botwriter'); ?>
178 </a>
179 <a href="<?php echo esc_url($info['docs_url']); ?>" target="_blank" class="link-item">
180 <span class="dashicons dashicons-book"></span>
181 <?php esc_html_e('Documentation', 'botwriter'); ?>
182 </a>
183 <a href="<?php echo esc_url($info['pricing_url']); ?>" target="_blank" class="link-item">
184 <span class="dashicons dashicons-money-alt"></span>
185 <?php esc_html_e('Pricing', 'botwriter'); ?>
186 </a>
187 <a href="https://console.groq.com/playground" target="_blank" class="link-item">
188 <span class="dashicons dashicons-controls-play"></span>
189 <?php esc_html_e('Playground', 'botwriter'); ?>
190 </a>
191 </div>
192 </div>
193 </div>
194 <?php
195 }
196