FakeClassificationGateway
class FakeClassificationGateway implements ClassificationGateway
Properties
| protected int | $currentResponseIndex | ||
| protected bool | $preventStrayClassifications |
Methods
Answer the given questions about the state.
Get the next response instance.
Marshal the given response into a full response instance.
Generate a fake choice answer.
Generate a fake score answer.
Generate random probabilities summing to one over the given keys.
Indicate that an exception should be thrown if any classification is not faked.
Details
at line 36
__construct(Closure|array $responses = [])
Create a classification gateway with fake responses.
at line 49
ClassificationResponse
classify(ClassificationProvider $provider, string $model, string|array $state, array $questions, int $timeout = 30, array $providerOptions = [], array $attachments = [])
Answer the given questions about the state.
at line 66
protected ClassificationResponse
nextResponse(ClassificationProvider $provider, string $model, ClassificationPrompt $prompt)
Get the next response instance.
at line 89
protected ClassificationResponse
marshalResponse(mixed $response, ClassificationProvider $provider, string $model, ClassificationPrompt $prompt)
Marshal the given response into a full response instance.
at line 129
protected Answer
generateFakeAnswer(Question $question)
Generate a shape-valid fake answer for the given question.
at line 144
protected ChoiceAnswer
fakeChoiceAnswer(array $options)
Generate a fake choice answer.
at line 160
protected ScoreAnswer
fakeScoreAnswer(array $levels)
Generate a fake score answer.
at line 175
protected array
randomDistribution(array $keys)
Generate random probabilities summing to one over the given keys.
at line 190
FakeClassificationGateway
preventStrayClassifications(bool $prevent = true)
Indicate that an exception should be thrown if any classification is not faked.
When the shared manager holds this fake gateway, the setting affects every request in the worker.