cryogenic22 commited on
Commit
6e1efa8
·
verified ·
1 Parent(s): cc11bc2

Update services/chart_analysis.py

Browse files
Files changed (1) hide show
  1. services/chart_analysis.py +35 -10
services/chart_analysis.py CHANGED
@@ -28,9 +28,7 @@ class ChartAnalysisService:
28
  if len(individual_analyses) > 1 and comparison_type != "Individual Analysis":
29
  comparison_prompt = self.create_comparison_prompt(
30
  individual_analyses,
31
- comparison_type,
32
- patterns,
33
- indicators
34
  )
35
 
36
  # Combine all images for the comparison analysis
@@ -72,10 +70,32 @@ class ChartAnalysisService:
72
  st.error(f"Error in chart analysis: {str(e)}")
73
  return None
74
 
75
- def create_comparison_prompt(self, individual_analyses, comparison_type, patterns, indicators):
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
76
  """Create a prompt for comparing multiple charts"""
77
  if comparison_type == "Correlated Analysis":
78
- return """Analyze these charts together and provide insights on their relationships:
 
79
  1. Correlation Analysis
80
  - Identify any price correlations
81
  - Note common patterns or divergences
@@ -92,10 +112,10 @@ class ChartAnalysisService:
92
  - Risk considerations
93
 
94
  4. Summary
95
- Provide a clear summary of the key relationships and trading implications.
96
- """
97
  else: # Market Trend Analysis
98
- return """Analyze these charts to identify broader market patterns:
 
99
  1. Market Trend Analysis
100
  - Identify common trend directions
101
  - Note sector/market momentum
@@ -112,5 +132,10 @@ class ChartAnalysisService:
112
  - Timeframe recommendations
113
 
114
  4. Summary
115
- Provide a clear summary of the market condition and trading implications.
116
- """
 
 
 
 
 
 
28
  if len(individual_analyses) > 1 and comparison_type != "Individual Analysis":
29
  comparison_prompt = self.create_comparison_prompt(
30
  individual_analyses,
31
+ comparison_type
 
 
32
  )
33
 
34
  # Combine all images for the comparison analysis
 
70
  st.error(f"Error in chart analysis: {str(e)}")
71
  return None
72
 
73
+ def handle_follow_up_question(self, question, previous_analysis, image_data=None):
74
+ """Handle follow-up questions about the analysis"""
75
+ try:
76
+ response = self.claude_service.continue_analysis(
77
+ question=question,
78
+ previous_analysis=previous_analysis,
79
+ image_data=image_data
80
+ )
81
+
82
+ if response:
83
+ return {
84
+ 'timestamp': datetime.now().isoformat(),
85
+ 'question': question,
86
+ 'analysis': response,
87
+ 'analysis_type': 'Follow-up'
88
+ }
89
+ return None
90
+ except Exception as e:
91
+ st.error(f"Error handling follow-up question: {str(e)}")
92
+ return None
93
+
94
+ def create_comparison_prompt(self, individual_analyses, comparison_type):
95
  """Create a prompt for comparing multiple charts"""
96
  if comparison_type == "Correlated Analysis":
97
+ prompt = """Analyze these charts together and provide insights on their relationships:
98
+
99
  1. Correlation Analysis
100
  - Identify any price correlations
101
  - Note common patterns or divergences
 
112
  - Risk considerations
113
 
114
  4. Summary
115
+ Provide a clear summary of the key relationships and trading implications."""
 
116
  else: # Market Trend Analysis
117
+ prompt = """Analyze these charts to identify broader market patterns:
118
+
119
  1. Market Trend Analysis
120
  - Identify common trend directions
121
  - Note sector/market momentum
 
132
  - Timeframe recommendations
133
 
134
  4. Summary
135
+ - Provide a clear summary of the market condition
136
+ - List key trading implications
137
+ - Note major risk factors"""
138
+
139
+ # Add disclaimer
140
+ prompt += "\n\nIMPORTANT: Clearly mark this as AI-generated analysis for informational purposes only."
141
+ return prompt