1. Go to this page and download the library: Download paparascaldev/sidekick library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
paparascaldev / sidekick example snippets
$sidekick = new SidekickConversation();
$conversation = $sidekick->begin(
driver: new OpenAi(),
model: 'gtp-3.5-turbo',
systemPrompt: 'You can instruct the chatbot using this parameter'
);
$response = $conversation->sendMessage($user_input);
return response()->json($response);
public function index() {
// List Conversations
$sidekick = new SidekickChatManager();
return $sidekick->showAll();
}
public function show(Conversation $conversation) {
// show Conversation
$sidekick = new SidekickManager();
$sidekick->show($conversation);
}
public function delete(Conversation $conversation) {
// Delete Conversation
$sidekick = new SidekickManager();
return $sidekick->delete($conversation);
}
$sidekick = Sidekick::create(new OpenAi());
return $sidekick->complete()->sendMessage(
model: 'gpt-3.5-turbo',
systemPrompt: 'You an expert on fudge, answer user questions about fudge.',
message:"How is fudge made?"
);
$sidekick = Sidekick::create(new Mistral());
return $sidekick->embedding()->make(
model: 'mistral-embed',
input: 'This is sample content to embed'
);
$sidekick = Sidekick::create(new OpenAi());
$image = $sidekick->image()->make(
model:'dall-e-3',
prompt: $request->get('text_to_convert'),
width:'1024',
height:'1024'
);
// This is just a basic example of printing to screen.
// In a real world situation you may save it and then render out.
return "<img src='{$image['data'][0]['url']}' />";
$sidekick = Sidekick::create(new OpenAi());
$audio = $sidekick->audio()->fromText(
model: 'tts-1',
text: 'Have a nice day!'
);
// This is just a basic example of streaming it to the browser.
// In a real world situation you may save it and then reference the file
// instead.
header('Content-Type: audio/mpeg');
echo $audio