ChatGPT 架构

ChatGPT 架构 2.2.0

没有下载权限
XF 兼容性
  1. 2.2.x
摘要
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

这个插件提供了与ChatGPT工作相关的辅助函数。

它允许您为与ChatGPT一起工作的插件设置API密钥,并避免加载重复的依赖项。


开发人员使用指南

获取OpenAI API密钥
PHP:
$apiKey = \XF::options()->bsChatGptApiKey;
获取OpenAI API
PHP:
/** \Orhanerday\OpenAi\OpenAi $api */
$api = \XF::app()->container('chatGPT');
从GPT获得回复
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,
 ])
);
消息存储从主题中获取消息 – 从该话题加载机器人上下文。机器人的引用被转换为其正确上下文的消息。
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 – 生成一个消息数组,准备内容以供机器人使用(移除不必要的BB代码)。
PHP:
public function wrapMessage(string $content, string $role = 'user'): array
/*
returns [
    'content' => $preparedContent,
    'role' => $role
]
*/
准备内容 – 准备消息内容以便于机器人(移除不必要的 BB 代码)。
获取引语 – 解析文本中的引语,将其整理成方便的形式。
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)
    ]
]
*/
去除引号 – 从文本中移除引号。可以针对特定帖子或用户移除引号。
PHP:
public function removeQuotes(
string $text,
int $userId = null,
int $postId = null,
string $postType = 'post'
): string
作者
axtona
浏览
522
扩展类型
zip
文件大小
2 MB
首次发布
上次更新
评分 0.00 星 0 个评分
链接失效了吗? 发送消息 给 NP 团队,我们会尽快为您处理!
支持开发者 如果您对测试满意或项目已成功盈利,可点击「更多信息」按钮,通过购买来支持开发者!

最新更新

  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

来自 axtona 的更多资源

[ITD] 遮擋角色(_lite) A
一个简单 yet 强大的插件 设计 用于 论坛管理员
DEBtech Portal AI Suite Pro A
Portal AI Suite将您的XenForo论坛转变为现代门户。
广告套件专业版 A
现代广告和变现系统对于XenForo 2.3

相似的资源

[021] ChatGPT Reply Assistant A
this add-on uses ChatGPT to generate replies to posts automatically
浏览
466
已更新
[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.
浏览
443
已更新
[BS] ChatGPT Autoresponder A
allows you to embed a ChatGPT-based bot in the forum that will reply to your users in certain sectio
浏览
287
已更新
顶部