Skip to content

Commit

Permalink
-
Browse files Browse the repository at this point in the history
  • Loading branch information
OskarStark committed Oct 5, 2024
1 parent 1ceb4b3 commit 1167f40
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
20 changes: 13 additions & 7 deletions examples/reasoning-openai.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,23 @@
exit(1);
}


if (empty($_ENV['RUN_EXPENSIVE_EXAMPLES']) || false === filter_var($_ENV['RUN_EXPENSIVE_EXAMPLES'], FILTER_VALIDATE_BOOLEAN)) {
echo 'This example is marked as expensive and will not run unless RUN_EXPENSIVE_EXAMPLES is set to true.'.PHP_EOL;
exit(1);
}

$platform = new OpenAI(HttpClient::create(), $_ENV['OPENAI_API_KEY']);
$llm = new Gpt($platform, Version::o1Preview());

$prompt = <<<PROMPT
I want to build a Symfony app in PHP 8.2 that takes user questions and looks them
up in a database where they are mapped to answers. If there is close match, it
retrieves the matched answer. If there isn't, it asks the user to provide an answer
and stores the question/answer pair in the database. Make a plan for the directory
structure you'll need, then return each file in full. Only supply your reasoning
at the beginning and end, not throughout the code.
PROMPT;
I want to build a Symfony app in PHP 8.2 that takes user questions and looks them
up in a database where they are mapped to answers. If there is close match, it
retrieves the matched answer. If there isn't, it asks the user to provide an answer
and stores the question/answer pair in the database. Make a plan for the directory
structure you'll need, then return each file in full. Only supply your reasoning
at the beginning and end, not throughout the code.
PROMPT;

$response = (new Chain($llm))->call(new MessageBag(Message::ofUser($prompt)));

Expand Down
5 changes: 0 additions & 5 deletions examples/structured-output-math.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,6 @@
exit(1);
}

if (empty($_ENV['RUN_EXPENSIVE_EXAMPLES']) || false === filter_var($_ENV['RUN_EXPENSIVE_EXAMPLES'], FILTER_VALIDATE_BOOLEAN)) {
echo 'This example is marked as expensive and will not run unless RUN_EXPENSIVE_EXAMPLES is set to true.'.PHP_EOL;
exit(1);
}

$platform = new OpenAI(HttpClient::create(), $_ENV['OPENAI_API_KEY']);
$llm = new Gpt($platform, Version::gpt4oMini());
$serializer = new Serializer([new ObjectNormalizer()], [new JsonEncoder()]);
Expand Down

0 comments on commit 1167f40

Please sign in to comment.