ChatGPT 架构

ChatGPT 架构 2.2.0

没有下载权限
XF 兼容性
  1. 2.2.x
摘要
增强你的ChatGPT体验,提供助手函数并设置API密钥以实现无缝集成。高效获取消息、准备机器人内容以及移除引号。

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
浏览
543
扩展类型
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 New methods in MessagesDTO: map...
  2. 2.1.1 - changelog
    Fix: Backward compatibility
  3. 1.6.0 - changelog
    Support for function calling

来自 axtona 的更多资源

科 prox CAPTCHA - 自 hosted 防止 欺诈 选项,无需点击 A
添加Cap,一个自托管、隐私友好的工作证明式验证码作为访客验证码
高级交通统计:从洞察到主动防御 A
一个综合且视觉吸引的交通计数器与统计小部件。
巫师PRO A
巫师PRO 13.1.0
将PHP和任何类型的HTML、CSS和JavaScript代码直接放入内容中!

相似的资源

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