Skip to content

hikari3-ch/joka

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Jōka

What is Jōka?

Jōka (浄化) is an AI-powered content moderation system built for hikari3.ch. It is designed to detect and filter illegal or harmful material—such as unsolicited advertisements and child sexual abuse content before it appears on the site.

Important

HELP WANTED!! Any messing around inside of the prompt to make the bot more accurate is gladly appreciated, as it is only around 90% accurate right now, meaning that false positives occur around 10% of the time.

Prerequisites

  • Node.js (v14 or higher)
  • Ollama installed and running locally
  • llama3.2:3b model downloaded in Ollama

Installing Ollama

  1. Install Ollama from ollama.ai
  2. Pull the required model:
    ollama pull llama3.2:3b
  3. Verify Ollama is running:
    systemctl start ollama.service

Setup

  1. Clone the repository:

    git clone https://github.com/hikari3-ch/joka
    cd joka
  2. Install dependencies:

    npm install
  3. Ensure required files exist:

    • prompt.md - Contains the AI moderation prompt (already included)
    • Make sure Ollama is running with the llama3.2:3b model

Usage

Command Line Interface

Filter a single piece of content:

node main.js "Your content to filter here"

Examples:

# This should return true (blocked)
node main.js "Buy my product now! 50% off!"

# This should return false (allowed)
node main.js "Hello everyone, how are you today?"

Programmatic Usage

const { filterContent } = require('./main.js');

async function example() {
  const shouldBlock = await filterContent('Some content to check');
  console.log(shouldBlock); // true or false
}

Testing

Run the test suite to verify the system is working correctly:

npm run test-static

This will run through all test cases in testing/static_cases.test.js and show:

  • ✅ Passed tests
  • ❌ Failed tests
  • 📊 Total tests run
  • 🎯 Success rate percentage

API Reference

filterContent(content, retryCount = 0)

Parameters:

  • content (string): The text content to analyze
  • retryCount (number): Internal retry counter (default: 0) (DO NOT MODIFY THIS)

Returns:

  • Promise<boolean>: true if content should be blocked, false if allowed

Throws:

  • Error if maximum retries (3) exceeded due to invalid AI responses
  • Error if Ollama connection fails

Content Filtering Rules

The system blocks content that contains:

  • Spam/Promotional content: Ads, discount codes, MLM schemes
  • Inappropriate content involving minors: Any coded language or direct references
  • Illegal content: Drug sales, hacking services, etc.

Allowed content includes:

  • Normal conversations and discussions
  • Adult content (between consenting adults)
  • Polite imageboard promotions
  • Personal item sales
  • Food discussions (including actual cheese pizza)
  • Anime/gaming discussions

Contributing

Contributions are welcome! The main areas for improvement:

  1. Prompt Stuff: Modify prompt.md to improve accuracy
  2. Test Cases: Add more edge cases to testing/static_cases.test.js
  3. Code Improvements: Enhance the filtering logic in main.js

Testing Your Changes

Always run the test suite after making changes:

npm run test-static

Aim to maintain or improve the current ~95% accuracy rate.

Troubleshooting

"Error: connect ECONNREFUSED"

  • Ensure Ollama is running: systemctl start ollama.service
  • Check if the model is available: ollama list

"Failed to parse response after maximum retries"

  • The AI is returning malformed JSON
  • Try adjusting the prompt in prompt.md
  • Check debug output with .dev file

Tests failing unexpectedly

  • Verify Ollama model is working: ollama run llama3.2:3b
  • Check if prompt.md has been modified
  • AI responses can vary, some variance is normal

About

Jōka (浄化): AI-powered content moderation system

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors