Skip to content

enhance client contract #31

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

Merged
merged 1 commit into from
Feb 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@

namespace DeepSeek\Contracts;

interface DeepseekClientContract
interface ClientContract
{
public static function build(string $apiKey): self;
public function run(): string;
public static function build(string $apiKey, ?string $baseUrl = null, ?int $timeout = null): self;
public function query(string $content, ?string $role = "user"): self;
public function getModelsList(): self;
public function withModel(?string $model = null): self;
public function withStream(bool $stream = true): self;
public function buildQuery(string $content, ?string $role = null): array;
}
11 changes: 5 additions & 6 deletions src/DeepSeekClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,18 @@

namespace DeepSeek;

use DeepSeek\Contracts\DeepseekClientContract;
use DeepSeek\Contracts\ClientContract;
use DeepSeek\Contracts\Models\ResultContract;
use DeepSeek\Enums\Requests\EndpointSuffixes;
use DeepSeek\Resources\Resource;
use Psr\Http\Client\ClientInterface;
use DeepSeek\Factories\ApiFactory;
use DeepSeek\Enums\Queries\QueryRoles;
use DeepSeek\Enums\Requests\QueryFlags;
use DeepSeek\Enums\Requests\HeaderFlags;
use DeepSeek\Enums\Configs\TemperatureValues;
use DeepSeek\Traits\Resources\{HasChat, HasCoder};

class DeepSeekClient implements DeepseekClientContract
class DeepSeekClient implements ClientContract
{
use HasChat, HasCoder;

Expand Down Expand Up @@ -113,14 +112,14 @@ public static function build(string $apiKey, ?string $baseUrl = null, ?int $time
* @param string|null $role
* @return self The current instance for method chaining.
*/
public function query(string $content, ?string $role = null): self
public function query(string $content, ?string $role = "user"): self
{
$this->queries[] = $this->buildQuery($content, $role);
return $this;
}

/**
* get list of available models ..
* get list of available models .
*
* @return self The current instance for method chaining.
*/
Expand Down Expand Up @@ -161,7 +160,7 @@ public function setTemperature(float $temperature): self
return $this;
}

protected function buildQuery(string $content, ?string $role = null): array
public function buildQuery(string $content, ?string $role = null): array
{
return [
'role' => $role ?: QueryRoles::USER->value,
Expand Down