-
Notifications
You must be signed in to change notification settings - Fork 28
Add structured JSON parallel translation feature #51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
0b4b998
f0ef786
4adb6d6
8779662
4bfc7d7
2c3a916
12a134b
62d7183
83ebad8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -41,11 +41,13 @@ public function messages() | |
| */ | ||
| public function request(string $method, string $endpoint, array $data = []): array | ||
| { | ||
| $timeout = 1800; // 30 minutes | ||
|
|
||
| $response = Http::withHeaders([ | ||
| 'x-api-key' => $this->apiKey, | ||
| 'anthropic-version' => $this->apiVersion, | ||
| 'content-type' => 'application/json', | ||
| ])->$method("{$this->baseUrl}/{$endpoint}", $data); | ||
| ])->timeout($timeout)->$method("{$this->baseUrl}/{$endpoint}", $data); | ||
|
|
||
| if (! $response->successful()) { | ||
| $statusCode = $response->status(); | ||
|
|
@@ -283,6 +285,9 @@ public function requestStream(string $method, string $endpoint, array $data, cal | |
| 'accept: application/json', | ||
| ]; | ||
|
|
||
| // Set timeout to 30 minutes for streaming | ||
| $timeout = 1800; // 30 minutes | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. style: 일관성을 위해 중복된 주석과 변수 선언을 제거하는 것을 고려하세요. 44번 라인과 289번 라인이 동일한 값입니다 |
||
|
|
||
| // Initialize cURL | ||
| $ch = curl_init(); | ||
|
|
||
|
|
@@ -291,7 +296,7 @@ public function requestStream(string $method, string $endpoint, array $data, cal | |
| curl_setopt($ch, CURLOPT_RETURNTRANSFER, false); | ||
| curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); | ||
| curl_setopt($ch, CURLOPT_CUSTOMREQUEST, strtoupper($method)); | ||
| curl_setopt($ch, CURLOPT_TIMEOUT, 300); | ||
| curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); | ||
|
|
||
| if (strtoupper($method) !== 'GET') { | ||
| curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data)); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -30,10 +30,12 @@ public function __construct(string $apiKey) | |
| */ | ||
| public function request(string $method, string $endpoint, array $data = []): array | ||
| { | ||
| $timeout = 1800; // 30 minutes | ||
|
|
||
| $response = Http::withHeaders([ | ||
| 'Authorization' => 'Bearer '.$this->apiKey, | ||
| 'Content-Type' => 'application/json', | ||
| ])->$method("{$this->baseUrl}/{$endpoint}", $data); | ||
| ])->timeout($timeout)->$method("{$this->baseUrl}/{$endpoint}", $data); | ||
|
|
||
| if (! $response->successful()) { | ||
| throw new \Exception("OpenAI API error: {$response->body()}"); | ||
|
|
@@ -173,8 +175,10 @@ public function requestStream(string $method, string $endpoint, array $data, cal | |
| curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | ||
| curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); | ||
| curl_setopt($ch, CURLOPT_CUSTOMREQUEST, strtoupper($method)); | ||
| curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30); | ||
| curl_setopt($ch, CURLOPT_TIMEOUT, 120); | ||
|
|
||
| $timeout = 1800; // 30 minutes | ||
| curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30); // Keep connection timeout at 30 seconds | ||
| curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); | ||
|
Comment on lines
+179
to
+181
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. style: 타임아웃 값을 |
||
|
|
||
| if (strtoupper($method) !== 'GET') { | ||
| curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data)); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logic:
use_extended_thinking을 사용하려면 claude-3-7-sonnet 모델이 필요하지만, 12번 라인에서 claude-sonnet-4-20250514로 설정되어 있습니다. 이 옵션은 현재 모델에서는 작동하지 않습니다.