A small script for use on the agent screen with Vicidial and openai. Open source development. A program that answers your questions to openai with the help of an API. The agent can ask questions in different languages and get answers with the powerful artificial intelligence of openai to make their job easier. Before installation, you need to install composer on opensuse. "sudo zypper install php-composer" and then create a file called openai in the htdocs folder. I got help from the open-ai github project when using the API.https://github.com/orhanerday/open-ai For installation, you can put the following code in the same directory as "composer require orhanerday/open-ai" as index.php. After that, you can add the script page from vicidial admin. After the installation is complete, you can create your own api code at beta.openai.com. I leave some links to get an idea of what you can do with openai. It is a very open topic for development, I hope it will be useful to you. Finally, this text was translated into English with openai.
https://beta.openai.com/examples
VERSION: 2.14-869a
BUILD: 221021-1038
index.php
- Code: Select all
<!DOCTYPE html>
<html>
<head>
<style>
.questiondiv {
border: 1px outset red;
background-color: lightblue;
text-align: left;
width: 50%;
}
</style>
</head>
<body><form action="" method="post">
Question:
<input type="text" name="question" id="question" size="85" value="<?php echo $_POST['question'];?>">
<input type="submit" value="Ask Question" name="submit">
</form>
<br>
<?php
error_reporting(0);
require __DIR__ . '/vendor/autoload.php'; // remove this line if you use a PHP Framework.
use Orhanerday\OpenAi\OpenAi;
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$question = $_POST['question'];
$open_ai_key = 'yourapicode';
$open_ai = new OpenAi($open_ai_key);
$result = $open_ai->completion([
"model" => "text-davinci-003",
"prompt" => $question,
'temperature' => 0.5,
'max_tokens' => 750
]);
$arr = (array) json_decode($result, true);
echo '<div class="questiondiv">';
echo $arr['choices']['0']['text'];
echo '</div>';
}
?>
</body>
</html>
Script
- Code: Select all
<iframe src="../openai/index.php" style="background-color:transparent;" scrolling="auto" frameborder="0" allowtransparency="true" id="popupFrame" name="popupFrame" width="--A--script_width--B--" height="--A--script_height--B--" STYLE="z-index:17"> </iframe>
https://github.com/bbakirtas/vicidial-openai
Screenshots;
https://github.com/bbakirtas/vicidial-o ... ialask.JPG
https://github.com/bbakirtas/vicidial-o ... server.JPG