Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
APIChatGPT
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SIGNORELLI Lucas
APIChatGPT
Commits
8d62939b
Commit
8d62939b
authored
2 years ago
by
Yghore
Browse files
Options
Downloads
Patches
Plain Diff
ADD A PLACE FOR FUTUR FAKER
parent
f8600b81
No related branches found
No related tags found
No related merge requests found
Pipeline
#10909
passed
2 years ago
Stage: build
Stage: test
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
OpenAIGenerator.php
+44
-16
44 additions, 16 deletions
OpenAIGenerator.php
with
44 additions
and
16 deletions
OpenAIGenerator.php
+
44
−
16
View file @
8d62939b
...
...
@@ -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
""
;
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment