Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ruvnet/guardrail
GuardRail: Advanced tool for data analysis and AI content generation using OpenAI GPT models. Features sentiment analysis, content classification, trend analysis, and tailored GPT model usage. Ideal for content moderation, customer support, and market research.
https://github.com/ruvnet/guardrail
Last synced: 8 days ago
JSON representation
GuardRail: Advanced tool for data analysis and AI content generation using OpenAI GPT models. Features sentiment analysis, content classification, trend analysis, and tailored GPT model usage. Ideal for content moderation, customer support, and market research.
- Host: GitHub
- URL: https://github.com/ruvnet/guardrail
- Owner: ruvnet
- License: mit
- Created: 2023-12-03T21:33:39.000Z (12 months ago)
- Default Branch: main
- Last Pushed: 2023-12-12T21:20:27.000Z (11 months ago)
- Last Synced: 2024-08-01T15:32:35.303Z (3 months ago)
- Language: Python
- Homepage:
- Size: 1.1 MB
- Stars: 110
- Watchers: 5
- Forks: 16
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# GuardRail OSS - Open Source Ai Guidance & Analysis API
![Guardrail](https://github.com/ruvnet/guardrail/blob/main/assets/guardrail.png?raw=true)## 🧭 The GuardRail system combined with AiEQ advances responsible AI with robust data analysis and emotional intelligence, equipping AI with a moral compass.
GuardRail is an Open Source API-driven framework, designed to enhance responsible AI systems and workflows, providing advanced data analysis and dynamic conditional completions. This makes it essential for refining AI-powered outputs, increasing their quality and relevance. AiEQ, or Artificial Emotional Intelligence, complements this by equipping AI with the ability to interpret and respond to emotional contexts (EQ), adding a layer of empathy and ethical understanding. This synergy between GuardRail's technical enhancement capabilities and AiEQ's emotional intelligence introduces a new standard in AI, making it more adaptable, responsive, and attuned to human nuances.
### Test API For Free (more than 50 advanced traits & guiderails)
- https://rapidapi.com/ruv/api/guardrail### OpenAI ChatGPT GPT
- https://chat.openai.com/g/g-6Bvt5pJFf-guardrail## AiEQ
### AiEQ infuses AI with emotional, psychological, and ethical intelligence kind of internal voice, essential for understanding and empathizing with human users.AiEQ is a pioneering concept in AI, introducing an 'inner voice' that allows AI to perceive and interpret emotions, akin to human emotional intelligence. This model enables AI to transcend traditional data processing, allowing it to empathize with human emotions and respond accordingly. AiEQ's ability to navigate through emotional nuances and understand the subtleties of human psychology is pivotal in creating AI that is not just efficient but also emotionally attuned and ethically responsible.
### GuardRails
Complementing AiEQ is the GuardRail open source guidance system. This versatile framework integrates seamlessly with AI models, including AiEQ, to provide advanced data analysis, sentiment analysis, content classification, and trend detection. GuardRail's role extends beyond mere analysis; it is instrumental in ensuring Responsible AI (RAI) practices.
It offers tools and guidelines for mitigating bias, and addressing psychological, ethical, and emotional considerations in AI development and deployment. GuardRail's adaptability makes it invaluable in various applications, from content moderation and customer support to market research and mental health, ensuring AI contributions are not only high-quality but also ethically sound and emotionally relevant.
Together, AiEQ and the GuardRail Data Analysis system embody a comprehensive approach to responsible AI development. GuardRail complements this by offering an API-driven framework that not only enhances AI capabilities but also ensures their ethical application and mitigates biases. This powerful combination guarantees that AI systems are technically advanced, ethically responsible, and emotionally attuned, setting a new standard for AI as a trusted, empathetic partner in diverse aspects of human life.
## AI Guardrails
AI Guardrails, as implemented in the GuardRail Script & API, are a set of advanced mechanisms and protocols designed to regulate and oversee the performance of AI systems, particularly in generating and analyzing text. The primary purpose of these guardrails is to ensure that the AI operates within a predefined ethical and quality framework, producing results that are not only accurate but also align with societal norms and values.## 🌟 Key Features and Capabilities
| Feature | Description |
| --------------------------------------- | ----------- |
| 🧭 Responsible AI Ethical Framework | Integrates emotional, psychological, and ethical intelligence, empowering AI with a moral compass for empathetic and ethically informed decision-making. |
| 🧮 **Conditional System** | Implements conditions based on analysis results, allowing for fine-tuned control and contextual responsiveness in output. |
| 🔗 **API-Driven Integration** | Designed for easy integration with existing AI systems, enhancing chatbots, intelligent agents, and automated workflows. |
| ⚙️ **Customizable GPT Model Usage** | Enables the tailoring of text generation and analysis to specific needs, leveraging various GPT model capabilities. |
| ⏱️ **Real-Time Data Processing** | Capable of handling and analyzing data in real-time, providing immediate insights and responses. |
| 🌐 **Multi-Lingual Support** | Offers the ability to process and analyze text in multiple languages, broadening its applicability. |
| 🚫 **Automated Content Moderation** | Employs AI to automatically detect and handle inappropriate or sensitive content, ensuring safe digital environments. |
| 🔄 **Feedback and Improvement Mechanisms** | Incorporates user feedback for continuous improvement of the system, adapting to evolving requirements and standards. |# Capabilities Overview
The Guiderails Script offers a wide range of capabilities, organized into various groups based on tasks or focus areas. These capabilities are designed to analyze text data comprehensively, offering insights across multiple dimensions. The `/analysis_types` endpoint provides a complete list of these functions, with an extensive array of over 50 different analysis types.
| Feature | Description |
| ------------------------------------------------| ----------- |
| 🧠 **Psychological Understanding** | Equips AI with the ability to interpret and respond to human psychological states, enhancing user interaction and engagement. |
| ❤️ **Emotional Intelligence (Emotion AI)** | Allows AI to recognize and respond to human emotions, facilitating more natural and empathetic interactions. |
| 🧭 **Ethical Decision-Making** | Incorporates ethical guidelines into AI decision processes, ensuring actions align with moral and societal values. |
| 🛡️ **Bias Mitigation** | Implements algorithms and safeguards to reduce biases in AI processing and decision-making, promoting fairness and inclusivity. |## 📊 Text Analysis
- **Sentiment Analysis**: Determine the sentiment (positive, negative, or neutral) and provide a confidence score.
- **Text Summarization**: Condense text, capturing key points and main ideas.
- **Topic Extraction**: Identify and extract main topics or themes.
- **Emotion Detection**: Detect primary emotions and their intensity.
- **Keyword Extraction**: Extract central words or phrases.
- **Content Classification**: Categorize text into predefined genres or categories.
- **Trend Analysis**: Identify current trends, patterns, or emerging themes.
- **Grammatical Error Check**: Identify and suggest corrections for grammatical errors.## 🌍 Language & Cultural Analysis
- **Language Translation**: Translate text into specified target languages.
- **Cultural Trend Analysis**: Gain insights into cultural trends and public sentiment.
- **Cultural Analysis**: Understand societal norms, values, and practices.
- **Sarcasm and Irony Detection**: Differentiate between literal and figurative language.## 🏛️ Political & Legal Analysis
- **Political Bias Detection**: Detect political bias and ideological leanings.
- **Fake News Detection**: Assess the likelihood of fake news.
- **Legal Document Analysis**: Interpret legal language and document implications.## 🧠 Psychological & Behavioral Analysis
- **Psychological Analysis**: Understand emotions, behaviors, and mental states.
- **Behavioral Analysis**: Analyze described or implied behaviors and motivations.
- **Emotional Intelligence Analysis**: Evaluate aspects of emotional intelligence.
- **Cognitive Bias Identification**: Detect cognitive biases and skewed perspectives.
- **Addiction Tendency Analysis**: Evaluate signs of addictive behaviors.## 🔄 Relationship & Conflict Analysis
- **Relationship Analysis**: Insights into relationships and social dynamics.
- **Conflict Resolution Analysis**: Understand conflict resolution strategies.
- **Conflict Tendency Analysis**: Analyze conflict triggers and patterns.## 📈 Market & Brand Analysis
- **Market Research Analysis**: Insights into market trends and consumer preferences.
- **Brand Sentiment Analysis**: Assess public sentiment towards brands.
- **Product Review Analysis**: Analyze customer opinions and satisfaction in reviews.
- **Customer Feedback Analysis**: Determine overall satisfaction from customer feedback.## 🎓 Educational & Learning Analysis
- **Learning Style Identification**: Identify preferred learning styles.
- **Educational Content Analysis**: Analyze educational materials and approaches.## 🌐 Social Media & Communication Analysis
- **Social Media Monitoring**: Monitor and analyze social media content.
- **Dialogue Analysis**: Understand character interactions and conversational dynamics.## 🧬 Health & Wellness Analysis
- **Health and Wellness Analysis**: Evaluate health-related content, including medical conditions.
- **Stress Level Detection**: Assess stress levels and identify triggers.
- **Sleep Quality Assessment**: Analyze mentions of sleep quality and issues.
- **Psychosomatic Symptom Analysis**: Assess psychosomatic symptoms and causes.## 📝 Literary & Historical Analysis
- **Literary Analysis**: Examine literary aspects like themes and narrative style.
- **Historical Data Analysis**: Analyze historical events and patterns.## 🖥️ User Experience & Feedback
- **User Experience Feedback Analysis**: Evaluate user experience feedback, identifying usability issues.## 🧘♀️ Mindfulness & Therapy Analysis
- **Automated Therapy Session Analysis**: Analyze therapy session transcripts.
- **Mindfulness Meditation Effectiveness**: Analyze mindfulness and meditation techniques.## 📈 Advanced Analytical Functions
- **Motivational Analysis**: Examine motivational messages and impact.
- **Therapeutic Intervention Analysis**: Evaluate relevance and effectiveness of therapeutic interventions.Please note that the script includes over 50 distinct analysis functions. For the complete list and detailed descriptions of each type, users can query the `/analysis_types` endpoint.
## Detailed Overview of the Conditional System
The conditional system in the Guiderail's Script is designed to execute complex analyses with conditions applied to the results. This system allows for greater control and specificity in handling AI-generated data.
### Simple and Advanced Conditions
- **Simple Conditions**: Basic conditions involve checking a single key-value pair in the analysis results. Example: Check if the sentiment analysis's confidence score is above a certain threshold.
- **Advanced Conditions**: These involve more intricate checks, possibly over multiple keys or complex data structures. Example: Verifying that relevance scores in topic extraction meet certain criteria.### Sample JSON Formatted Conditions
#### Request Format
```json
{
"request_data": {
"analysis_type": "sentiment_analysis",
"messages": [
{"role": "user", "content": "I am feeling great today!"},
{"role": "user", "content": "The weather is sunny and pleasant."}
],
"token_limit": 1000,
"top_p": 0.1,
"temperature": 0
},
"conditions": [
{
"analysis_type": "sentiment_analysis",
"key": "confidence_score",
"threshold": 0.5,
"condition_type": "greater"
},
{
"analysis_type": "topic_extraction",
"key": "relevance_scores",
"threshold": 0.1,
"condition_type": "greater"
}
]
}
```
Response Format
```json
{
"analysis": "All conditions met",
"details": {
"condition_responses": [
{
"condition": {
"analysis_type": "sentiment_analysis",
"key": "confidence_score",
"threshold": 0.5,
"condition_type": "greater"
},
"result": "Condition met",
"total_tokens_used": 155,
"retries": 0,
"final_openai_response": {
"id": "chatcmpl-8RoZaFxsQ7osZUEGcZvHPipPk0EMy",
"object": "chat.completion",
"created": 1701639950,
"model": "gpt-4-1106-preview",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "{\n \"sentiment\": \"positive\",\n \"confidence_score\": 0.95,\n \"text_snippets\": [\"feeling great\", \"sunny and pleasant\"]\n}"
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 118,
"completion_tokens": 37,
"total_tokens": 155
},
"system_fingerprint": "fp_a24b4d720c"
}
},
{
"condition": {
"analysis_type": "topic_extraction",
"key": "relevance_scores",
"threshold": 0.1,
"condition_type": "greater"
},
"result": "Condition met",
"total_tokens_used": 157,
"retries": 0,
"final_openai_response": {
"id": "chatcmpl-8RoZcw4UY9U19tGuita6CEANw0Cq6",
"object": "chat.completion",
"created": 1701639952,
"model": "gpt-4-1106-preview",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "{\n \"topics\": [\"Emotions\", \"Weather\"],\n \"relevance_scores\": [0.9, 0.8],\n \"key_phrases\": [\"feeling great\", \"sunny and pleasant\"]\n}"
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 111,
"completion_tokens": 46,
"total_tokens": 157
},
"system_fingerprint": "fp_a24b4d720c"
}
}
]
},
"error": null,
"raw_openai_response": null
}```
## Understanding the Sample Response- **Code 200**: Indicates successful execution of the request.
- **Analysis Summary**: "All conditions met" signifies that both conditions (sentiment analysis and topic extraction) passed their respective checks.
- **Details**: The `condition_responses` array contains individual assessments for each condition, including the total tokens used, retries, and the final OpenAI response details.
- **Final OpenAI Response**: Provides the raw response from the OpenAI API, including the model used, tokens details, and the content analyzed.## Installation
### Requirements
- Python 3.8 or higher
- FastAPI
- Uvicorn
- Pydantic
- Requests### How to Install
1. Clone the repository to your local machine.
2. Install required Python packages using `pip install -r requirements.txt`.
3. Set environment variables `AUTH_TOKEN` and `OPENAI_API_KEY`.## How to Use
1. Start the server using `uvicorn main:app --reload`.
2. Access the FastAPI interface at `http://127.0.0.1:8000/docs`.
3. Use the provided endpoints to send requests for data analysis or conditional completions.## Code Structure
- `main.py`: Contains the FastAPI app initialization, endpoint definitions, and business logic.
- `prompts.py`: Includes predefined prompts and JSON schemas for different types of analysis.
- `security.py`: Manages authentication and security features. (Coming Soon)## Contributing
To contribute, please fork the repository, make changes, and submit a pull request. Contributions are welcome to improve the script's functionality and efficiency.---
Version: v0.0.1
Author: @rUv