CharacterKB: Your AI-Powered Companion for Fictional Characters
Rajesh Adhikari

Rajesh Adhikari @rajesh-adk-137

About: A little older, a little wiser.

Joined:
May 7, 2024

CharacterKB: Your AI-Powered Companion for Fictional Characters

Publish Date: Jun 29
5 1

Discover, Analyze, and Chat: Unleash the Power of Fictional Characters with CharacterKB


In the vast genre of storytelling, fictional characters often become as real to us as the people we know. But what if you could not only discover them based on nuanced descriptions but also delve into their psyches and even converse with them? This is where CharacterKB steps in – an innovative AI-powered platform designed to revolutionize how you interact with fictional characters.

I'm thrilled to introduce CharacterKB, a project developed for the MindsDB Quest 019, showcasing the robust capabilities of MindsDB's Knowledge Bases. CharacterKB leverages MindsDB's cutting-edge semantic search, AI Tables, and Agents to transform your character ideas into precise discoveries, deep psychological insights, and engaging conversations.

Why MindsDB Knowledge Bases?

MindsDB is an AI data solution that empowers users to query data using natural language and SQL across diverse data sources. Their Knowledge Bases are a game-changer, offering semantic search capabilities that allow you to store and retrieve information based on its meaning, rather than just keywords. This semantic understanding is crucial for CharacterKB, enabling it to go beyond simple keyword matching and truly understand your character descriptions.


Introducing CharacterKB: Your Intelligent Character Companion

Landing Page

CharacterKB is more than just a search engine; it's a comprehensive character experience crafted for writers, fans, and anyone curious about the depths of fictional personalities. Here's what makes it unique:

  • AI-Powered Character Discovery: Describe any character idea in natural language (e.g., "Billionaire who becomes a symbol of fear for criminals") and instantly get the best match along with the top 5 closest results using MindsDB's semantic search.

A natural language query in action, demonstrating CharacterKB's intuitive search and personalized character suggestions.

Suggested Characters

  • Character Insights & Analysis: Dive deeper with AI-powered psychological profiling that analyzes personality traits, emotional patterns, and core characteristics. Get concise personality tags and structured emotional profiles highlighting confidence, optimism, wit, and more.

Detailed character insights, including personality tags and emotional profiles, all generated by MindsDB AI Tables.

Character Insights

  • Interactive Character Chat: Engage in authentic conversations with discovered characters in their unique voices and mannerisms. Just click 'Chat' to get personalized advice, creative insights, or fun interactions—no setup needed.

Interact with the AI literary expert for in-depth conversations about characters.

Chatbot

  • Smart Image Suggestions: See visual representations of your matched character with curated image results pulled from the web using intelligent search, automatically and seamlessly.
  • Filter by Media Type: Refine your character searches by over 20 different media types, including Movies, TV Shows, Novels, Games, Anime, and Mythology.
  • Authentic Conversations: Characters respond with their unique voice, mannerisms, and wisdom, offering life advice, creative insights, and new perspectives.

The Tech Stack: MindsDB at the Core

CharacterKB is built with a robust and modern tech stack designed for scalability, performance, and reliability:

  • MindsDB: The central AI layer, handling Knowledge Bases for semantic search, AI Tables for data enrichment, and Agents for the conversational bot.
  • FastAPI (Python): The high-performance backend API.
  • React + Tailwind CSS: For a sleek, responsive, and interactive user interface.
  • OpenAI: Powering the large language models used by MindsDB for embeddings, AI Tables, and Agents.
  • Google Custom Search API: For smart image suggestions.
  • Docker Desktop: For consistent development and deployment environments.

System Architecture

CharacterKB's multi-layered architecture ensures a seamless and powerful user experience:

  • Frontend Layer: Built with React and Tailwind CSS, focusing on responsive design and intuitive user interaction.
  • API Layer: Powered by FastAPI, handling requests for character search, interactive character chat, and enriched character information.
  • AI Layer: MindsDB orchestrates the core AI functionalities, including Knowledge Base queries, Agent interactions, and semantic search.
  • Data Layer: Manages character metadata, media type classification, and relevance scoring, leveraging a dataset of over 10,000 characters.

