Vicidial Openai Script

Discussions about development of VICIDIAL and astGUIclient

Moderators: gerski, enjay, williamconley, Op3r, Staydog, gardo, mflorell, MJCoate, mcargile, Kumba, Michael_N

Vicidial Openai Script

Postby bbakirtas » Tue Dec 13, 2022 7:28 am

Everyone greetings.
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
Vicibox 9.0.1
VERSION: 2.14-738a
BUILD: 200210-1628
Intel Xeon X5650 12 Core HT 24 Core 2.90 Ghz
64 GB ECC Registered Memory
bbakirtas
 
Posts: 93
Joined: Thu Dec 06, 2012 3:35 am
Location: Turkey

Re: Vicidial Openai Script

Postby martinch » Wed Mar 15, 2023 5:33 pm

This is really nice! Inspired me to weave OpenAI / ChatGPT into ViCiDial myself!

I've done a demo of it if you're interested in seeing that here -> viewtopic.php?f=5&t=41656

I co-credited you in that piece as you inspired it. :) Thanks man.

Code: Select all
/* ==================================================================================
 * OpenAI Script for ViCiDial
 * 2023-03-04
 * Written by bbakirtas and Martin McCarthy (martinch)
 * This script allows ViCiDial to interface with OpenAI
 * ViCiDial is copyrighted to Matt Florell <vicidial@gmail.com> under the AGPLv2 license.
 *
 * Changelog;
 * 2023-01-02 - initial build.
 *================================================================================== */
Project Lead @ mDial -> https://github.com/TheBlode/mDial
martinch
 
Posts: 273
Joined: Thu Nov 15, 2018 9:14 am
Location: England, UK


Return to Development

Who is online

Users browsing this forum: No registered users and 21 guests