Skip to content
Snippets Groups Projects
Commit 8d62939b authored by Yghore's avatar Yghore
Browse files

ADD A PLACE FOR FUTUR FAKER

parent f8600b81
No related branches found
No related tags found
No related merge requests found
Pipeline #10909 passed
......@@ -4,10 +4,13 @@ class OPenAIGenerator
private string $question;
private string $code;
private string $test;
private string $usefaker;
private $faker;
public function __construct(string $question, bool $generateCode = true)
public function __construct(string $question, bool $generateCode = true, bool $useFaker = false)
{
$this->usefaker = $useFaker;
$this->question = $question;
if($generateCode)
{
......@@ -16,28 +19,53 @@ class OPenAIGenerator
$this->test = $this->genTest();
}
public function setFaker($faker) // SPECIFY CLASS OF FAKER FOR RETURN TYPE
{
// TO DOO SET FAKER CLASSE
$this->faker = $faker;
}
public function genCode(): string
{
$client = OpenAI::client('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');
$result = $client->completions()->create([
'model' => 'text-davinci-003',
'prompt' => "Create code for". $this->question . " in the java development language",
'max_tokens' => 10,
]);
return $result['choices'][0]['text'];
if(!$this->usefaker)
{
$client = OpenAI::client('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');
$result = $client->completions()->create([
'model' => 'text-davinci-003',
'prompt' => "Create code for". $this->question . " in the java development language",
'max_tokens' => 10,
]);
return $result['choices'][0]['text'];
}
else
{
// TO DOO
// USE CLASS FAKER FOR RETURN STRING
return "";
}
}
public function genTest(): string
{
$client = OpenAI::client('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');
$result = $client->completions()->create([
'model' => 'text-davinci-003',
'prompt' => "Create test for this code :" . $this->code . ", without import",
]);
return $result['choices'][0]['text'];
if(!$this->usefaker)
{
$client = OpenAI::client('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');
$result = $client->completions()->create([
'model' => 'text-davinci-003',
'prompt' => "Create test for this code :" . $this->code . ", without import",
]);
return $result['choices'][0]['text'];
}
else
{
// TO DOO
// USE CLASS FAKER FOR RETURN STRING
return "";
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment