[021] ChatGPT Framework

[021] ChatGPT Framework 2.2.0

Keine Berechtigung zum Herunterladen
XF-Kompatibilität
  1. 2.2.x
Kurzbeschreibung
Enhance your ChatGPT experience with this add-on, offering helper functions and setting an API key for seamless integration. Fetch messages from threads, prepare bot content, and remove quotes efficiently.
Options.webp

This add-on provides helper functions for working with ChatGPT.

It allows you to set an API key for add-ons that work with ChatGPT and avoid loading duplicate dependencies.

Developer usage guide

Get the OpenAI API key
PHP:
$apiKey = \XF::options()->bsChatGptApiKey;
Get OpenAI API
PHP:
/** \Orhanerday\OpenAi\OpenAi $api */
$api = \XF::app()->container('chatGPT');
Get reply from ChatGPT
PHP:
use BS\ChatGPTBots\Response;
/** \Orhanerday\OpenAi\OpenAi $api */
$api = \XF::app()->container('chatGPT');
$messages = [
['role' => 'user', 'content' => 'Hello!']
];
$reply = Response::getReply(
$api->chat([
'model'             => 'gpt-3.5-turbo',
'messages'          => $messages,
'temperature'       => 1.0,
'max_tokens'        => 420,
'frequency_penalty' => 0,
'presence_penalty'  => 0,
 ])
);
Message repository

fetchMessagesFromThread – Loads the context for the bot from the topic. Bot quotes are transformed into his messages for the correct context.
PHP:
public function fetchMessagesFromThread(
Thread $thread,
int $stopPosition = null, // Thread post position to which to load the context
?User $assistant = null, // Bot user to mark his messages in context
bool $transformAssistantQuotesToMessages = true, // If false, bot message quote messages will not be transformed into his messages
int $startPosition = null, // Thread post position from which to load the context
bool $removeQuotesFromAssistantMessages = true // Removes user post quotes from bot posts
)
wrapMessage – Generates a message array, preparing content for the bot (removes unnecessary BB codes).
PHP:
public function wrapMessage(string $content, string $role = 'user'): array
/*
returns [
    'content' => $preparedContent,
    'role' => $role
]
*/
prepareContent – Prepare message content for the bot (removes unnecessary BB codes).
getQuotes – Parses quotes from the text, bringing it to a convenient form.
PHP:
public function getQuotes(
string $text,
int $userId = null, // filter quotes by user id
int $postId = null, // filter quotes by post id
string $postType = 'post' // post type in quotes
): array
/*
returns [
    [
        'post_id' => int|null,
        'user_id' => int|null,
        'content' => string|null, (quote content)
        'message' => string|null, (reply on quote, text which located below quote)
        'match'   => string (full quote match)
    ]
]
*/
removeQuotes – Remove quotes from the text. Can be remove quotes for specific posts or users.
PHP:
public function removeQuotes(
string $text,
int $userId = null,
int $postId = null,
string $postType = 'post'
): string
Autor
axtona
Ansichten
503
Erweiterungstyp
zip
Dateigröße
2 MB
Erste Veröffentlichung
Letzte Aktualisierung
Bewertungen 0.00 Sterne 0 Bewertungen
Link defekt? Nachricht senden an das NP-Team – wir helfen dir schnell!
Unterstütze den Entwickler Wenn du mit dem Test zufrieden bist oder mit deinem Projekt erfolgreich Geld verdient hast, klicke auf den Button Mehr Informationen, um den Entwickler durch einen Kauf zu unterstützen.

Neueste Aktualisierungen

  1. 2.2.0 - change log
    Fix: Exception when creating alias for class \BS\ChatGPTFramework\Enums\JsonSchema\Type...
  2. 2.1.1 - changelog
    Fix: Backward compatibility
  3. 1.6.0 - changelog
    Support for function calling

Weitere Ressourcen von axtona

StackFood Mehrrestaurant - Essenvermittlungsanwendung mit Laravel-Admin und Restaurant-Panel A
eine vollständige Mehrrestaurant-Food-Delivery-System entwickelt mit Hilfe von Laravel und Flutter-Konzeptualisierung.
 Schaltflächen A
Scroll Buttons ist ein stärkendes Interface-Add-On, das mit modernen Web-Trends kodiert wurde
Shack Open Graph Pro A
Dieses Erweiterung fügt Open Graph und Twitter-Karten-Tags zu Ihrem Site hinzu
Ansichten
450
Aktualisiert

Ähnliche Ressourcen

[021] ChatGPT Reply Assistant A
this add-on uses ChatGPT to generate replies to posts automatically
Ansichten
436
Aktualisiert
[021] Fools Day with ChatGPT A
This is an example of an article posted by a bot on the topic "Science" in a humorous style.
Ansichten
426
Aktualisiert
[021] Account switcher A
Once installed, you will need to set group permissions to use the switch account feature.
Ansichten
291
Aktualisiert
Oben