承接 jeffreyvanrossum/contextr 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

jeffreyvanrossum/contextr

最新稳定版本:0.1.2

Composer 安装命令:

composer require jeffreyvanrossum/contextr

包简介

Determine context with AI.

README 文档

README

contextr logo

contextr

Total Downloads Latest Stable Version License

Use AI as your intelligent assistant to analyze text for spam, sentiment, and moderation, delivering precise insights with confidence scores and detailed reasoning.

Usage

Installation

composer require jeffreyvanrossum/contextr

Setup

First, you need to setup your instance of contextr.

You can use OpenAI or Grok as AI providers.

$contextr = new Contextr\Contextr(provider: new Contextr\Providers\OpenAi(apiKey: 'API_KEY'));

// Or for Grok:

$contextr = new Contextr\Contextr(provider: new Contextr\Providers\Grok(apiKey: 'API_KEY'));

Examples

Spam
$check = $contextr->spam()
    ->text('Buy cheap viagra now!!! Click here: shady.link')
    ->context([
        'topic' => 'Health Forum Discussion',
        'user_history' => 'First time poster'
    ])
    ->withReasoning()
    ->analyze();

$check->data();         // full result array
$check->spam();         // true (boolean)
$check->confidence();   // 0.95 (float)
$check->reasoning();    // "Contains promotional content and suspicious link"
Sentiment

Determine if the sentiment is positive, negative or neutral.

$check = $contextr->sentiment()
    ->text('This blu ray was great, too bad it did not include Project A.')
    ->context([
        'product' => 'Jackie Chan Collection Vol 1983',
        'category' => 'Blu ray'
    ])
    ->withReasoning()
    ->analyze();

$check->data();         // full result array
$check->sentiment();    // neutral (string)
$check->confidence();   // 0.75 (float)
$check->reasoning();    // "Expresses enjoyment of the blu ray but also disappointment about the absence of a specific content." (string)
Moderation

Determine if user comments violate moderation rules.

$check = $contextr->moderation()
    ->text('These morons don’t even know how to kick a ball properly!')
    ->rules(['hate speech', 'profanity', 'civility'])
    ->context([
        'platform' => 'sports news website',
        'topic' => 'Premier League match review'
    ])
    ->withReasoning()
    ->withViolations()
    ->analyze();

$check->data();         // full result array
$check->violates();     // true (boolean)
$check->confidence();   // 0.75 (float)
$check->violations();   // ['profanity', 'civility'] (array)
$check->reasoning();    // "Contains insulting language and lacks respectful tone"
AI

Determine the likelyhood that a text is AI-generated.

$check = $contextr->ai()
    ->text('The strategic intricacies of modern football necessitate a comprehensive understanding of player positioning, tactical adaptability, and cohesive team synergy to achieve superior performance outcomes.')
    ->context([
        'platform' => 'football fan forum',
        'topic' => 'Post-match discussion: Manchester United vs. Liverpool',
        'user_history' => 'New account, posted 5 similar analyses in 24 hours'
    ])
    ->withReasoning()
    >analyze();

$check->data();         // full result array
$check->ai();           // true (boolean)
$check->confidence();   // 0.92 (float)
$check->reasoning();    // "Overly polished language and generic analysis typical of AI-generated text, especially given the user's pattern of similar posts."

contextr as a service? 👀

Would you like this API, but as a hosted service, with a nice interface to define custom base templates?

Join the waitlist

Contributors

License

MIT. Please see the License File for more information.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-03-12