File size: 7,403 Bytes
6c6cb12
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
```python
"""
Janus Scanner Pro - OpenRouter API Integration
API Configuration and Model Integration Examples
"""

from openai import OpenAI
import json
# Configuration
API_KEY = "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"
BASE_URL = "https://openrouter.ai/api/v1"

# Initialize OpenRouter client
client = OpenAI(
    base_url=BASE_URL,
    api_key=API_KEY,
)
class JanusAPIIntegration:
    """Main class for Janus Scanner API integrations"""
    
    def __init__(self):
        self.client = client
        self.base_headers = {
            "HTTP-Referer": "https://janus-scanner-pro.com",
            "X-Title": "Janus Scanner Pro"
        }
    
    def text_analysis(self, text, model="deepseek/deepseek-chat-v3.1:free"):
        """Analyze text for fraud detection patterns"""
        messages = [
            {
                "role": "system",
                "content": "You are a financial fraud detection expert. Analyze the provided text for suspicious patterns, anomalies, and potential fraud indicators."
            },
            {
                "role": "user",
                "content": f"Analyze this financial data for fraud patterns: {text}"
            }
        ]
        
        completion = self.client.chat.completions.create(
            extra_headers=self.base_headers,
            model=model,
            messages=messages
        )
        return completion.choices[0].message.content
    
    def document_analysis(self, text, model="google/gemma-3-27b-it:free"):
        """Advanced document analysis with vision capabilities"""
        messages = [
            {
                "role": "user",
                "content": [
                    {
                        "type": "text",
                        "text": "Analyze this financial document for compliance issues, suspicious transactions, and regulatory violations."
                    },
                    {
                        "type": "text",
                        "text": text
                    }
                ]
            }
        ]
        
        completion = self.client.chat.completions.create(
            extra_headers=self.base_headers,
            model=model,
            messages=messages
        )
        return completion.choices[0].message.content
    
    def risk_assessment(self, transaction_data, model="nousresearch/hermes-3-llama-3.1-405b:free"):
        """Generate risk assessment for financial transactions"""
        messages = [
            {
                "role": "system",
                "content": "You are a risk assessment expert. Analyze transaction data and provide detailed risk scores and recommendations."
            },
            {
                "role": "user",
                "content": f"Assess the risk level for these transactions and provide recommendations: {transaction_data}"
            }
        ]
        
        completion = self.client.chat.completions.create(
            extra_headers=self.base_headers,
            model=model,
            messages=messages
        )
        return completion.choices[0].message.content

# Model configurations for different use cases
MODEL_CONFIGS = {
    "text_analysis": {
        "default": "deepseek/deepseek-chat-v3.1:free",
        "fast": "meituan/longcat-flash-chat:free",
        "high_capacity": "nousresearch/hermes-3-llama-3.1-405b:free"
    },
    "image_analysis": {
        "default": "google/gemma-3-27b-it:free",
        "specialized": "mistralai/mistral-small-3.2-24b-instruct:free"
    },
    "complex_reasoning": {
        "default": "nousresearch/hermes-3-llama-3.1-405b:free"
    }
}

def run_examples():
    """Run example API calls"""
    
    # Example 1: Text Analysis with DeepSeek
    print("=== Example 1: DeepSeek Text Analysis ===")
    janus = JanusAPIIntegration()
    
    sample_financial_text = """
    Transaction Report:
    - $15,000 cash withdrawal from account ending 1234
    - Multiple $9,999 transactions within 1 hour
    - International wire transfer to unknown entity
    - Account balance: $0 after suspicious activities
    """
    
    result1 = janus.text_analysis(sample_financial_text)
    print("Analysis Result:", result1)
    print()
    
    # Example 2: Document Analysis with Gemma
    print("=== Example 2: Gemma Document Analysis ===")
    sample_document = """
    Quarterly Report Q4 2024:
    Revenue: $2,450,000
    Expenses: $2,100,000
    Unknown expenses: $350,000 (marked as 'miscellaneous')
    Cash payments: $180,000 (cash only, no receipts)
    Related party transactions: $120,000 to entity with same address
    """
    
    result2 = janus.document_analysis(sample_document)
    print("Document Analysis:", result2)
    print()
    
    # Example 3: Risk Assessment with Hermes
    print("=== Example 3: Hermes Risk Assessment ===")
    transaction_data = [
        {"amount": 9999, "type": "withdrawal", "time": "23:45"},
        {"amount": 9999, "type": "withdrawal", "time": "23:46"},
        {"amount": 9999, "type": "withdrawal", "time": "23:47"},
        {"amount": 15000, "type": "wire_transfer", "account": "unknown"},
        {"amount": 5000, "type": "cash_deposit", "location": "different_city"}
    ]
    
    result3 = janus.risk_assessment(json.dumps(transaction_data))
    print("Risk Assessment:", result3)
    print()
    
    # Example 4: Fast Analysis with Longcat
    print("=== Example 4: Longcat Fast Analysis ===")
    messages = [
        {
            "role": "user",
            "content": "Quickly identify the main fraud indicators in this data: Multiple round number transactions, cash payments, and international transfers"
        }
    ]
    
    completion = client.chat.completions.create(
        extra_headers={
            "HTTP-Referer": "https://janus-scanner-pro.com",
            "X-Title": "Janus Scanner Pro"
        },
        model="meituan/longcat-flash-chat:free",
        messages=messages
    )
    
    print("Fast Analysis:", completion.choices[0].message.content)
    print()
    
    # Example 5: Multi-step Analysis Workflow
    print("=== Example 5: Multi-step Analysis ===")
    def comprehensive_analysis(data):
        # Step 1: Initial scan
        scan_result = janus.text_analysis(data, "meituan/longcat-flash-chat:free")
        
        # Step 2: Deep analysis if suspicious
        if "suspicious" in scan_result.lower():
            detailed_result = janus.risk_assessment(data, "nousresearch/hermes-3-llama-3.1-405b:free")
            return {
                "scan_result": scan_result,
                "detailed_analysis": detailed_result,
                "risk_level": "HIGH"
            }
        else:
            return {
                "scan_result": scan_result,
                "risk_level": "LOW"
            }
    
    test_data = "Multiple $9999 transactions, cash deposits, international transfers"
    workflow_result = comprehensive_analysis(test_data)
    print("Comprehensive Analysis:", json.dumps(workflow_result, indent=2))

if __name__ == "__main__":
    print("Janus Scanner Pro - OpenRouter API Integration")
    print("=" * 50)
    print("Available Models:")
    for category, models in MODEL_CONFIGS.items():
        print(f"\n{category.upper()}:")
        for name, model in models.items():
            print(f"  {name}: {model}")
    
    print("\n" + "=" * 50)
    run_examples()
```
```