jeffreyvanrossum/contextr 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

jeffreyvanrossum/contextr

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.

统计信息

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

GitHub 信息

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

其他信息

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

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固