### Python: Content Moderation Pipeline Source: https://raw.githubusercontent.com/fasuizu-br/brainiall-nlp-api/main/llms-full.txt An example Python function demonstrating how to use the Brainiall NLP API to perform a content moderation pipeline, including toxicity, PII, and language detection. ```APIDOC ## Python: Content Moderation Pipeline ### Description This Python code snippet shows how to integrate with the Brainiall NLP API to create a content moderation pipeline. It sequentially calls the toxicity, PII, and language detection endpoints to analyze text and determine an appropriate action (block, redact, or allow). ### Language Python ### Code Example ```python import requests BASE_URL = "https://apim-ai-apis.azure-api.net/v1/nlp" HEADERS = {"Authorization": "Bearer YOUR_KEY", "Content-Type": "application/json"} def moderate_content(text: str) -> dict: """Run content moderation pipeline: toxicity + PII + language.""" # Check toxicity toxicity = requests.post(f"{BASE_URL}/toxicity", headers=HEADERS, json={"text": text}).json() # Check for PII pii = requests.post(f"{BASE_URL}/pii", headers=HEADERS, json={"text": text}).json() # Detect language language = requests.post(f"{BASE_URL}/language", headers=HEADERS, json={"text": text}).json() return { "text": text, "language": language["language"], "is_toxic": toxicity["is_toxic"], "toxic_categories": {k: v for k, v in toxicity["scores"].items() if v > 0.5}, "has_pii": pii["pii_found"], "pii_types": [e["type"] for e in pii.get("entities", [])], "action": "block" if toxicity["is_toxic"] else ("redact" if pii["pii_found"] else "allow") } # Usage result = moderate_content("Please contact John at john@example.com for details") print(f"Action: {result['action']}") print(f"Language: {result['language']}") print(f"PII found: {result['pii_types']}") ``` ``` -------------------------------- ### GET /health Source: https://raw.githubusercontent.com/fasuizu-br/brainiall-nlp-api/main/llms-full.txt Checks the health status of the NLP service and reports the loading status of all available models. ```APIDOC ## GET /health ### Description Checks the health status of the NLP service and reports the loading status of all available models. ### Method GET ### Endpoint /v1/nlp/health ### Parameters None ### Request Example (No request body needed for GET request) ### Response #### Success Response (200) - **status** (string) - The overall health status of the service (e.g., "healthy"). - **models** (object) - An object detailing the status of each loaded NLP model. - **toxicity** (string) - Status of the toxicity model (e.g., "loaded"). - **sentiment** (string) - Status of the sentiment model (e.g., "loaded"). - **ner** (string) - Status of the NER model (e.g., "loaded"). - **pii** (string) - Status of the PII detection model (e.g., "loaded"). - **language** (string) - Status of the language detection model (e.g., "loaded"). #### Response Example ```json { "status": "healthy", "models": { "toxicity": "loaded", "sentiment": "loaded", "ner": "loaded", "pii": "loaded", "language": "loaded" } } ``` ``` -------------------------------- ### GET /health Source: https://raw.githubusercontent.com/fasuizu-br/brainiall-nlp-api/main/llms-full.txt Checks the health status of the NLP API. ```APIDOC ## GET /health ### Description Checks the health status of the NLP API. ### Method GET ### Endpoint /v1/nlp/health ### Parameters No parameters required. ### Request Example ```bash curl -s "https://apim-ai-apis.azure-api.net/v1/nlp/health" \ -H "Authorization: Bearer YOUR_KEY" \ | python3 -m json.tool ``` ### Response #### Success Response (200) - **status** (string) - The health status of the API (e.g., "healthy"). #### Response Example ```json { "status": "healthy" } ``` ``` -------------------------------- ### curl: All NLP Endpoints Source: https://raw.githubusercontent.com/fasuizu-br/brainiall-nlp-api/main/llms-full.txt Demonstrates how to call each NLP API endpoint (toxicity, sentiment, entities, PII, language, health) using curl commands. Each command sends a POST request with JSON payload and an authorization header, then pipes the output to 'python3 -m json.tool' for pretty-printing. Requires curl and Python 3. ```bash BASE="https://apim-ai-apis.azure-api.net/v1/nlp" KEY="YOUR_KEY" # Toxicity curl -s -X POST "$BASE/toxicity" \ -H "Content-Type: application/json" -H "Authorization: Bearer $KEY" \ -d '{"text": "You are wonderful!"}' | python3 -m json.tool # Sentiment curl -s -X POST "$BASE/sentiment" \ -H "Content-Type: application/json" -H "Authorization: Bearer $KEY" \ -d '{"text": "Best product ever!"}' | python3 -m json.tool # Entities curl -s -X POST "$BASE/entities" \ -H "Content-Type: application/json" -H "Authorization: Bearer $KEY" \ -d '{"text": "Satya Nadella leads Microsoft from Redmond."}' | python3 -m json.tool # PII curl -s -X POST "$BASE/pii" \ -H "Content-Type: application/json" -H "Authorization: Bearer $KEY" \ -d '{"text": "Email me at test@test.com, SSN 123-45-6789"}' | python3 -m json.tool # Language curl -s -X POST "$BASE/language" \ -H "Content-Type: application/json" -H "Authorization: Bearer $KEY" \ -d '{"text": "Bonjour le monde"}' | python3 -m json.tool # Health curl -s "$BASE/health" -H "Authorization: Bearer $KEY" | python3 -m json.tool ``` -------------------------------- ### JavaScript: Full NLP Analysis Source: https://raw.githubusercontent.com/fasuizu-br/brainiall-nlp-api/main/llms-full.txt Performs a comprehensive NLP analysis on a given text using JavaScript's fetch API. It concurrently calls multiple NLP API endpoints (toxicity, sentiment, entities, PII, language) and returns a consolidated result object. Requires a browser environment or Node.js with a fetch implementation. ```javascript const BASE_URL = "https://apim-ai-apis.azure-api.net/v1/nlp"; const HEADERS = { "Content-Type": "application/json", Authorization: "Bearer YOUR_KEY", }; async function analyzeText(text) { const endpoints = ["toxicity", "sentiment", "entities", "pii", "language"]; const results = {}; await Promise.all( endpoints.map(async (endpoint) => { const response = await fetch(`${BASE_URL}/${endpoint}`, { method: "POST", headers: HEADERS, body: JSON.stringify({ text }), }); results[endpoint] = await response.json(); }) ); return { text, language: results.language.language, sentiment: results.sentiment.sentiment, confidence: results.sentiment.confidence, is_toxic: results.toxicity.is_toxic, entity_count: results.entities.entity_count, pii_found: results.pii.pii_found, }; } const analysis = await analyzeText( "John from Google in NYC emailed john@google.com — great product!" ); console.log(JSON.stringify(analysis, null, 2)); ``` -------------------------------- ### NLP Tools API Source: https://raw.githubusercontent.com/fasuizu-br/brainiall-nlp-api/main/llms-full.txt This section details the available NLP tools, their descriptions, and the parameters they accept. Each tool can be accessed via a specific endpoint. ```APIDOC ## POST /analyze/toxicity ### Description Detect toxic content across 6 categories. ### Method POST ### Endpoint /analyze/toxicity ### Parameters #### Request Body - **text** (string) - Required - The text to analyze for toxicity. ### Request Example ```json { "text": "This is a sample text to check for toxicity." } ``` ### Response #### Success Response (200) - **categories** (object) - A dictionary containing toxicity scores for each category. - **is_toxic** (boolean) - Indicates if the text is considered toxic. #### Response Example ```json { "categories": { "toxic": 0.1, "severe_toxic": 0.05, "obscene": 0.02, "threat": 0.01, "insult": 0.08, "identity_hate": 0.03 }, "is_toxic": false } ``` ## POST /analyze/sentiment ### Description Analyze the sentiment of the provided text, determining if it is positive or negative. ### Method POST ### Endpoint /analyze/sentiment ### Parameters #### Request Body - **text** (string) - Required - The text to analyze for sentiment. ### Request Example ```json { "text": "I am very happy with the service." } ``` ### Response #### Success Response (200) - **sentiment** (string) - The detected sentiment (e.g., 'positive', 'negative'). - **score** (float) - The confidence score for the sentiment prediction. #### Response Example ```json { "sentiment": "positive", "score": 0.95 } ``` ## POST /extract/entities ### Description Extract named entities (PER, ORG, LOC, MISC) from the given text. ### Method POST ### Endpoint /extract/entities ### Parameters #### Request Body - **text** (string) - Required - The text from which to extract entities. ### Request Example ```json { "text": "Apple is looking at buying U.K. startup for $1 billion." } ``` ### Response #### Success Response (200) - **entities** (array) - A list of detected entities, each with a type and value. #### Response Example ```json { "entities": [ {"type": "ORG", "value": "Apple"}, {"type": "GPE", "value": "U.K."}, {"type": "MONEY", "value": "$1 billion"} ] } ``` ## POST /detect/pii ### Description Detect Personally Identifiable Information (PII) such as emails, phone numbers, SSNs, and credit card numbers within the text. ### Method POST ### Endpoint /detect/pii ### Parameters #### Request Body - **text** (string) - Required - The text to scan for PII. ### Request Example ```json { "text": "Contact me at example@email.com or call 123-456-7890." } ``` ### Response #### Success Response (200) - **pii** (object) - A dictionary containing detected PII types and their values. #### Response Example ```json { "pii": { "emails": ["example@email.com"], "phones": ["123-456-7890"] } } ``` ## POST /detect/language ### Description Identify the language of the provided text from a list of 217 supported languages. ### Method POST ### Endpoint /detect/language ### Parameters #### Request Body - **text** (string) - Required - The text whose language needs to be detected. ### Request Example ```json { "text": "Bonjour le monde." } ``` ### Response #### Success Response (200) - **language** (string) - The detected language code (e.g., 'fr'). - **confidence** (float) - The confidence score for the language detection. #### Response Example ```json { "language": "fr", "confidence": 0.99 } ``` ## GET /check/nlp_service ### Description Perform a health check on the NLP service. ### Method GET ### Endpoint /check/nlp_service ### Parameters None ### Request Example (No request body needed for GET requests) ### Response #### Success Response (200) - **status** (string) - The status of the NLP service (e.g., 'ok'). #### Response Example ```json { "status": "ok" } ``` ``` -------------------------------- ### POST /language Source: https://raw.githubusercontent.com/fasuizu-br/brainiall-nlp-api/main/llms-full.txt Detects the language of the provided text. ```APIDOC ## POST /language ### Description Detects the language of the provided text. ### Method POST ### Endpoint /v1/nlp/language ### Parameters #### Request Body - **text** (string) - Required - The text for which to detect the language. ### Request Example ```json { "text": "Bonjour le monde" } ``` ### Response #### Success Response (200) - **language** (string) - The detected language code (e.g., "en", "fr"). #### Response Example ```json { "language": "fr" } ``` ``` -------------------------------- ### POST /language Source: https://raw.githubusercontent.com/fasuizu-br/brainiall-nlp-api/main/llms-full.txt Detects the language of the provided text from a list of 217 supported languages. ```APIDOC ## POST /language ### Description Detects the language of the provided text from a list of 217 supported languages. ### Method POST ### Endpoint /v1/nlp/language ### Parameters #### Request Body - **text** (string) - Required - The text to analyze for language detection. ### Request Example ```json { "text": "Your text to analyze" } ``` ### Response #### Success Response (200) - **text** (string) - The original text analyzed. - **language** (string) - The detected language code (e.g., "en" for English). - **confidence** (number) - The confidence score for the language detection. - **language_name** (string) - The full name of the detected language. #### Response Example ```json { "text": "Your text to analyze", "language": "en", "confidence": 0.9876, "language_name": "English" } ``` ``` -------------------------------- ### POST /toxicity Source: https://raw.githubusercontent.com/fasuizu-br/brainiall-nlp-api/main/llms-full.txt Detects toxic content across 6 categories in the provided text. It returns scores for each category and an overall toxicity assessment. ```APIDOC ## POST /toxicity ### Description Detects toxic content across 6 categories in the provided text. It returns scores for each category and an overall toxicity assessment. ### Method POST ### Endpoint /v1/nlp/toxicity ### Parameters #### Request Body - **text** (string) - Required - The text to analyze for toxicity. ### Request Example ```json { "text": "Your text to analyze" } ``` ### Response #### Success Response (200) - **text** (string) - The original text analyzed. - **is_toxic** (boolean) - Indicates if the text is considered toxic. - **scores** (object) - A dictionary of toxicity scores for different categories. - **toxic** (number) - Score for general toxicity. - **severe_toxic** (number) - Score for severe toxicity. - **obscene** (number) - Score for obscene language. - **threat** (number) - Score for threatening content. - **insult** (number) - Score for insults. - **identity_hate** (number) - Score for identity-based hate speech. - **max_score** (number) - The highest toxicity score among all categories. - **max_category** (string) - The category with the highest toxicity score. #### Response Example ```json { "text": "Your text to analyze", "is_toxic": false, "scores": { "toxic": 0.0012, "severe_toxic": 0.0001, "obscene": 0.0005, "threat": 0.0002, "insult": 0.0008, "identity_hate": 0.0001 }, "max_score": 0.0012, "max_category": "toxic" } ``` ``` -------------------------------- ### NLP API Configuration (JSON) Source: https://raw.githubusercontent.com/fasuizu-br/brainiall-nlp-api/main/llms-full.txt This JSON configuration specifies the endpoint URL and headers for the 'brainiall-nlp' MCP server. It is used to direct API requests to the correct service. ```json { "mcpServers": { "brainiall-nlp": { "url": "https://apim-ai-apis.azure-api.net/mcp/nlp/mcp", "headers": { "Accept": "application/json, text/event-stream" } } } } ``` -------------------------------- ### POST /toxicity Source: https://raw.githubusercontent.com/fasuizu-br/brainiall-nlp-api/main/llms-full.txt Analyzes the text to determine if it is toxic and returns a boolean indicating the result. ```APIDOC ## POST /toxicity ### Description Analyzes the text to determine if it is toxic and returns a boolean indicating the result. ### Method POST ### Endpoint /v1/nlp/toxicity ### Parameters #### Request Body - **text** (string) - Required - The text to analyze for toxicity. ### Request Example ```json { "text": "This is a wonderful day!" } ``` ### Response #### Success Response (200) - **is_toxic** (boolean) - True if the text is detected as toxic, false otherwise. #### Response Example ```json { "is_toxic": false } ``` ``` -------------------------------- ### Python: Batch Sentiment Analysis Source: https://raw.githubusercontent.com/fasuizu-br/brainiall-nlp-api/main/llms-full.txt Performs sentiment analysis on a list of reviews concurrently using Python's ThreadPoolExecutor. It sends requests to the NLP API's sentiment endpoint and aggregates the results to count positive and negative sentiments. Requires the 'requests' and 'concurrent.futures' libraries. ```python import requests from concurrent.futures import ThreadPoolExecutor import time BASE_URL = "https://apim-ai-apis.azure-api.net/v1/nlp" HEADERS = {"Authorization": "Bearer YOUR_KEY", "Content-Type": "application/json"} reviews = [ "Absolutely love this product! Best purchase ever.", "Terrible quality. Broke after one week.", "It's decent for the price. Nothing extraordinary.", "Amazing customer service! They resolved my issue immediately.", "Would not recommend. Very disappointing experience.", "Great value for money. Exactly what I needed.", "The worst experience I've had with any company.", "Exceeded my expectations in every way!", ] def analyze(text): resp = requests.post(f"{BASE_URL}/sentiment", headers=HEADERS, json={"text": text}) return resp.json() start = time.time() with ThreadPoolExecutor(max_workers=10) as pool: results = list(pool.map(analyze, reviews)) elapsed = time.time() - start positive = sum(1 for r in results if r["sentiment"] == "positive") negative = len(results) - positive print(f"Analyzed {len(reviews)} reviews in {elapsed:.2f}s") print(f"Positive: {positive}, Negative: {negative}") for text, result in zip(reviews, results): icon = "+" if result["sentiment"] == "positive" else "-" print(f" [{icon}] {result['confidence']:.3f} | {text[:60]}") ``` -------------------------------- ### Python: Content Moderation Pipeline Source: https://raw.githubusercontent.com/fasuizu-br/brainiall-nlp-api/main/llms-full.txt A Python function to perform a content moderation pipeline by checking text for toxicity, PII, and language using the Brainiall NLP API. It requires the 'requests' library and an API key for authentication. The function returns a dictionary summarizing the moderation results and suggesting an action. ```python import requests BASE_URL = "https://apim-ai-apis.azure-api.net/v1/nlp" HEADERS = {"Authorization": "Bearer YOUR_KEY", "Content-Type": "application/json"} def moderate_content(text: str) -> dict: """Run content moderation pipeline: toxicity + PII + language.""" # Check toxicity toxicity = requests.post(f"{BASE_URL}/toxicity", headers=HEADERS, json={"text": text}).json() # Check for PII pii = requests.post(f"{BASE_URL}/pii", headers=HEADERS, json={"text": text}).json() # Detect language language = requests.post(f"{BASE_URL}/language", headers=HEADERS, json={"text": text}).json() return { "text": text, "language": language["language"], "is_toxic": toxicity["is_toxic"], "toxic_categories": {k: v for k, v in toxicity["scores"].items() if v > 0.5}, "has_pii": pii["pii_found"], "pii_types": [e["type"] for e in pii.get("entities", [])], "action": "block" if toxicity["is_toxic"] else ("redact" if pii["pii_found"] else "allow") } # Usage result = moderate_content("Please contact John at john@example.com for details") print(f"Action: {result['action']}") print(f"Language: {result['language']}") print(f"PII found: {result['pii_types']}") ``` -------------------------------- ### POST /entities Source: https://raw.githubusercontent.com/fasuizu-br/brainiall-nlp-api/main/llms-full.txt Extracts named entities from the text using Named Entity Recognition (NER). It identifies entities like persons, organizations, and locations. ```APIDOC ## POST /entities ### Description Extracts named entities from the text using Named Entity Recognition (NER). It identifies entities like persons, organizations, and locations. ### Method POST ### Endpoint /v1/nlp/entities ### Parameters #### Request Body - **text** (string) - Required - The text to analyze for named entities. ### Request Example ```json { "text": "Your text to analyze" } ``` ### Response #### Success Response (200) - **text** (string) - The original text analyzed. - **entities** (array) - A list of detected entities. - **text** (string) - The text of the entity. - **label** (string) - The type of the entity (e.g., PER, ORG, LOC, MISC). - **start** (integer) - The starting character index of the entity in the text. - **end** (integer) - The ending character index of the entity in the text. - **score** (number) - The confidence score for the entity detection. - **entity_count** (integer) - The total number of entities detected. #### Response Example ```json { "text": "Your text to analyze", "entities": [ {"text": "Entity Name", "label": "PER", "start": 0, "end": 11, "score": 0.9987} ], "entity_count": 1 } ``` ``` -------------------------------- ### POST /entities Source: https://raw.githubusercontent.com/fasuizu-br/brainiall-nlp-api/main/llms-full.txt Extracts named entities (like persons, organizations, and locations) from the provided text. ```APIDOC ## POST /entities ### Description Extracts named entities (like persons, organizations, and locations) from the provided text. ### Method POST ### Endpoint /v1/nlp/entities ### Parameters #### Request Body - **text** (string) - Required - The text to extract entities from. ### Request Example ```json { "text": "Tim Cook, CEO of Apple Inc., announced the opening of a new office in Austin, Texas." } ``` ### Response #### Success Response (200) - **entities** (array) - An array of detected entities, each with a 'label' and 'text'. - **label** (string) - The type of entity (e.g., "PER", "ORG", "LOC"). - **text** (string) - The extracted entity text. - **entity_count** (integer) - The total number of entities found. #### Response Example ```json { "entities": [ {"label": "PER", "text": "Tim Cook"}, {"label": "ORG", "text": "Apple Inc."}, {"label": "LOC", "text": "Austin"}, {"label": "LOC", "text": "Texas"} ], "entity_count": 4 } ``` ``` -------------------------------- ### POST /pii Source: https://raw.githubusercontent.com/fasuizu-br/brainiall-nlp-api/main/llms-full.txt Detects Personally Identifiable Information (PII) within the text, such as email addresses, phone numbers, and credit card numbers. ```APIDOC ## POST /pii ### Description Detects Personally Identifiable Information (PII) within the text, such as email addresses, phone numbers, and credit card numbers. ### Method POST ### Endpoint /v1/nlp/pii ### Parameters #### Request Body - **text** (string) - Required - The text to analyze for PII. ### Request Example ```json { "text": "Your text to analyze" } ``` ### Response #### Success Response (200) - **text** (string) - The original text analyzed. - **pii_found** (boolean) - Indicates if any PII was found. - **entities** (array) - A list of detected PII entities. - **type** (string) - The type of PII detected (e.g., email, phone, ssn, credit_card). - **value** (string) - The detected PII value. - **start** (integer) - The starting character index of the PII in the text. - **end** (integer) - The ending character index of the PII in the text. - **pii_count** (integer) - The total number of PII entities detected. #### Response Example ```json { "text": "Your text to analyze", "pii_found": true, "entities": [ {"type": "email", "value": "user@example.com", "start": 10, "end": 26} ], "pii_count": 1 } ``` ``` -------------------------------- ### Python: Entity Extraction Pipeline Source: https://raw.githubusercontent.com/fasuizu-br/brainiall-nlp-api/main/llms-full.txt Extracts named entities (persons, organizations, locations) and personally identifiable information (PII like emails and phone numbers) from text using Python. It makes separate calls to the 'entities' and 'pii' endpoints of the NLP API. Requires the 'requests' library. ```python import requests BASE_URL = "https://apim-ai-apis.azure-api.net/v1/nlp" HEADERS = {"Authorization": "Bearer YOUR_KEY", "Content-Type": "application/json"} def extract_all_entities(text: str) -> dict: """Extract named entities and PII from text.""" ner = requests.post(f"{BASE_URL}/entities", headers=HEADERS, json={"text": text}).json() pii = requests.post(f"{BASE_URL}/pii", headers=HEADERS, json={"text": text}).json() return { "persons": [e["text"] for e in ner["entities"] if e["label"] == "PER"], "organizations": [e["text"] for e in ner["entities"] if e["label"] == "ORG"], "locations": [e["text"] for e in ner["entities"] if e["label"] == "LOC"], "emails": [e["value"] for e in pii.get("entities", []) if e["type"] == "email"], "phones": [e["value"] for e in pii.get("entities", []) if e["type"] == "phone"], } text = """ Tim Cook, CEO of Apple Inc., announced the opening of a new office in Austin, Texas. For inquiries, contact press@apple.com or call 1-800-275-2273. """ entities = extract_all_entities(text) print(f"Persons: {entities['persons']}") print(f"Organizations: {entities['organizations']}") print(f"Locations: {entities['locations']}") print(f"Emails: {entities['emails']}") print(f"Phones: {entities['phones']}") ``` -------------------------------- ### POST /pii Source: https://raw.githubusercontent.com/fasuizu-br/brainiall-nlp-api/main/llms-full.txt Detects and extracts Personally Identifiable Information (PII) such as email addresses and phone numbers from the text. ```APIDOC ## POST /pii ### Description Detects and extracts Personally Identifiable Information (PII) such as email addresses and phone numbers from the text. ### Method POST ### Endpoint /v1/nlp/pii ### Parameters #### Request Body - **text** (string) - Required - The text to scan for PII. ### Request Example ```json { "text": "Email me at test@test.com or call 123-456-7890." } ``` ### Response #### Success Response (200) - **entities** (array) - An array of detected PII entities, each with a 'type' and 'value'. - **type** (string) - The type of PII (e.g., "email", "phone"). - **value** (string) - The extracted PII value. - **pii_found** (boolean) - Indicates if any PII was found. #### Response Example ```json { "entities": [ {"type": "email", "value": "test@test.com"}, {"type": "phone", "value": "123-456-7890"} ], "pii_found": true } ``` ``` -------------------------------- ### POST /sentiment Source: https://raw.githubusercontent.com/fasuizu-br/brainiall-nlp-api/main/llms-full.txt Analyzes the sentiment of a given text and returns whether it is positive or negative, along with a confidence score. ```APIDOC ## POST /sentiment ### Description Analyzes the sentiment of a given text and returns whether it is positive or negative, along with a confidence score. ### Method POST ### Endpoint /v1/nlp/sentiment ### Parameters #### Request Body - **text** (string) - Required - The text to analyze. ### Request Example ```json { "text": "Absolutely love this product! Best purchase ever." } ``` ### Response #### Success Response (200) - **sentiment** (string) - The detected sentiment (e.g., "positive", "negative"). - **confidence** (number) - The confidence score for the sentiment detection. #### Response Example ```json { "sentiment": "positive", "confidence": 0.9876 } ``` ``` -------------------------------- ### POST /sentiment Source: https://raw.githubusercontent.com/fasuizu-br/brainiall-nlp-api/main/llms-full.txt Classifies the sentiment of the provided text, indicating whether it is positive or negative, along with a confidence score. ```APIDOC ## POST /sentiment ### Description Classifies the sentiment of the provided text, indicating whether it is positive or negative, along with a confidence score. ### Method POST ### Endpoint /v1/nlp/sentiment ### Parameters #### Request Body - **text** (string) - Required - The text to analyze for sentiment. ### Request Example ```json { "text": "Your text to analyze" } ``` ### Response #### Success Response (200) - **text** (string) - The original text analyzed. - **sentiment** (string) - The classified sentiment (e.g., "positive", "negative"). - **confidence** (number) - The confidence score for the sentiment classification. - **scores** (object) - A dictionary of sentiment scores. - **positive** (number) - Score for positive sentiment. - **negative** (number) - Score for negative sentiment. #### Response Example ```json { "text": "Your text to analyze", "sentiment": "positive", "confidence": 0.9847, "scores": { "positive": 0.9847, "negative": 0.0153 } } ``` ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.