cite-agent 1.3.5__py3-none-any.whl → 1.3.7__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.

Potentially problematic release.


This version of cite-agent might be problematic. Click here for more details.

Files changed (37) hide show
  1. cite_agent/__version__.py +1 -1
  2. cite_agent/cli.py +22 -2
  3. cite_agent/enhanced_ai_agent.py +407 -82
  4. cite_agent/project_detector.py +148 -0
  5. {cite_agent-1.3.5.dist-info → cite_agent-1.3.7.dist-info}/METADATA +1 -1
  6. cite_agent-1.3.7.dist-info/RECORD +31 -0
  7. {cite_agent-1.3.5.dist-info → cite_agent-1.3.7.dist-info}/top_level.txt +0 -1
  8. cite_agent-1.3.5.dist-info/RECORD +0 -56
  9. src/__init__.py +0 -1
  10. src/services/__init__.py +0 -132
  11. src/services/auth_service/__init__.py +0 -3
  12. src/services/auth_service/auth_manager.py +0 -33
  13. src/services/graph/__init__.py +0 -1
  14. src/services/graph/knowledge_graph.py +0 -194
  15. src/services/llm_service/__init__.py +0 -5
  16. src/services/llm_service/llm_manager.py +0 -495
  17. src/services/paper_service/__init__.py +0 -5
  18. src/services/paper_service/openalex.py +0 -231
  19. src/services/performance_service/__init__.py +0 -1
  20. src/services/performance_service/rust_performance.py +0 -395
  21. src/services/research_service/__init__.py +0 -23
  22. src/services/research_service/chatbot.py +0 -2056
  23. src/services/research_service/citation_manager.py +0 -436
  24. src/services/research_service/context_manager.py +0 -1441
  25. src/services/research_service/conversation_manager.py +0 -597
  26. src/services/research_service/critical_paper_detector.py +0 -577
  27. src/services/research_service/enhanced_research.py +0 -121
  28. src/services/research_service/enhanced_synthesizer.py +0 -375
  29. src/services/research_service/query_generator.py +0 -777
  30. src/services/research_service/synthesizer.py +0 -1273
  31. src/services/search_service/__init__.py +0 -5
  32. src/services/search_service/indexer.py +0 -186
  33. src/services/search_service/search_engine.py +0 -342
  34. src/services/simple_enhanced_main.py +0 -287
  35. {cite_agent-1.3.5.dist-info → cite_agent-1.3.7.dist-info}/WHEEL +0 -0
  36. {cite_agent-1.3.5.dist-info → cite_agent-1.3.7.dist-info}/entry_points.txt +0 -0
  37. {cite_agent-1.3.5.dist-info → cite_agent-1.3.7.dist-info}/licenses/LICENSE +0 -0
@@ -1,287 +0,0 @@
1
- """
2
- Simple Enhanced Main Application - Working version with core capabilities
3
- """
4
-
5
- import asyncio
6
- import logging
7
- import os
8
- import time
9
- from datetime import datetime, timezone
10
- from fastapi import FastAPI, Request, HTTPException
11
- from fastapi.middleware.cors import CORSMiddleware
12
- from fastapi.responses import JSONResponse
13
- from pydantic import BaseModel
14
- from typing import Optional, Dict, Any
15
-
16
- # Import our enhanced services
17
- from services.reasoning_engine.reasoning_engine import ReasoningEngine
18
- from services.tool_framework.tool_manager import ToolManager
19
- from services.context_manager.advanced_context import AdvancedContextManager
20
-
21
- # Configure logging
22
- logging.basicConfig(level=logging.INFO)
23
- logger = logging.getLogger(__name__)
24
-
25
- # Initialize FastAPI app
26
- app = FastAPI(
27
- title="Nocturnal Archive API - Enhanced",
28
- description="Production-grade AI-powered research platform with advanced reasoning capabilities",
29
- version="3.0.0",
30
- docs_url="/docs",
31
- redoc_url="/redoc"
32
- )
33
-
34
-
35
- def _utc_timestamp() -> str:
36
- return datetime.now(timezone.utc).isoformat()
37
-
38
- # Add CORS middleware
39
- app.add_middleware(
40
- CORSMiddleware,
41
- allow_origins=["*"], # Configure for production
42
- allow_credentials=True,
43
- allow_methods=["*"],
44
- allow_headers=["*"],
45
- )
46
-
47
- # Initialize enhanced services
48
- tool_manager = ToolManager()
49
- context_manager = AdvancedContextManager()
50
- reasoning_engine = ReasoningEngine()
51
-
52
- # Pydantic models for request/response
53
- class ChatRequest(BaseModel):
54
- message: str
55
- session_id: Optional[str] = None
56
- use_advanced_reasoning: Optional[bool] = True
57
-
58
- class ResearchRequest(BaseModel):
59
- topic: str
60
- max_results: Optional[int] = 10
61
- use_advanced_reasoning: Optional[bool] = True
62
-
63
- class ReasoningRequest(BaseModel):
64
- problem_description: str
65
- context: Optional[Dict[str, Any]] = None
66
- user_id: Optional[str] = None
67
-
68
- class ToolExecutionRequest(BaseModel):
69
- tool_name: Optional[str] = None
70
- task_description: str
71
- context: Optional[Dict[str, Any]] = None
72
- auto_select_tool: Optional[bool] = True
73
-
74
- # Health check endpoints
75
- @app.get("/")
76
- async def root():
77
- """Root endpoint with service information."""
78
- return {
79
- "service": "Nocturnal Archive API - Enhanced",
80
- "version": "3.0.0",
81
- "status": "healthy",
82
- "environment": os.getenv("ENVIRONMENT", "development"),
83
- "capabilities": [
84
- "Advanced Reasoning Engine",
85
- "Dynamic Tool Framework",
86
- "Code Execution Environment",
87
- "Advanced Context Management",
88
- "Academic Research & Synthesis",
89
- "Multi-LLM Integration"
90
- ]
91
- }
92
-
93
- @app.get("/health")
94
- async def health_check():
95
- """Health check endpoint."""
96
- return {
97
- "status": "healthy",
98
- "timestamp": _utc_timestamp(),
99
- "services": {
100
- "reasoning_engine": "operational",
101
- "tool_framework": "operational",
102
- "context_manager": "operational"
103
- }
104
- }
105
-
106
- @app.get("/api/status")
107
- async def api_status():
108
- """API status endpoint."""
109
- return {
110
- "status": "operational",
111
- "services": {
112
- "reasoning": "operational",
113
- "tools": "operational",
114
- "context": "operational"
115
- }
116
- }
117
-
118
- # Enhanced Reasoning Endpoints
119
- @app.post("/api/reasoning/solve")
120
- async def solve_problem(request: ReasoningRequest):
121
- """Solve complex problems using advanced reasoning."""
122
- try:
123
- # Solve the problem using reasoning engine
124
- result = await reasoning_engine.solve_problem(
125
- problem_description=request.problem_description,
126
- context=request.context,
127
- user_id=request.user_id
128
- )
129
-
130
- return {
131
- "status": "success",
132
- "result": result
133
- }
134
-
135
- except Exception as e:
136
- logger.error(f"Reasoning error: {str(e)}")
137
- raise HTTPException(status_code=500, detail=f"Reasoning failed: {str(e)}")
138
-
139
- # Enhanced Tool Framework Endpoints
140
- @app.post("/api/tools/execute")
141
- async def execute_tool(request: ToolExecutionRequest):
142
- """Execute a tool with dynamic selection."""
143
- try:
144
- # Execute tool
145
- if request.auto_select_tool:
146
- result = await tool_manager.execute_with_auto_selection(
147
- task_description=request.task_description,
148
- context=request.context
149
- )
150
- else:
151
- if not request.tool_name:
152
- raise HTTPException(status_code=400, detail="Tool name required when auto_select_tool is False")
153
-
154
- result = await tool_manager.execute_tool(
155
- tool_name=request.tool_name,
156
- task_description=request.task_description,
157
- context=request.context
158
- )
159
-
160
- return {
161
- "status": "success",
162
- "result": result
163
- }
164
-
165
- except Exception as e:
166
- logger.error(f"Tool execution error: {str(e)}")
167
- raise HTTPException(status_code=500, detail=f"Tool execution failed: {str(e)}")
168
-
169
- @app.get("/api/tools/available")
170
- async def get_available_tools():
171
- """Get list of available tools."""
172
- try:
173
- tools = tool_manager.get_available_tools()
174
- tool_capabilities = {}
175
-
176
- for tool in tools:
177
- tool_capabilities[tool] = tool_manager.get_tool_capabilities(tool)
178
-
179
- return {
180
- "status": "success",
181
- "tools": tools,
182
- "capabilities": tool_capabilities
183
- }
184
- except Exception as e:
185
- logger.error(f"Failed to get available tools: {str(e)}")
186
- raise HTTPException(status_code=500, detail=f"Failed to get available tools: {str(e)}")
187
-
188
- # Enhanced Context Management Endpoints
189
- @app.post("/api/context/process")
190
- async def process_context(request: ChatRequest):
191
- """Process interaction and update context."""
192
- try:
193
- session_id = request.session_id or "default_session"
194
-
195
- # Generate response (this would integrate with existing chat logic)
196
- response = f"Enhanced response to: {request.message}"
197
-
198
- # Process interaction in context manager
199
- result = await context_manager.process_interaction(
200
- user_input=request.message,
201
- response=response,
202
- session_id=session_id,
203
- user_id="anonymous"
204
- )
205
-
206
- return {
207
- "status": "success",
208
- "response": response,
209
- "context_result": result
210
- }
211
-
212
- except Exception as e:
213
- logger.error(f"Context processing error: {str(e)}")
214
- raise HTTPException(status_code=500, detail=f"Context processing failed: {str(e)}")
215
-
216
- @app.get("/api/context/retrieve")
217
- async def retrieve_context(query: str, session_id: Optional[str] = None):
218
- """Retrieve relevant context for a query."""
219
- try:
220
- result = await context_manager.retrieve_relevant_context(
221
- query=query,
222
- session_id=session_id,
223
- user_id="anonymous"
224
- )
225
-
226
- return {
227
- "status": "success",
228
- "result": result
229
- }
230
-
231
- except Exception as e:
232
- logger.error(f"Context retrieval error: {str(e)}")
233
- raise HTTPException(status_code=500, detail=f"Context retrieval failed: {str(e)}")
234
-
235
- # Enhanced Chat Endpoint with Advanced Reasoning
236
- @app.post("/api/enhanced-chat")
237
- async def enhanced_chat_endpoint(request: ChatRequest):
238
- """Enhanced chat endpoint with advanced reasoning capabilities."""
239
- try:
240
- session_id = request.session_id or "enhanced_session"
241
-
242
- # Use advanced reasoning if requested
243
- if request.use_advanced_reasoning:
244
- # Solve as a reasoning problem
245
- reasoning_result = await reasoning_engine.solve_problem(
246
- problem_description=request.message,
247
- context={"session_id": session_id, "user_id": "anonymous"},
248
- user_id="anonymous"
249
- )
250
-
251
- response = reasoning_result.get("solution", "No solution generated")
252
- else:
253
- # Use simple response
254
- response = f"Standard response to: {request.message}"
255
-
256
- # Process interaction in context manager
257
- await context_manager.process_interaction(
258
- user_input=request.message,
259
- response=str(response),
260
- session_id=session_id,
261
- user_id="anonymous"
262
- )
263
-
264
- return {
265
- "response": response,
266
- "session_id": session_id,
267
- "timestamp": _utc_timestamp(),
268
- "mode": "enhanced_reasoning" if request.use_advanced_reasoning else "standard"
269
- }
270
-
271
- except Exception as e:
272
- logger.error(f"Enhanced chat error: {str(e)}")
273
- raise HTTPException(status_code=500, detail=f"Chat failed: {str(e)}")
274
-
275
- # Error handling
276
- @app.exception_handler(Exception)
277
- async def global_exception_handler(request: Request, exc: Exception):
278
- """Global exception handler."""
279
- logger.error(f"Unhandled exception: {str(exc)}")
280
- return JSONResponse(
281
- status_code=500,
282
- content={"detail": "Internal server error"}
283
- )
284
-
285
- if __name__ == "__main__":
286
- import uvicorn
287
- uvicorn.run(app, host="127.0.0.1", port=8003)