update prompt
This commit is contained in:
parent
662b0644b8
commit
28218b2db9
|
|
@ -8,14 +8,22 @@ from langchain_core.language_models.chat_models import BaseChatModel
|
||||||
class Reflector:
|
class Reflector:
|
||||||
"""Handles reflection on decisions and updating memory."""
|
"""Handles reflection on decisions and updating memory."""
|
||||||
|
|
||||||
def __init__(self, quick_thinking_llm: BaseChatModel):
|
def __init__(self, quick_thinking_llm: BaseChatModel, config):
|
||||||
"""Initialize the reflector with an LLM."""
|
"""Initialize the reflector with an LLM."""
|
||||||
|
language = config["output_language"]
|
||||||
|
language_prompts = {
|
||||||
|
"en": "",
|
||||||
|
"zh-tw": "Use Traditional Chinese as the output.",
|
||||||
|
"zh-cn": "Use Simplified Chinese as the output.",
|
||||||
|
}
|
||||||
|
self.language_prompt = language_prompts.get(language, "")
|
||||||
|
|
||||||
self.quick_thinking_llm = quick_thinking_llm
|
self.quick_thinking_llm = quick_thinking_llm
|
||||||
self.reflection_system_prompt = self._get_reflection_prompt()
|
self.reflection_system_prompt = self._get_reflection_prompt()
|
||||||
|
|
||||||
def _get_reflection_prompt(self) -> str:
|
def _get_reflection_prompt(self) -> str:
|
||||||
"""Get the system prompt for reflection."""
|
"""Get the system prompt for reflection."""
|
||||||
return """
|
return f"""
|
||||||
You are an expert financial analyst tasked with reviewing trading decisions/analysis and providing a comprehensive, step-by-step analysis.
|
You are an expert financial analyst tasked with reviewing trading decisions/analysis and providing a comprehensive, step-by-step analysis.
|
||||||
Your goal is to deliver detailed insights into investment decisions and highlight opportunities for improvement, adhering strictly to the following guidelines:
|
Your goal is to deliver detailed insights into investment decisions and highlight opportunities for improvement, adhering strictly to the following guidelines:
|
||||||
|
|
||||||
|
|
@ -45,6 +53,8 @@ Your goal is to deliver detailed insights into investment decisions and highligh
|
||||||
- Ensure the condensed sentence captures the essence of the lessons and reasoning for easy reference.
|
- Ensure the condensed sentence captures the essence of the lessons and reasoning for easy reference.
|
||||||
|
|
||||||
Adhere strictly to these instructions, and ensure your output is detailed, accurate, and actionable. You will also be given objective descriptions of the market from a price movements, technical indicator, news, and sentiment perspective to provide more context for your analysis.
|
Adhere strictly to these instructions, and ensure your output is detailed, accurate, and actionable. You will also be given objective descriptions of the market from a price movements, technical indicator, news, and sentiment perspective to provide more context for your analysis.
|
||||||
|
|
||||||
|
Output language: ***{self.language_prompt}***
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def _extract_current_situation(self, current_state: Dict[str, Any]) -> str:
|
def _extract_current_situation(self, current_state: Dict[str, Any]) -> str:
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,16 @@ from langchain_core.language_models.chat_models import BaseChatModel
|
||||||
class SignalProcessor:
|
class SignalProcessor:
|
||||||
"""Processes trading signals to extract actionable decisions."""
|
"""Processes trading signals to extract actionable decisions."""
|
||||||
|
|
||||||
def __init__(self, quick_thinking_llm: BaseChatModel):
|
def __init__(self, quick_thinking_llm: BaseChatModel, config):
|
||||||
"""Initialize with an LLM for processing."""
|
"""Initialize with an LLM for processing."""
|
||||||
|
language = config["output_language"]
|
||||||
|
language_prompts = {
|
||||||
|
"en": "",
|
||||||
|
"zh-tw": "Use Traditional Chinese as the output.",
|
||||||
|
"zh-cn": "Use Simplified Chinese as the output.",
|
||||||
|
}
|
||||||
|
self.language_prompt = language_prompts.get(language, "")
|
||||||
|
|
||||||
self.quick_thinking_llm = quick_thinking_llm
|
self.quick_thinking_llm = quick_thinking_llm
|
||||||
|
|
||||||
def process_signal(self, full_signal: str) -> str:
|
def process_signal(self, full_signal: str) -> str:
|
||||||
|
|
@ -24,7 +32,13 @@ class SignalProcessor:
|
||||||
messages = [
|
messages = [
|
||||||
(
|
(
|
||||||
"system",
|
"system",
|
||||||
"You are an efficient assistant designed to analyze paragraphs or financial reports provided by a group of analysts. Your task is to extract the investment decision: SELL, BUY, or HOLD. Provide only the extracted decision (SELL, BUY, or HOLD) as your output, without adding any additional text or information.",
|
f"""
|
||||||
|
You are an efficient assistant designed to analyze paragraphs or financial reports provided by a group of analysts.
|
||||||
|
Your task is to extract the investment decision: SELL, BUY, or HOLD.
|
||||||
|
Provide only the extracted decision (SELL, BUY, or HOLD) as your output, without adding any additional text or information.
|
||||||
|
|
||||||
|
Output language: ***{self.language_prompt}***
|
||||||
|
""",
|
||||||
),
|
),
|
||||||
("human", full_signal),
|
("human", full_signal),
|
||||||
]
|
]
|
||||||
|
|
|
||||||
|
|
@ -109,8 +109,8 @@ class TradingAgentsGraph:
|
||||||
)
|
)
|
||||||
|
|
||||||
self.propagator = Propagator()
|
self.propagator = Propagator()
|
||||||
self.reflector = Reflector(self.quick_thinking_llm)
|
self.reflector = Reflector(self.quick_thinking_llm, self.config)
|
||||||
self.signal_processor = SignalProcessor(self.quick_thinking_llm)
|
self.signal_processor = SignalProcessor(self.quick_thinking_llm, self.config)
|
||||||
|
|
||||||
# State tracking
|
# State tracking
|
||||||
self.curr_state = None
|
self.curr_state = None
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue