定制 albertcht/notion-ai 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

albertcht/notion-ai

最新稳定版本:v0.1.0

Composer 安装命令:

composer require albertcht/notion-ai

包简介

Api Client of Notion AI in PHP

README 文档

README

Latest Version on Packagist Tests Total Downloads

Demo Notion AI

About this package

Notion AI is a powerful artificial intelligence feature based on GPT-3 that is part of the productivity app Notion. You can use Notion AI within Notion itself, but there is currently no official API available.

This is an unofficial PHP client for the Notion AI API that makes it easy to interact with Notion AI in your PHP projects.

Installation

You can install the package via composer:

composer require albertcht/notion-ai

Usage

  • Initialize a Notion AI instance
$notion = new AlbertCht\NotionAi\NotionAi('token', 'spaceId');
  • Set options of Guzzle client in the third paramter

See: https://docs.guzzlephp.org/en/stable/request-options.html

$notion = new AlbertCht\NotionAi\NotionAi('token', 'spaceId', ['timeout' => 120]);
  • Replace a PSR Http Client if needed
$client = new GuzzleHttp\Client();
$notion->setClient($client);
  • Send a request with general sendRequest function

If some APIs are not wrapped in this package, you can interact with Notion AI by this function

$notion->sendRequest([
    [
        'type' => $promptType,
        'pageTitle' => $pageTitle,
        'selectedText' => $selectedText,
    ]
]);
  • Send a request with stream response
// you can set buffer size of stream in the second parameter
$notion->stream(function ($output) {
    echo $output;
    if (ob_get_length()) {
        ob_get_flush();
        flush();
    }
}, 128);
$notion->sendRequest([
    [
        'type' => $promptType,
        'pageTitle' => $pageTitle,
        'selectedText' => $selectedText,
    ]
]);
  • Supported APIs
public function writeWithPrompt(string $promptType, string $selectedText, string $pageTitle = ''): ?string;

public function continueWriting(string $previousContent, string $pageTitle = '', string $restContent = ''): ?string;

public function helpMeEdit(string $prompt, string $selectedText, string $pageTitle = ''): ?string;

public function helpMeWrite(string $prompt, string $previousContent = '', string $pageTitle = '', string $restContent = ''): ?string;

public function helpMeDraft(string $prompt, string $previousContent = '', string $pageTitle = '', string $restContent = ''): ?string;

public function translate(string $text, string $language): ?string;

public function changeTone(string $text, string $tone): ?string;

public function summarize(string $selectedText, string $pageTitle = ''): ?string;

public function improveWriting(string $selectedText, string $pageTitle = ''): ?string;

public function fixSpellingGrammar(string $selectedText, string $pageTitle = ''): ?string;

public function explainThis(string $selectedText, string $pageTitle = ''): ?string;

public function makeLonger(string $selectedText, string $pageTitle = ''): ?string;

public function makeShorter(string $selectedText, string $pageTitle = ''): ?string;

public function findActionItems(string $selectedText, string $pageTitle = ''): ?string;

public function simplifyLanguage(string $selectedText, string $pageTitle = ''): ?string;

public function writeWithTopic(string $topic, string $prompt): ?string;

public function brainstormIdeas(string $prompt): ?string;

public function outline(string $prompt): ?string;

public function socialMediaPost(string $prompt): ?string;

public function creativeStory(string $prompt): ?string;

public function poem(string $prompt): ?string;

public function essay(string $prompt): ?string;

public function meetingAgenda(string $prompt): ?string;

public function pressRelease(string $prompt): ?string;

public function jobDescription(string $prompt): ?string;

public function salesEmail(string $prompt): ?string;

public function recruitingEmail(string $prompt): ?string;

public function prosConsList(string $prompt): ?string;

Enums

There are enums you can refer to when you call APIs:

Testing

composer test

How to get token and space id from Notion?

  • Get token from Notion

Screenshot of token.

  • Get space id from Notion

Screenshot of spaceId.

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Donation

Buy Me A Coffee

You can support me by a cup of coffee. An open-source project also relies on community's contribution. Any PRs are welcome to help maintain this package.

Credits

License

The MIT License (MIT). Please see License File for more information.

统计信息

  • 总下载量: 44
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 28
  • 点击次数: 3
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 28
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-04-12

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固