Skip to content

Commit

Permalink
refactor: rename supports methods (#13)
Browse files Browse the repository at this point in the history
* Rename method

* refactor: supports method names

---------

Co-authored-by: Christopher Hertel <mail@christopher-hertel.de>
  • Loading branch information
OskarStark and chr-hertel authored Sep 22, 2024
1 parent d67c5e7 commit 9668be9
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/Anthropic/Model/Claude.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ public function call(MessageBag $messages, array $options = []): Response
return new Response(new Choice($response['content'][0]['text']));
}

public function hasToolSupport(): bool
public function supportsToolCalling(): bool
{
return false; // it does, but implementation here is still open.
}

public function hasStructuredOutputSupport(): bool
public function supportsStructuredOutput(): bool
{
return false;
}
Expand Down
4 changes: 2 additions & 2 deletions src/Chain.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ public function call(MessageBag $messages, array $options = []): string|object
{
$llmOptions = $options;

if (!array_key_exists('tools', $llmOptions) && null !== $this->toolRegistry && $this->llm->hasToolSupport()) {
if (!array_key_exists('tools', $llmOptions) && null !== $this->toolRegistry && $this->llm->supportsToolCalling()) {
$llmOptions['tools'] = $this->toolRegistry->getMap();
}

if (array_key_exists('output_structure', $llmOptions) && null !== $this->responseFormatFactory && $this->llm->hasStructuredOutputSupport()) {
if (array_key_exists('output_structure', $llmOptions) && null !== $this->responseFormatFactory && $this->llm->supportsStructuredOutput()) {
$llmOptions['response_format'] = $this->responseFormatFactory->create($llmOptions['output_structure']);
unset($llmOptions['output_structure']);
}
Expand Down
4 changes: 2 additions & 2 deletions src/LanguageModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ interface LanguageModel
*/
public function call(MessageBag $messages, array $options = []): Response;

public function hasToolSupport(): bool;
public function supportsToolCalling(): bool;

public function hasStructuredOutputSupport(): bool;
public function supportsStructuredOutput(): bool;
}
6 changes: 3 additions & 3 deletions src/OpenAI/Model/Gpt.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@ public function call(MessageBag $messages, array $options = []): Response
return new Response(...array_map([$this, 'convertChoice'], $response['choices']));
}

public function hasToolSupport(): bool
public function supportsToolCalling(): bool
{
return true;
}

public function hasStructuredOutputSupport(): bool
public function supportsStructuredOutput(): bool
{
return $this->version->hasStructuredOutputSupport();
return $this->version->supportsStructuredOutput();
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/OpenAI/Model/Gpt/Version.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ enum Version: string
case GPT_4o = 'gpt-4o';
case GPT_4o_MINI = 'gpt-4o-mini';

public function hasStructuredOutputSupport(): bool
public function supportsStructuredOutput(): bool
{
return self::GPT_4o === $this || self::GPT_4o_MINI === $this;
}
Expand Down

0 comments on commit 9668be9

Please sign in to comment.