Skip to content

Commit

Permalink
Code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
ddebowczyk committed Aug 10, 2024
1 parent 4dec204 commit beb7c6f
Show file tree
Hide file tree
Showing 117 changed files with 125 additions and 702 deletions.
2 changes: 1 addition & 1 deletion docs/cookbook/examples/troubleshooting/debugging.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class User {
}

$instructor = (new Instructor)->withClient(new OpenAIClient(
apiKey: Env::get('OPENAI_API_KEY'),// . 'invalid', // intentionally invalid API key
apiKey: Env::get('OPENAI_API_KEY'),// . 'invalid', // intentionally invalid API key
baseUri: Env::get('OPENAI_BASE_URI'),
));

Expand Down
2 changes: 1 addition & 1 deletion src-hub/Commands/GenerateDocs.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
namespace Cognesy\InstructorHub\Commands;

use Cognesy\Instructor\Utils\Color;
use Cognesy\Instructor\Utils\Cli\Color;
use Cognesy\InstructorHub\Core\Cli;
use Cognesy\InstructorHub\Core\Command;
use Cognesy\InstructorHub\Services\MintlifyDocGenerator;
Expand Down
2 changes: 1 addition & 1 deletion src-hub/Commands/ListAllExamples.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
namespace Cognesy\InstructorHub\Commands;

use Cognesy\Instructor\Utils\Color;
use Cognesy\Instructor\Utils\Cli\Color;
use Cognesy\InstructorHub\Core\Cli;
use Cognesy\InstructorHub\Core\Command;
use Cognesy\InstructorHub\Data\Example;
Expand Down
2 changes: 1 addition & 1 deletion src-hub/Commands/RunAllExamples.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
namespace Cognesy\InstructorHub\Commands;

use Cognesy\Instructor\Utils\Color;
use Cognesy\Instructor\Utils\Cli\Color;
use Cognesy\InstructorHub\Core\Cli;
use Cognesy\InstructorHub\Core\Command;
use Cognesy\InstructorHub\Services\Runner;
Expand Down
2 changes: 1 addition & 1 deletion src-hub/Commands/RunOneExample.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
namespace Cognesy\InstructorHub\Commands;

use Cognesy\Instructor\Utils\Color;
use Cognesy\Instructor\Utils\Cli\Color;
use Cognesy\InstructorHub\Core\Cli;
use Cognesy\InstructorHub\Core\Command;
use Cognesy\InstructorHub\Data\Example;
Expand Down
2 changes: 1 addition & 1 deletion src-hub/Commands/ShowExample.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
namespace Cognesy\InstructorHub\Commands;

use Cognesy\Instructor\Utils\Color;
use Cognesy\Instructor\Utils\Cli\Color;
use Cognesy\InstructorHub\Core\Cli;
use Cognesy\InstructorHub\Core\Command;
use Cognesy\InstructorHub\Services\ExampleRepository;
Expand Down
4 changes: 2 additions & 2 deletions src-hub/Core/Cli.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace Cognesy\InstructorHub\Core;

use Cognesy\Instructor\Utils\Color;
use Cognesy\Instructor\Utils\Console;
use Cognesy\Instructor\Utils\Cli\Color;
use Cognesy\Instructor\Utils\Cli\Console;

