1. Go to this page and download the library: Download postare/filament-model-ai 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/ */
postare / filament-model-ai example snippets
// Configuration for Postare/ModelAi
return [
// OpenAI API Key
'openai_api_key' => env('OPENAI_API_KEY', ''),
// Default OpenAI Model (refer to https://platform.openai.com/docs/models)
'default_openai_model' => 'gpt-3.5-turbo-1106',
// Disable selecting OpenAI Model
'disable_openai_model_selection' => false,
// Slug for the Model AI page
'slug' => 'model-ai',
// Filament Navigation Group (refer to translation file for label or disable it)
'use_navigation_group' => true,
// Model Settings
'eloquent_model' => \App\Models\User::class, // Laravel model to use
'selected_columns' => [ // Selected columns from the model
'name',
'email',
],
'field_label' => 'name', // Field to use as a label
'field_id' => 'id', // Field to use as an ID
// System Prompt
'system_prompt' => 'You are a helpful assistant. Consider the data at the end of this message as context and answer the questions I will ask you later.',
// Predefined Prompts (feel free to add, remove, or modify them)
'predefined_prompts' => [
[
'name' => 'SEO', // Prompt name
'prompt' => 'Generate a title and an SEO-oriented meta description based on the provided data.', // Prompt instruction
],
[
'name' => 'Facebook Post', // Prompt name
'prompt' => 'Create a Facebook post, avoiding lists.', // Prompt instruction
],
],
];
$response = ModelAi::chat()
// Optional: Override the default OpenAI model specified in the configuration file
->openai_model('gpt-4-1106-preview')
// Optional
->system('your name is GeePeeTee, and you speak in a very 16th-century, very polished way.')
// Optional, model to use:
// params: model, id, selected_columns
->model(\App\Models\User::class, 1, ['name', 'email', 'email_verified_at'])
// Mandatory, prompt to use:
->prompt("tell me about this user")
// Mandatory, send the request
->send();
// Pray tell, thou hath sought to gain insight into the individual known by the appellation "Francesco". This gentle soul didst establish an entity of digital correspondence through "inerba@******.com", yet verily, the verification of such an electronic missive remains a quest unfulfilled.
$response = ModelAi::chat()
->prompt("make up your own dad joke")
->send();
// Why don't skeletons fight each other? They don't have the guts.