Browse Source

优化配置

peterguo 1 week ago
parent
commit
d388791ad3
2 changed files with 13 additions and 4 deletions
  1. 10 3
      app/Services/LLM/DeepSeekService.php
  2. 3 1
      config/llm.php

+ 10 - 3
app/Services/LLM/DeepSeekService.php

@@ -9,18 +9,25 @@ class DeepSeekService
 {
     public static function streamedResponseChat($message): void
     {
+        $llmConfig  = config('llm.deepseek');
         $headers = [
-            'Authorization' => 'Bearer ' . config('llm.deepseek.key'),
+            'Authorization' => 'Bearer ' . $llmConfig['key'],
             'Content-Type' => 'application/json',
         ];
         $body = [
-            'model' => 'deepseek-chat',
+            'model' => $llmConfig['model'],
             'messages' => $message,
             'stream' => true,
+            'max_tokens' => 1024,
+            'temperature' => 0.7,
+            'top_p' => 1,
+            "top_k"=> 50,
+            "frequency_penalty" => 0.5,
+            "n" => 1
         ];
 
         // 3. 调用DeepSeek流式API
-        $response = Http::withHeaders($headers)->timeout(300)->send('POST', 'https://api.deepseek.com/chat/completions', [
+        $response = Http::withHeaders($headers)->timeout(300)->send('POST', $llmConfig['base_url'] , [
             'json' => $body
         ]);
 

+ 3 - 1
config/llm.php

@@ -1,6 +1,8 @@
 <?php
 return [
     'deepseek' => [
-        'key' => env('DEEPSEEK_API_SECRET', ''),
+        'base_url' => env('LLM_MODEL_BASE_URL'),
+        'model' => env('LLM_MODEL_NAME'),
+        'key' => env('LLM_MODEL_KEY', ''),
     ]
 ];