class Cli
{
Expand Down
2 changes: 1 addition & 1 deletion src-hub/Core/CliApp.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
namespace Cognesy\InstructorHub\Core;

use Cognesy\Instructor\Configuration\Configuration;
use Cognesy\Instructor\Utils\Color;
use Cognesy\Instructor\Utils\Cli\Color;

abstract class CliApp {
private CommandProvider $commandProvider;
Expand Down
2 changes: 1 addition & 1 deletion src-hub/Utils/CliMarkdown.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
namespace Cognesy\InstructorHub\Utils;

use cebe\markdown\GithubMarkdown;
use Cognesy\Instructor\Utils\Color as IColor;
use Cognesy\Instructor\Utils\Cli\Color as IColor;
use Cognesy\InstructorHub\Core\Cli;
use Toolkit\Cli\Color;
use Toolkit\Cli\Color\ColorTag;
Expand Down
2 changes: 1 addition & 1 deletion src-hub/Views/DocGenView.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Cognesy\InstructorHub\Views;

use Cognesy\Instructor\Utils\Color;
use Cognesy\Instructor\Utils\Cli\Color;
use Cognesy\InstructorHub\Core\Cli;
use Cognesy\InstructorHub\Data\Example;

Expand Down
2 changes: 1 addition & 1 deletion src-hub/Views/RunnerView.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Cognesy\InstructorHub\Views;

use Cognesy\Instructor\Utils\Color;
use Cognesy\Instructor\Utils\Cli\Color;
use Cognesy\InstructorHub\Core\Cli;
use Cognesy\InstructorHub\Data\Example;
use Exception;
Expand Down
2 changes: 1 addition & 1 deletion src/ApiClient/RequestConfig/CacheConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
namespace Cognesy\Instructor\ApiClient\RequestConfig;

use Closure;
use Cognesy\Instructor\Utils\Json;
use Cognesy\Instructor\Utils\Json\Json;
use League\Flysystem\Filesystem;
use League\Flysystem\Local\LocalFilesystemAdapter;
use RuntimeException;
Expand Down
2 changes: 1 addition & 1 deletion src/ApiClient/Requests/Traits/HandlesResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use Cognesy\Instructor\ApiClient\Responses\ApiResponse;
use Cognesy\Instructor\ApiClient\Responses\PartialApiResponse;
use Cognesy\Instructor\Utils\Json;
use Cognesy\Instructor\Utils\Json\Json;
use Exception;
use Saloon\Http\Response;

Expand Down
2 changes: 1 addition & 1 deletion src/ApiClient/Responses/ApiResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace Cognesy\Instructor\ApiClient\Responses;

use Cognesy\Instructor\Data\ToolCalls;
use Cognesy\Instructor\Utils\Json;
use Cognesy\Instructor\Utils\Json\Json;

class ApiResponse
{
Expand Down
2 changes: 1 addition & 1 deletion src/Clients/Anthropic/Traits/HandlesResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use Cognesy\Instructor\ApiClient\Responses\ApiResponse;
use Cognesy\Instructor\ApiClient\Responses\PartialApiResponse;
use Cognesy\Instructor\Utils\Json;
use Cognesy\Instructor\Utils\Json\Json;
use Saloon\Http\Response;

trait HandlesResponse
Expand Down
2 changes: 1 addition & 1 deletion src/Clients/Cohere/Traits/HandlesResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

use Cognesy\Instructor\ApiClient\Responses\ApiResponse;
use Cognesy\Instructor\ApiClient\Responses\PartialApiResponse;
use Cognesy\Instructor\Utils\Json;
use Cognesy\Instructor\Utils\Json\Json;
use Saloon\Http\Response;

trait HandlesResponse
Expand Down
2 changes: 1 addition & 1 deletion src/Clients/Gemini/Traits/HandlesResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

use Cognesy\Instructor\ApiClient\Responses\ApiResponse;
use Cognesy\Instructor\ApiClient\Responses\PartialApiResponse;
use Cognesy\Instructor\Utils\Json;
use Cognesy\Instructor\Utils\Json\Json;
use Saloon\Http\Response;

trait HandlesResponse
Expand Down
9 changes: 0 additions & 9 deletions src/Contracts/CanBuildRequest.php

This file was deleted.

2 changes: 1 addition & 1 deletion src/Contracts/CanGenerateResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use Cognesy\Instructor\ApiClient\Responses\ApiResponse;
use Cognesy\Instructor\Data\ResponseModel;
use Cognesy\Instructor\Utils\Result;
use Cognesy\Instructor\Utils\Result\Result;

interface CanGenerateResponse
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Cognesy\Instructor\Contracts\CanProvideMessage;
namespace Cognesy\Instructor\Contracts;

use Cognesy\Instructor\Data\Messages\Message;

Expand Down
31 changes: 0 additions & 31 deletions src/Core/Factories/InstructorFactory.php

This file was deleted.

19 changes: 0 additions & 19 deletions src/Core/Factories/StreamFactory.php

This file was deleted.

4 changes: 2 additions & 2 deletions src/Core/Response/ResponseGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
use Cognesy\Instructor\Exceptions\JsonParsingException;
use Cognesy\Instructor\Transformation\ResponseTransformer;
use Cognesy\Instructor\Utils\Chain;
use Cognesy\Instructor\Utils\Json;
use Cognesy\Instructor\Utils\Result;
use Cognesy\Instructor\Utils\Json\Json;
use Cognesy\Instructor\Utils\Result\Result;
use Cognesy\Instructor\Validation\ResponseValidator;
use Cognesy\Instructor\Validation\ValidationResult;
use Exception;
Expand Down
4 changes: 2 additions & 2 deletions src/Core/StreamResponse/PartialsGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
use Cognesy\Instructor\Transformation\ResponseTransformer;
use Cognesy\Instructor\Utils\Arrays;
use Cognesy\Instructor\Utils\Chain;
use Cognesy\Instructor\Utils\Json;
use Cognesy\Instructor\Utils\Result;
use Cognesy\Instructor\Utils\Json\Json;
use Cognesy\Instructor\Utils\Result\Result;
use Exception;
use Generator;

Expand Down
4 changes: 2 additions & 2 deletions src/Core/StreamResponse/Traits/ValidatesPartialResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
use Cognesy\Instructor\Exceptions\JsonParsingException;
use Cognesy\Instructor\Utils\Arrays;
use Cognesy\Instructor\Utils\Chain;
use Cognesy\Instructor\Utils\Json;
use Cognesy\Instructor\Utils\Result;
use Cognesy\Instructor\Utils\Json\Json;
use Cognesy\Instructor\Utils\Result\Result;
use Exception;

trait ValidatesPartialResponse
Expand Down
2 changes: 1 addition & 1 deletion src/Data/Messages/Traits/Message/HandlesCreation.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Cognesy\Instructor\Data\Messages\Traits\Message;

use Cognesy\Instructor\Contracts\CanProvideMessage\CanProvideMessage;
use Cognesy\Instructor\Contracts\CanProvideMessage;
use Cognesy\Instructor\Data\Messages\Message;
use Cognesy\Instructor\Data\Messages\Utils\Text;
use Exception;
Expand Down
2 changes: 1 addition & 1 deletion src/Data/Messages/Traits/Messages/HandlesCreation.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Cognesy\Instructor\Data\Messages\Traits\Messages;

use Cognesy\Instructor\Contracts\CanProvideMessage\CanProvideMessage;
use Cognesy\Instructor\Contracts\CanProvideMessage;
use Cognesy\Instructor\Contracts\CanProvideMessages;
use Cognesy\Instructor\Data\Messages\Message;
use Cognesy\Instructor\Data\Messages\Messages;
Expand Down
2 changes: 1 addition & 1 deletion src/Data/Messages/Utils/Text.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use BackedEnum;
use Closure;
use Cognesy\Instructor\Utils\Json;
use Cognesy\Instructor\Utils\Json\Json;

// TODO: this should be moved to a chain-like component, so the way we handle inputs can be customized
class Text
Expand Down
2 changes: 1 addition & 1 deletion src/Data/Traits/Example/HandlesConversion.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

use BackedEnum;
use Cognesy\Instructor\Data\Messages\Messages;
use Cognesy\Instructor\Utils\Json;
use Cognesy\Instructor\Utils\Json\Json;
use Cognesy\Instructor\Utils\TemplateUtil;

trait HandlesConversion
Expand Down
2 changes: 1 addition & 1 deletion src/Data/Traits/Example/HandlesCreation.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
namespace Cognesy\Instructor\Data\Traits\Example;

use Cognesy\Instructor\Utils\Json;
use Cognesy\Instructor\Utils\Json\Json;
use Exception;

trait HandlesCreation
Expand Down
3 changes: 1 addition & 2 deletions src/Deserialization/Deserializers/SymfonyDeserializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@

use Cognesy\Instructor\Deserialization\Contracts\CanDeserializeClass;
use Cognesy\Instructor\Deserialization\Exceptions\DeserializationException;
use Cognesy\Instructor\Utils\Json;
use Cognesy\Instructor\Utils\Json\Json;
use Symfony\Component\PropertyInfo\Extractor\PhpDocExtractor;
use Symfony\Component\PropertyInfo\Extractor\PhpStanExtractor;
use Symfony\Component\PropertyInfo\Extractor\ReflectionExtractor;
use Symfony\Component\PropertyInfo\PropertyInfoExtractor;
use Symfony\Component\Serializer\Encoder\JsonEncoder;
use Symfony\Component\Serializer\Normalizer\ArrayDenormalizer;
use Symfony\Component\Serializer\Normalizer\DateTimeNormalizer;
use Symfony\Component\Serializer\Normalizer\GetSetMethodNormalizer;
use Symfony\Component\Serializer\Normalizer\ObjectNormalizer;
use Symfony\Component\Serializer\Normalizer\PropertyNormalizer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Cognesy\Instructor\Deserialization\Exceptions;

use Cognesy\Instructor\Utils\Json;
use Cognesy\Instructor\Utils\Json\Json;

class DeserializationException extends \Exception
{
Expand Down
2 changes: 1 addition & 1 deletion src/Deserialization/ResponseDeserializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
use Cognesy\Instructor\Events\Response\ResponseDeserializationAttempt;
use Cognesy\Instructor\Events\Response\ResponseDeserializationFailed;
use Cognesy\Instructor\Events\Response\ResponseDeserialized;
use Cognesy\Instructor\Utils\Result;
use Cognesy\Instructor\Utils\Result\Result;
use Exception;

class ResponseDeserializer
Expand Down
2 changes: 1 addition & 1 deletion src/Events/ApiClient/ApiRequestInitiated.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
namespace Cognesy\Instructor\Events\ApiClient;

use Cognesy\Instructor\Events\Event;
use Cognesy\Instructor\Utils\Json;
use Cognesy\Instructor\Utils\Json\Json;
use Psr\Log\LogLevel;

class ApiRequestInitiated extends Event
Expand Down
2 changes: 1 addition & 1 deletion src/Events/ApiClient/ApiRequestSent.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
namespace Cognesy\Instructor\Events\ApiClient;

use Cognesy\Instructor\Events\Event;
use Cognesy\Instructor\Utils\Json;
use Cognesy\Instructor\Utils\Json\Json;
use Psr\Log\LogLevel;

class ApiRequestSent extends Event
Expand Down
2 changes: 1 addition & 1 deletion src/Events/ApiClient/ApiResponseReceived.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace Cognesy\Instructor\Events\ApiClient;

use Cognesy\Instructor\Events\Event;
use Cognesy\Instructor\Utils\Json;
use Cognesy\Instructor\Utils\Json\Json;

class ApiResponseReceived extends Event
{
Expand Down
2 changes: 1 addition & 1 deletion src/Events/ApiClient/ApiStreamConnected.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace Cognesy\Instructor\Events\ApiClient;

use Cognesy\Instructor\Events\Event;
use Cognesy\Instructor\Utils\Json;
use Cognesy\Instructor\Utils\Json\Json;

class ApiStreamConnected extends Event
{
Expand Down
2 changes: 1 addition & 1 deletion src/Events/ApiClient/ApiStreamResponseReceived.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
namespace Cognesy\Instructor\Events\ApiClient;

use Cognesy\Instructor\Utils\Json;
use Cognesy\Instructor\Utils\Json\Json;

class ApiStreamResponseReceived extends ApiResponseReceived
{
Expand Down
Loading

0 comments on commit beb7c6f

Please sign in to comment.