Skip to content

Commit

Permalink
composer.json
Browse files Browse the repository at this point in the history
  • Loading branch information
ddebowczyk committed Jun 7, 2024
1 parent bcd087d commit 8e54f8f
Show file tree
Hide file tree
Showing 27 changed files with 62 additions and 58 deletions.
4 changes: 4 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "cognesy/instructor-php",
"description": "Structured data extraction in PHP, powered by LLMs",
"keywords": ["llm", "language models", "inference", "ai", "genai", "openai", "anthropic", "cohere", "ollama", "structured output", "semantic processing", "automation", "data processing", "data extraction"],
"type": "library",
"license": "MIT",
"autoload": {
Expand Down Expand Up @@ -62,5 +63,8 @@
"phpstan/phpdoc-parser": "^1.29",
"psr/log": "^3.0",
"monolog/monolog": "^3.6"
},
"scripts": {
"tests": "@php vendor/bin/pest"
}
}
4 changes: 2 additions & 2 deletions src/Clients/Anthropic/AnthropicApiRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
namespace Cognesy\Instructor\Clients\Anthropic;

use Cognesy\Instructor\ApiClient\Requests\ApiRequest;
use Override;


class AnthropicApiRequest extends ApiRequest
{
Expand All @@ -14,7 +14,7 @@ class AnthropicApiRequest extends ApiRequest

/////////////////////////////////////////////////////////////////////////////////////////////////

#[Override]

protected function defaultBody(): array {
return array_filter(
array_merge(
Expand Down
4 changes: 2 additions & 2 deletions src/Clients/Anthropic/AnthropicClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use Cognesy\Instructor\ApiClient\ApiConnector;
use Cognesy\Instructor\Enums\Mode;
use Cognesy\Instructor\Events\EventDispatcher;
use Override;


class AnthropicClient extends ApiClient
{
Expand Down Expand Up @@ -34,7 +34,7 @@ public function __construct(
));
}

#[Override]

public function getModeRequestClass(Mode $mode = null) : string {
return AnthropicApiRequest::class;
}
Expand Down
6 changes: 3 additions & 3 deletions src/Clients/Anthropic/AnthropicConnector.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@
namespace Cognesy\Instructor\Clients\Anthropic;

use Cognesy\Instructor\ApiClient\ApiConnector;
use Override;

use Saloon\Contracts\Authenticator;
use Saloon\Http\Auth\HeaderAuthenticator;

class AnthropicConnector extends ApiConnector
{
protected string $baseUrl = 'https://api.anthropic.com/v1';

#[Override]

protected function defaultAuth() : Authenticator {
return new HeaderAuthenticator($this->apiKey, 'x-api-key');
}

#[Override]

protected function defaultHeaders(): array {
return [
'content-type' => 'application/json',
Expand Down
6 changes: 3 additions & 3 deletions src/Clients/Anthropic/Traits/HandlesStreamData.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@

namespace Cognesy\Instructor\Clients\Anthropic\Traits;

use Override;


trait HandlesStreamData
{
#[Override]

protected function isDone(string $data): bool {
return $data === 'event: message_stop';
}

#[Override]

protected function getData(string $data): string {
if (str_starts_with($data, 'data:')) {
return trim(substr($data, 5));
Expand Down
4 changes: 2 additions & 2 deletions src/Clients/Anyscale/AnyscaleClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use Cognesy\Instructor\Clients\OpenAI\Traits\HandlesStreamData;
use Cognesy\Instructor\Enums\Mode;
use Cognesy\Instructor\Events\EventDispatcher;
use Override;


class AnyscaleClient extends ApiClient
{
Expand Down Expand Up @@ -35,7 +35,7 @@ public function __construct(
));
}

#[Override]

public function getModeRequestClass(Mode $mode = null) : string {
return AnyscaleApiRequest::class;
}
Expand Down
4 changes: 2 additions & 2 deletions src/Clients/Anyscale/AnyscaleConnector.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
namespace Cognesy\Instructor\Clients\Anyscale;

use Cognesy\Instructor\ApiClient\ApiConnector;
use Override;

use Saloon\Contracts\Authenticator;
use Saloon\Http\Auth\TokenAuthenticator;

class AnyscaleConnector extends ApiConnector
{
protected string $baseUrl = 'https://api.endpoints.anyscale.com/v1';

#[Override]

protected function defaultAuth() : Authenticator {
return new TokenAuthenticator($this->apiKey);
}
Expand Down
4 changes: 2 additions & 2 deletions src/Clients/Azure/AzureClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use Cognesy\Instructor\Clients\OpenAI\Traits\HandlesStreamData;
use Cognesy\Instructor\Enums\Mode;
use Cognesy\Instructor\Events\EventDispatcher;
use Override;


class AzureClient extends ApiClient
{
Expand Down Expand Up @@ -41,7 +41,7 @@ public function __construct(
$this->queryParams = ['api-version' => $apiVersion];
}

#[Override]

public function getModeRequestClass(Mode $mode = null) : string {
return AzureApiRequest::class;
}
Expand Down
6 changes: 3 additions & 3 deletions src/Clients/Azure/AzureConnector.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
namespace Cognesy\Instructor\Clients\Azure;

use Cognesy\Instructor\ApiClient\ApiConnector;
use Override;

use Saloon\Contracts\Authenticator;
use Saloon\Http\Auth\HeaderAuthenticator;

Expand All @@ -27,12 +27,12 @@ public function __construct(
$this->deploymentId = $deploymentId;
}

#[Override]

public function resolveBaseUrl(): string {
return "https://{$this->resourceName}.{$this->baseUrl}/openai/deployments/{$this->deploymentId}";
}

#[Override]

protected function defaultAuth() : Authenticator {
return new HeaderAuthenticator($this->apiKey, 'api-key');
}
Expand Down
4 changes: 2 additions & 2 deletions src/Clients/Cohere/CohereApiRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
namespace Cognesy\Instructor\Clients\Cohere;

use Cognesy\Instructor\ApiClient\Requests\ApiRequest;
use Override;


class CohereApiRequest extends ApiRequest
{
Expand All @@ -12,7 +12,7 @@ class CohereApiRequest extends ApiRequest

protected string $defaultEndpoint = '/chat';

#[Override]

protected function defaultBody(): array {
return array_filter(
array_merge(
Expand Down
4 changes: 2 additions & 2 deletions src/Clients/Cohere/CohereConnector.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
use Cognesy\Instructor\ApiClient\ApiConnector;
use Saloon\Contracts\Authenticator;
use Saloon\Http\Auth\TokenAuthenticator;
use Override;


class CohereConnector extends ApiConnector
{
protected string $baseUrl = 'https://api.cohere.com/v1/';

#[Override]

protected function defaultAuth() : Authenticator {
return new TokenAuthenticator($this->apiKey);
}
Expand Down
6 changes: 3 additions & 3 deletions src/Clients/Cohere/Traits/HandlesStreamData.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@

namespace Cognesy\Instructor\Clients\Cohere\Traits;

use Override;


trait HandlesStreamData
{
#[Override]

protected function isDone(string $data): bool {
return $data === '[DONE]';
}

#[Override]

protected function getData(string $data): string {
return trim($data);
}
Expand Down
4 changes: 2 additions & 2 deletions src/Clients/FireworksAI/FireworksAIClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use Cognesy\Instructor\Clients\OpenAI\Traits\HandlesStreamData;
use Cognesy\Instructor\Enums\Mode;
use Cognesy\Instructor\Events\EventDispatcher;
use Override;


class FireworksAIClient extends ApiClient
{
Expand Down Expand Up @@ -35,7 +35,7 @@ public function __construct(
));
}

#[Override]

public function getModeRequestClass(Mode $mode = null) : string {
return FireworksAIApiRequest::class;
}
Expand Down
4 changes: 2 additions & 2 deletions src/Clients/FireworksAI/FireworksAIConnector.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
namespace Cognesy\Instructor\Clients\FireworksAI;

use Cognesy\Instructor\ApiClient\ApiConnector;
use Override;

use Saloon\Contracts\Authenticator;
use Saloon\Http\Auth\TokenAuthenticator;

class FireworksAIConnector extends ApiConnector
{
protected string $baseUrl = 'https://api.fireworks.ai/inference/v1';

#[Override]

protected function defaultAuth() : Authenticator {
return new TokenAuthenticator($this->apiKey);
}
Expand Down
4 changes: 2 additions & 2 deletions src/Clients/Groq/GroqClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use Cognesy\Instructor\Clients\OpenAI\Traits\HandlesStreamData;
use Cognesy\Instructor\Enums\Mode;
use Cognesy\Instructor\Events\EventDispatcher;
use Override;


class GroqClient extends ApiClient
{
Expand Down Expand Up @@ -36,7 +36,7 @@ public function __construct(
));
}

#[Override]

public function getModeRequestClass(Mode $mode = null) : string {
return GroqApiRequest::class;
}
Expand Down
4 changes: 2 additions & 2 deletions src/Clients/Groq/GroqConnector.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
namespace Cognesy\Instructor\Clients\Groq;

use Cognesy\Instructor\ApiClient\ApiConnector;
use Override;

use Saloon\Contracts\Authenticator;
use Saloon\Http\Auth\TokenAuthenticator;

class GroqConnector extends ApiConnector
{
protected string $baseUrl = 'https://api.groq.com/openai/v1';

#[Override]

protected function defaultAuth() : Authenticator {
return new TokenAuthenticator($this->apiKey);
}
Expand Down
4 changes: 2 additions & 2 deletions src/Clients/Mistral/MistralClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use Cognesy\Instructor\Clients\OpenAI\Traits\HandlesStreamData;
use Cognesy\Instructor\Enums\Mode;
use Cognesy\Instructor\Events\EventDispatcher;
use Override;


class MistralClient extends ApiClient
{
Expand Down Expand Up @@ -37,7 +37,7 @@ public function __construct(
));
}

#[Override]

public function getModeRequestClass(Mode $mode = null) : string {
return MistralApiRequest::class;
}
Expand Down
4 changes: 2 additions & 2 deletions src/Clients/Mistral/MistralConnector.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
namespace Cognesy\Instructor\Clients\Mistral;

use Cognesy\Instructor\ApiClient\ApiConnector;
use Override;

use Saloon\Contracts\Authenticator;
use Saloon\Http\Auth\TokenAuthenticator;

class MistralConnector extends ApiConnector
{
protected string $baseUrl = 'https://api.mistral.ai/v1';

#[Override]

protected function defaultAuth() : Authenticator {
return new TokenAuthenticator($this->apiKey);
}
Expand Down
4 changes: 2 additions & 2 deletions src/Clients/Ollama/OllamaClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use Cognesy\Instructor\Clients\OpenAI\Traits\HandlesStreamData;
use Cognesy\Instructor\Enums\Mode;
use Cognesy\Instructor\Events\EventDispatcher;
use Override;


class OllamaClient extends ApiClient
{
Expand Down Expand Up @@ -35,7 +35,7 @@ public function __construct(
));
}

#[Override]

public function getModeRequestClass(Mode $mode = null) : string {
return OllamaApiRequest::class;
}
Expand Down
4 changes: 2 additions & 2 deletions src/Clients/Ollama/OllamaConnector.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
namespace Cognesy\Instructor\Clients\Ollama;

use Cognesy\Instructor\ApiClient\ApiConnector;
use Override;

use Saloon\Contracts\Authenticator;
use Saloon\Http\Auth\TokenAuthenticator;

Expand All @@ -21,7 +21,7 @@ public function __construct(
parent::__construct($apiKey, $baseUrl, $connectTimeout, $requestTimeout, $metadata, $senderClass);
}

#[Override]

protected function defaultAuth() : Authenticator {
return new TokenAuthenticator($this->apiKey);
}
Expand Down
4 changes: 2 additions & 2 deletions src/Clients/OpenAI/OpenAIClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use Cognesy\Instructor\ApiClient\ApiConnector;
use Cognesy\Instructor\Enums\Mode;
use Cognesy\Instructor\Events\EventDispatcher;
use Override;


class OpenAIClient extends ApiClient
{
Expand Down Expand Up @@ -36,7 +36,7 @@ public function __construct(
));
}

#[Override]

public function getModeRequestClass(Mode $mode = null) : string {
return OpenAIApiRequest::class;
}
Expand Down
Loading

0 comments on commit 8e54f8f

Please sign in to comment.