# Opinion Compass Agent (`jan.turon/opinion-compass`) Actor

An AI agent that analyzes individuals' stances on specific statements using public social media data. You enter a person's name and an opinion statement, and the Actor evaluates multiple sources to provide a detailed assessment with supporting evidence. The agent is built using LangGraph and Python.

- **URL**: https://apify.com/jan.turon/opinion-compass.md
- **Developed by:** [Jan Turoň](https://apify.com/jan.turon) (community)
- **Categories:** Agents, Open source
- **Stats:** 78 total users, 0 monthly users, 0.0% runs succeeded, 4 bookmarks
- **User rating**: No ratings yet

## Pricing

from $10.00 / 1,000 ai analyses

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## Opinion Compass

[![Actor badge](https://apify.com/actor-badge?actor=jan.turon/opinion-compass)](https://apify.com/jan.turon/opinion-compass)
[![GitHub Repo stars](https://img.shields.io/github/stars/HonzaTuron/opinion-compass)](https://github.com/HonzaTuron/opinion-compass)

### Introduction and Features

The Opinion Compass is designed to analyze the opinions of individuals based on specified statements. Users can simply provide the name of the person whose opinions they want to analyze along with the specific opinion statement.

Key functionalities:

- **AI Analysis:** Leverages AI technology to provide analysis on the provided opinions.
- **Evidence Consideration:** Includes various pieces of evidence that influence the final analysis, enhancing the comprehensiveness of the insights.

![Opinion Compass Logo](compass.png)

#### Evidence Scoring

The Opinion Compass analyzes multiple pieces of evidence and provides detailed scoring:

Each piece of evidence is evaluated with two key metrics:

- **Opinion Score (-1.0 to 1.0)**: Indicates how strongly the evidence supports or opposes the opinion
  - 1.0: Strongly supports the opinion
  - 0.0: Neutral stance
  - -1.0: Strongly opposes the opinion
- **Relevance Score (0.0 to 1.0)**: Shows how relevant the evidence is to the opinion
  - 1.0: Highly relevant evidence
  - 0.0: Not relevant

Example output of single evidence data point:

```json
    {
        "source": "X/Twitter",
        "score": -0.8,
        "relevance": 1,
        "text": "This declaration is a sad testament of bad Brusselian leadership. While President @realDonaldTrump and President Putin negotiate on peace, EU officials issue worthless statements.\n\nYou can’t request a seat at the negotiating table. You have to earn it! Through strength, good leadership and smart diplomacy.\n\nThe position of Brussels - to support killing as long as it takes - is morally and politically unacceptable.",
        "url": "https://x.com/PM_ViktorOrban/status/1889976335897899377"
    }
```

#### Aggregated Score

The system produces a final aggregated score (-1.0 to 1.0) that considers all pieces of evidence, weighted by their relevance. This provides a comprehensive assessment of the person's stance on the given opinion.

### Tutorial Section

#### How to use Opinion Compass to analyze opinions

1. Ensure you have an Apify account.
2. Create a new Actor run with the following input JSON:

```json
{
  "person": "Name of person you want to analyze, e.g. Donald Trump",
  "opinion": "Opinion statement you want to analyze, e.g. 'USA should always come first.'"
}
```

3. Run the Actor and retrieve the final analysis as output.

### Pricing Explanation

The Opinion Compass operates on a **Pay Per Event** pricing model

What is charged for
| Feature                | Description                                             | Price    |
|------------------------|---------------------------------------------------------|----------|
| Actor Start per 1 GB   | Flat fee for starting an Actor run for each 1 GB of memory | $0.005  |
| AI Analysis            | Produces final AI analysis| $0.01   |
| Piece of Evidence      | Additional fee for each piece of evidence considered. | $0.02   |

### Input and Output Examples

#### Input requirements

The following JSON input format must be used when running the Actor:

```json
{
  "person": "Tomio Okamura",
  "opinion": "Democratic values are important."
}
```

#### Expected Output

The output from the Actor will be structured in JSON as stored in the default KV store under `ai-analysis` as follows:

```json
{
  "analysis": {
    "person": "Tomio Okamura",
    "opinion": "Democratic values are important.",
    "score": 0.5,
    "explanation": "The score is based on the evidence that the person identifies with the opinion. It ranges from -1.0 to 1.0. The higher the score, the more the person identifies with the opinion. 1 means strong identification, -1 means strong opposition, 0 means inconclusive evidence.",
  }
}
```

### FAQ, Disclaimers, and Support

- **Can I use the Opinion Compass for any public opinion?**
  Yes, as long as the opinion is public and can be addressed ethically.

- **What should I do if I encounter errors?**
  Check your input format and ensure required fields are included. If issues persist, consult the support channels.
  You are only charged for the results if they can be produced.

- **How accurate are the results?**
  The accuracy depends on the available evidence and context. The system uses advanced AI models but results should be considered as analytical insights rather than definitive truth.

- **What sources does Opinion Compass use?**
  The system analyzes publicly available information from X(Twitter) and Instagram. More sources will be added in the future.

- **How recent is the analyzed data?**
  The system analyzes the most recent data available.

- **Can I analyze multiple opinions at once?**
  Currently, the system processes one person-opinion pair at a time. For multiple analyses, you'll need to run separate queries.

- **How long does an analysis typically take?**
  Analysis time varies based on the complexity and amount of available evidence, but typically takes a few minutes to complete.

- **Is there a limit to the number of analyses I can run?**
  No, but standard pricing applies to each analysis run. Consider your usage needs and budget accordingly.

For further assistance, please create an issue or contact the author.

### Feedback

Your feedback is important to us! If you have suggestions or find any issues, please reach out.

# Actor input Schema

## `person` (type: `string`):

Person whose opinions you want to analyze.

## `opinion` (type: `string`):

Opinion you want to analyze for given person.

## Actor input object example

```json
{
  "person": "Donald Trump",
  "opinion": "USA should always come first."
}
```

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "person": "Donald Trump",
    "opinion": "USA should always come first."
};

// Run the Actor and wait for it to finish
const run = await client.actor("jan.turon/opinion-compass").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "person": "Donald Trump",
    "opinion": "USA should always come first.",
}

# Run the Actor and wait for it to finish
run = client.actor("jan.turon/opinion-compass").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "person": "Donald Trump",
  "opinion": "USA should always come first."
}' |
apify call jan.turon/opinion-compass --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,jan.turon/opinion-compass"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/okXfaDO7XNcqGS2Vx/builds/28OtcePLFImzwF08c/openapi.json
