Hi Team,
I am new to ChatGPT and OpenAI… Can we build OpenAI for PHP based website?
If yes can i get tutorial link or documentation to implement for my specific website which is based on PHP.
Regards,
Piyush Raval
Hi Team,
I am new to ChatGPT and OpenAI… Can we build OpenAI for PHP based website?
If yes can i get tutorial link or documentation to implement for my specific website which is based on PHP.
Regards,
Piyush Raval
Hi,
Thanks a lot for reply and guide.
I just checked below sample code
<?php require __DIR__ . '/vendor/autoload.php'; // remove this line if you use a PHP Framework. use Orhanerday\OpenAi\OpenAi; $open_ai_key = getenv('OPENAI_API_KEY'); $open_ai = new OpenAi($open_ai_key); $chat = $open_ai->chat([ 'model' => 'gpt-3.5-turbo', 'messages' => [ [ "role" => "system", "content" => "You are a helpful assistant." ], [ "role" => "user", "content" => "Who won the world series in 2020?" ], [ "role" => "assistant", "content" => "The Los Angeles Dodgers won the World Series in 2020." ], [ "role" => "user", "content" => "Where was it played?" ], ], 'temperature' => 1.0, 'max_tokens' => 4000, 'frequency_penalty' => 0, 'presence_penalty' => 0, ]); var_dump($chat); echo "Hi @rajuroyal ,
Can you please share links?
did you just use chatgpt to generate a forum reply? because these links are all broken.
There is no “official” open ai PHP client, there are a bunch of community ones.
this is not helpful at all
Your question is too general.
If you say exactly what you are looking to achieve with chatgpt I think I can help you.
In any case, here is some initial basic information that I hope will help you and others as a starting point for integrating gpt into a website.
In general, to create a chatbox for a php website, I came across 3 methods based on an ajax call to php script that has a simple curl command according to the chatgpt-3.5 documentation.
I’m sure there are a lot of ways and tricks that I don’t know about, I’m sharing what I know so far and that works for me after many attempts to reach the most effective chat for my sites:
instructions Tip - Provide in your gpt instructions relevant links that you have on the site or even html id tags and make them clickable in his answer in the frontend before displaying them in the conversation window.
I previously came across a post here on the forum about a conversation on this topic of how to extract massive information according to the user’s question and provide the relevant information to gpt in a prompt, but this is no longer related to working with gpt but independent analysis and extraction.
May checkout the PHP Client I’ve built.
No links allowed here, but you will find it, when searching for “openai-php/client” on packagist.