Building CharacterKB: A Deep Dive into MindsDB Integration

The integration of MindsDB is fundamental to every intelligent feature within CharacterKB. Here’s a glimpse into how different MindsDB capabilities are utilized, directly with SQL queries executed within MindsDB Studio:

1. Intelligent Character Discovery with Knowledge Bases

At the heart of CharacterKB's search is a MindsDB Knowledge Base, which stores over 10,000 character descriptions. This allows the application to understand the context, personality, and media type preferences of your query, going beyond simple keyword matching.

Here's an example of a semantic search query within MindsDB:

SELECT *
FROM character_kb_10000
WHERE content = 'a genius scientist who loves trains sheldon'
LIMIT 5;
Enter fullscreen mode Exit fullscreen mode

This SQL query to the character_kb_10000 Knowledge Base allows for semantic search, finding characters based on their description, and retrieving the top results.

2. AI-Powered Interactive Character Chat with MindsDB Agents

The interactive "Character Chat" is powered by a custom conversational agent created within MindsDB. This agent is designed to provide thoughtful analysis, interpretations, and discussions about characters, drawing from its deep literary knowledge and role-playing as the character.

Here’s how you can query the Character Agent in MindsDB:

SELECT answer
FROM character_agent
WHERE
  character_name = 'Tony Stark'
  AND character_description = 'Tony Stark is a genius billionaire inventor who masks his insecurities with sarcasm and bold charisma. As Iron Man, he faces threats with a mix of wit, technology, and restless optimism about humankind’s potential.'
  AND question = 'I’m nervous before my first job interview. Any advice?';
Enter fullscreen mode Exit fullscreen mode

This SQL query to the character_agent MindsDB Agent passes the character's name, description, and the user's question to get a contextual, in-character answer.

3. Enriched Character Information with MindsDB AI Tables

To provide comprehensive character details, CharacterKB utilizes MindsDB AI Tables. These tables dynamically generate enriched metadata such as personality traits, emotional profiles, and smart tags.

Here’s how you query the Character Insights model in MindsDB:

SELECT response
FROM character_insights
WHERE
  character_name = 'Tony Stark'
  AND character_description = 'Tony Stark is a genius billionaire inventor who masks his insecurities with sarcasm and bold charisma. As Iron Man, he faces threats with a mix of wit, technology, and restless optimism about humankind’s potential.';
Enter fullscreen mode Exit fullscreen mode

This query to the character_insights MindsDB Model (an AI Table) takes the character's name and description to generate a rich set of personality details.

4. Data Freshness with MindsDB Jobs

To ensure the Knowledge Base remains up-to-date with new characters, a MindsDB JOB is scheduled to periodically check for and ingest new data from the source Google Sheet.

An example of the MindsDB JOB creation:

CREATE JOB character_kb_job AS (
  INSERT INTO character_kb_10000
  SELECT unique_id, media_type, genre, character_name, description
  FROM character_sheet_10000.character_data_10000
  WHERE unique_id > 10000; -- Adjust this condition if your initial dataset has a different max ID
)
EVERY 1 minute;
Enter fullscreen mode Exit fullscreen mode

This job is configured to run every minute, checking for and inserting new character data into the character_kb_10000 Knowledge Base.


Live Demo & GitHub Repository

Curious to see CharacterKB in action?

🔗 CharacterKB GitHub Repository

Conclusion

Building CharacterKB for the MindsDB Quest 019 has been an incredibly insightful journey. MindsDB's Knowledge Bases, AI Tables, and Agents provide a robust and intuitive framework for creating intelligent, data-driven applications. CharacterKB stands as a testament to the power of AI in transforming how we discover, analyze, and interact with the vast world of fictional characters, making the exploration of their personalities an engaging and intelligent experience.

Acknowledgments

Comments 1 total

Add comment