arionxiv 1.0.32__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- arionxiv/__init__.py +40 -0
- arionxiv/__main__.py +10 -0
- arionxiv/arxiv_operations/__init__.py +0 -0
- arionxiv/arxiv_operations/client.py +225 -0
- arionxiv/arxiv_operations/fetcher.py +173 -0
- arionxiv/arxiv_operations/searcher.py +122 -0
- arionxiv/arxiv_operations/utils.py +293 -0
- arionxiv/cli/__init__.py +4 -0
- arionxiv/cli/commands/__init__.py +1 -0
- arionxiv/cli/commands/analyze.py +587 -0
- arionxiv/cli/commands/auth.py +365 -0
- arionxiv/cli/commands/chat.py +714 -0
- arionxiv/cli/commands/daily.py +482 -0
- arionxiv/cli/commands/fetch.py +217 -0
- arionxiv/cli/commands/library.py +295 -0
- arionxiv/cli/commands/preferences.py +426 -0
- arionxiv/cli/commands/search.py +254 -0
- arionxiv/cli/commands/settings_unified.py +1407 -0
- arionxiv/cli/commands/trending.py +41 -0
- arionxiv/cli/commands/welcome.py +168 -0
- arionxiv/cli/main.py +407 -0
- arionxiv/cli/ui/__init__.py +1 -0
- arionxiv/cli/ui/global_theme_manager.py +173 -0
- arionxiv/cli/ui/logo.py +127 -0
- arionxiv/cli/ui/splash.py +89 -0
- arionxiv/cli/ui/theme.py +32 -0
- arionxiv/cli/ui/theme_system.py +391 -0
- arionxiv/cli/utils/__init__.py +54 -0
- arionxiv/cli/utils/animations.py +522 -0
- arionxiv/cli/utils/api_client.py +583 -0
- arionxiv/cli/utils/api_config.py +505 -0
- arionxiv/cli/utils/command_suggestions.py +147 -0
- arionxiv/cli/utils/db_config_manager.py +254 -0
- arionxiv/github_actions_runner.py +206 -0
- arionxiv/main.py +23 -0
- arionxiv/prompts/__init__.py +9 -0
- arionxiv/prompts/prompts.py +247 -0
- arionxiv/rag_techniques/__init__.py +8 -0
- arionxiv/rag_techniques/basic_rag.py +1531 -0
- arionxiv/scheduler_daemon.py +139 -0
- arionxiv/server.py +1000 -0
- arionxiv/server_main.py +24 -0
- arionxiv/services/__init__.py +73 -0
- arionxiv/services/llm_client.py +30 -0
- arionxiv/services/llm_inference/__init__.py +58 -0
- arionxiv/services/llm_inference/groq_client.py +469 -0
- arionxiv/services/llm_inference/llm_utils.py +250 -0
- arionxiv/services/llm_inference/openrouter_client.py +564 -0
- arionxiv/services/unified_analysis_service.py +872 -0
- arionxiv/services/unified_auth_service.py +457 -0
- arionxiv/services/unified_config_service.py +456 -0
- arionxiv/services/unified_daily_dose_service.py +823 -0
- arionxiv/services/unified_database_service.py +1633 -0
- arionxiv/services/unified_llm_service.py +366 -0
- arionxiv/services/unified_paper_service.py +604 -0
- arionxiv/services/unified_pdf_service.py +522 -0
- arionxiv/services/unified_prompt_service.py +344 -0
- arionxiv/services/unified_scheduler_service.py +589 -0
- arionxiv/services/unified_user_service.py +954 -0
- arionxiv/utils/__init__.py +51 -0
- arionxiv/utils/api_helpers.py +200 -0
- arionxiv/utils/file_cleanup.py +150 -0
- arionxiv/utils/ip_helper.py +96 -0
- arionxiv-1.0.32.dist-info/METADATA +336 -0
- arionxiv-1.0.32.dist-info/RECORD +69 -0
- arionxiv-1.0.32.dist-info/WHEEL +5 -0
- arionxiv-1.0.32.dist-info/entry_points.txt +4 -0
- arionxiv-1.0.32.dist-info/licenses/LICENSE +21 -0
- arionxiv-1.0.32.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Centralized Prompt Templates for ArionXiv
|
|
3
|
+
|
|
4
|
+
Prompts are stored in MongoDB and fetched on-demand with TTL caching.
|
|
5
|
+
Admin can edit prompts directly in the database (prompts collection).
|
|
6
|
+
|
|
7
|
+
Fallback prompts are used when database is unavailable.
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
from typing import Dict, Any, Optional
|
|
11
|
+
import asyncio
|
|
12
|
+
import logging
|
|
13
|
+
|
|
14
|
+
logger = logging.getLogger(__name__)
|
|
15
|
+
|
|
16
|
+
# ============================================================================
|
|
17
|
+
# FALLBACK PROMPTS - Used when database is unavailable
|
|
18
|
+
# Master prompts are stored in MongoDB (prompts collection)
|
|
19
|
+
# ============================================================================
|
|
20
|
+
|
|
21
|
+
DEFAULT_PROMPTS: Dict[str, str] = {
|
|
22
|
+
|
|
23
|
+
"comprehensive_paper_analysis": """You are an expert research analyst. Analyze this research paper thoroughly.
|
|
24
|
+
|
|
25
|
+
Paper Content:
|
|
26
|
+
{content}
|
|
27
|
+
|
|
28
|
+
IMPORTANT: You MUST respond with ONLY valid JSON. No explanations, no markdown, no text before or after the JSON.
|
|
29
|
+
|
|
30
|
+
Return EXACTLY this JSON structure (replace placeholders with your analysis):
|
|
31
|
+
{{
|
|
32
|
+
"summary": "A comprehensive 3-4 sentence summary of the paper's main contribution and findings",
|
|
33
|
+
"key_findings": ["Finding 1", "Finding 2", "Finding 3", "Finding 4"],
|
|
34
|
+
"methodology": "Description of the research methodology, algorithms, or experimental approach used",
|
|
35
|
+
"strengths": ["Strength 1", "Strength 2", "Strength 3"],
|
|
36
|
+
"limitations": ["Limitation 1", "Limitation 2"],
|
|
37
|
+
"technical_details": "Detailed technical explanation of the core innovations, architectures, or implementations",
|
|
38
|
+
"broader_impact": "Analysis of the paper's broader implications, applications, and future research directions",
|
|
39
|
+
"confidence_score": 0.85,
|
|
40
|
+
"relevance_tags": ["tag1", "tag2", "tag3"],
|
|
41
|
+
"technical_level": "intermediate",
|
|
42
|
+
"novelty_score": 0.8,
|
|
43
|
+
"impact_potential": "Description of the potential real-world impact"
|
|
44
|
+
}}
|
|
45
|
+
|
|
46
|
+
Remember: Output ONLY the JSON object. No other text.""",
|
|
47
|
+
|
|
48
|
+
"enhanced_paper_analysis": """You are an elite research analyst. Provide an exceptionally thorough analysis of this research paper.
|
|
49
|
+
|
|
50
|
+
Paper Content:
|
|
51
|
+
{content}
|
|
52
|
+
|
|
53
|
+
Provide a detailed analysis in JSON format with: summary, key_findings, methodology, strengths, limitations, technical_details, broader_impact, confidence_score, relevance_tags, technical_level.""",
|
|
54
|
+
|
|
55
|
+
"paper_analysis": """Analyze this research paper comprehensively.
|
|
56
|
+
|
|
57
|
+
Title: {title}
|
|
58
|
+
Abstract: {abstract}
|
|
59
|
+
Content: {content}
|
|
60
|
+
|
|
61
|
+
Provide JSON with: summary, key_findings, methodology, strengths, limitations.""",
|
|
62
|
+
|
|
63
|
+
"quick_analysis": """Provide a quick analysis of this paper.
|
|
64
|
+
|
|
65
|
+
Title: {title}
|
|
66
|
+
Abstract: {abstract}
|
|
67
|
+
|
|
68
|
+
Return JSON with: summary, main_contribution, relevance_score.""",
|
|
69
|
+
|
|
70
|
+
"research_analysis": """Analyze this research paper in depth.
|
|
71
|
+
|
|
72
|
+
Title: {title}
|
|
73
|
+
Content: {content}
|
|
74
|
+
|
|
75
|
+
Provide JSON with: detailed_summary, methodology, findings, implications.""",
|
|
76
|
+
|
|
77
|
+
"summary_analysis": """Provide a summary analysis of this paper.
|
|
78
|
+
|
|
79
|
+
Content: {content}
|
|
80
|
+
|
|
81
|
+
Focus on key points and main contributions.""",
|
|
82
|
+
|
|
83
|
+
"detailed_analysis": """Provide a detailed analysis of this paper.
|
|
84
|
+
|
|
85
|
+
Content: {content}
|
|
86
|
+
|
|
87
|
+
Include methodology, findings, strengths, and limitations.""",
|
|
88
|
+
|
|
89
|
+
"technical_analysis": """Provide a technical analysis of this paper.
|
|
90
|
+
|
|
91
|
+
Content: {content}
|
|
92
|
+
|
|
93
|
+
Focus on technical contributions, algorithms, and implementation details.""",
|
|
94
|
+
|
|
95
|
+
"insights_analysis": """Extract key insights from this paper.
|
|
96
|
+
|
|
97
|
+
Content: {content}
|
|
98
|
+
|
|
99
|
+
Provide actionable insights and implications for the field.""",
|
|
100
|
+
|
|
101
|
+
"daily_dose_analysis": """Analyze this research paper and provide a thorough analysis.
|
|
102
|
+
|
|
103
|
+
Title: {title}
|
|
104
|
+
|
|
105
|
+
Authors: {authors}
|
|
106
|
+
|
|
107
|
+
Categories: {categories}
|
|
108
|
+
|
|
109
|
+
Abstract: {abstract}
|
|
110
|
+
|
|
111
|
+
Provide a structured analysis with the following sections:
|
|
112
|
+
1. SUMMARY: A concise 2-3 sentence summary of the paper's main contribution.
|
|
113
|
+
2. KEY FINDINGS: List the 3-4 most important findings or contributions (as numbered items).
|
|
114
|
+
3. METHODOLOGY: Brief description of the approach or methods used.
|
|
115
|
+
4. SIGNIFICANCE: Why this paper matters and its potential impact.
|
|
116
|
+
5. LIMITATIONS: Any noted limitations or areas for future work.
|
|
117
|
+
6. RELEVANCE SCORE: Rate from 1-10 how impactful this paper is for practitioners.
|
|
118
|
+
|
|
119
|
+
IMPORTANT: Do NOT use any markdown formatting (no asterisks, no bold, no headers). Write in plain text only.
|
|
120
|
+
Be concise but thorough. Focus on actionable insights.""",
|
|
121
|
+
|
|
122
|
+
"trend_analysis": """You are a research trend analyst. Based on the following research papers, generate insights about current trends and directions.
|
|
123
|
+
|
|
124
|
+
Papers:
|
|
125
|
+
{papers_data}
|
|
126
|
+
|
|
127
|
+
Analyze: emerging trends, common methodologies, novel approaches, cross-paper themes, future opportunities, field evolution.""",
|
|
128
|
+
|
|
129
|
+
"enhanced_trend_analysis": """You are an expert research trend analyst. Analyze the following papers for emerging trends and patterns.
|
|
130
|
+
|
|
131
|
+
Papers:
|
|
132
|
+
{papers_data}
|
|
133
|
+
|
|
134
|
+
Provide JSON with: emerging_trends, common_themes, methodology_patterns, future_directions, key_insights.""",
|
|
135
|
+
|
|
136
|
+
"paper_summary": """Summarize the following collection of research papers concisely.
|
|
137
|
+
|
|
138
|
+
Papers:
|
|
139
|
+
{papers_data}
|
|
140
|
+
|
|
141
|
+
Provide a brief, coherent summary of the main themes and contributions.""",
|
|
142
|
+
|
|
143
|
+
"personalized_recommendations": """Based on the user's research interests and history, recommend relevant research directions.
|
|
144
|
+
|
|
145
|
+
User Profile:
|
|
146
|
+
{user_profile}
|
|
147
|
+
|
|
148
|
+
Recent Activity:
|
|
149
|
+
{recent_activity}
|
|
150
|
+
|
|
151
|
+
Provide JSON with: recommended_topics, suggested_papers, emerging_areas, learning_path.""",
|
|
152
|
+
|
|
153
|
+
"rag_chat": """You are an AI research assistant helping users understand research papers. Your role is to provide accurate, helpful answers based on the paper content.
|
|
154
|
+
|
|
155
|
+
PAPER METADATA:
|
|
156
|
+
Title: {paper_title}
|
|
157
|
+
Authors: {paper_authors}
|
|
158
|
+
Published on arXiv: {paper_published}
|
|
159
|
+
|
|
160
|
+
RELEVANT SECTIONS FROM THE PAPER:
|
|
161
|
+
{context}
|
|
162
|
+
|
|
163
|
+
CONVERSATION HISTORY:
|
|
164
|
+
{history}
|
|
165
|
+
|
|
166
|
+
USER QUESTION: {message}
|
|
167
|
+
|
|
168
|
+
Instructions:
|
|
169
|
+
- You are discussing the paper "{paper_title}" - always remember and reference this title when asked about which paper you're discussing
|
|
170
|
+
- Provide comprehensive, detailed answers using specific details from the paper
|
|
171
|
+
- Quote relevant passages when appropriate
|
|
172
|
+
- If the answer is not in the provided context, say so clearly
|
|
173
|
+
- Be conversational but maintain technical accuracy
|
|
174
|
+
- Structure longer answers with clear sections""",
|
|
175
|
+
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
# ============================================================================
|
|
180
|
+
# PROMPT SERVICE INTEGRATION
|
|
181
|
+
# ============================================================================
|
|
182
|
+
|
|
183
|
+
try:
|
|
184
|
+
from ..services.unified_prompt_service import unified_prompt_service
|
|
185
|
+
PROMPT_SERVICE_AVAILABLE = True
|
|
186
|
+
except ImportError:
|
|
187
|
+
PROMPT_SERVICE_AVAILABLE = False
|
|
188
|
+
# Debug level - this is expected during module initialization
|
|
189
|
+
logger.debug("UnifiedPromptService not available - using fallback prompts")
|
|
190
|
+
|
|
191
|
+
def format_prompt(prompt_name: str, **kwargs) -> str:
|
|
192
|
+
"""
|
|
193
|
+
Format a prompt template with provided variables.
|
|
194
|
+
Fetches from MongoDB with caching, falls back to local prompts if unavailable.
|
|
195
|
+
"""
|
|
196
|
+
if PROMPT_SERVICE_AVAILABLE:
|
|
197
|
+
try:
|
|
198
|
+
try:
|
|
199
|
+
loop = asyncio.get_running_loop()
|
|
200
|
+
raise RuntimeError("In async context")
|
|
201
|
+
except RuntimeError:
|
|
202
|
+
try:
|
|
203
|
+
loop = asyncio.get_event_loop()
|
|
204
|
+
if loop.is_closed():
|
|
205
|
+
loop = asyncio.new_event_loop()
|
|
206
|
+
asyncio.set_event_loop(loop)
|
|
207
|
+
except RuntimeError:
|
|
208
|
+
loop = asyncio.new_event_loop()
|
|
209
|
+
asyncio.set_event_loop(loop)
|
|
210
|
+
|
|
211
|
+
if not loop.is_running():
|
|
212
|
+
formatted = loop.run_until_complete(
|
|
213
|
+
unified_prompt_service.format_prompt(prompt_name, **kwargs)
|
|
214
|
+
)
|
|
215
|
+
return formatted
|
|
216
|
+
|
|
217
|
+
except Exception as e:
|
|
218
|
+
logger.debug(f"Using fallback prompt for {prompt_name}: {str(e)}")
|
|
219
|
+
|
|
220
|
+
# Fallback to local prompts
|
|
221
|
+
if prompt_name in DEFAULT_PROMPTS:
|
|
222
|
+
return DEFAULT_PROMPTS[prompt_name].format(**kwargs)
|
|
223
|
+
else:
|
|
224
|
+
logger.warning(f"Unknown prompt '{prompt_name}', using generic template")
|
|
225
|
+
return f"Process the following with context: {kwargs}"
|
|
226
|
+
|
|
227
|
+
async def format_prompt_async(prompt_name: str, **kwargs) -> str:
|
|
228
|
+
"""
|
|
229
|
+
Async version of format_prompt for use in async contexts.
|
|
230
|
+
"""
|
|
231
|
+
if PROMPT_SERVICE_AVAILABLE:
|
|
232
|
+
try:
|
|
233
|
+
return await unified_prompt_service.format_prompt(prompt_name, **kwargs)
|
|
234
|
+
except Exception as e:
|
|
235
|
+
logger.debug(f"Using fallback prompt for {prompt_name}: {str(e)}")
|
|
236
|
+
|
|
237
|
+
# Fallback to local prompts
|
|
238
|
+
if prompt_name in DEFAULT_PROMPTS:
|
|
239
|
+
return DEFAULT_PROMPTS[prompt_name].format(**kwargs)
|
|
240
|
+
else:
|
|
241
|
+
logger.warning(f"Unknown prompt '{prompt_name}', using generic template")
|
|
242
|
+
return f"Process the following with context: {kwargs}"
|
|
243
|
+
|
|
244
|
+
|
|
245
|
+
def get_all_prompts() -> Dict[str, str]:
|
|
246
|
+
"""Get all available prompt names"""
|
|
247
|
+
return DEFAULT_PROMPTS
|