New Structure Demo (#120)

better demo
---------

Co-authored-by: Young <afe.young@gmail.com>
Co-authored-by: Taozhi Wang <taozhi.mark.wang@gmail.com>
Co-authored-by: you-n-g <you-n-g@users.noreply.github.com>
Co-authored-by: cyncyw <47289405+taozhiwang@users.noreply.github.com>
This commit is contained in:
XianBW
2024-07-30 17:23:05 +08:00
committed by GitHub
parent 1b4e98a752
commit dbbec2ffaf
11 changed files with 984 additions and 73 deletions
+25 -20
View File
@@ -18,7 +18,10 @@ from rdagent.components.coder.model_coder.model import ModelFBWorkspace, ModelTa
from rdagent.core.proposal import Hypothesis, HypothesisFeedback, Trace
from rdagent.log.base import Message, Storage, View
from rdagent.scenarios.qlib.experiment.factor_experiment import QlibFactorExperiment
from rdagent.scenarios.qlib.experiment.model_experiment import QlibModelExperiment
from rdagent.scenarios.qlib.experiment.model_experiment import (
QlibModelExperiment,
QlibModelScenario,
)
st.set_page_config(layout="wide")
@@ -213,7 +216,7 @@ class ModelTaskWindow(StWindow):
self.container.markdown(f"**Model Name**: {mt.name}")
self.container.markdown(f"**Model Type**: {mt.model_type}")
self.container.markdown(f"**Description**: {mt.description}")
self.container.markdown(f"**Formulation**: {mt.formulation}")
self.container.latex(f"Formulation: {mt.formulation}")
variables_df = pd.DataFrame(mt.variables, index=["Value"]).T
variables_df.index.name = "Variable"
@@ -479,6 +482,10 @@ class ResearchWindow(StWindow):
elif isinstance(msg.content[0], ModelTask):
self.container.markdown("**Model Tasks**")
ObjectsTabsWindow(self.container.container(), ModelTaskWindow, lambda x: x.name).consume_msg(msg)
elif msg.tag.endswith("load_pdf_screenshot"):
self.container.image(msg.content)
elif msg.tag.endswith("load_factor_tasks"):
self.container.json(msg.content)
class EvolvingWindow(StWindow):
@@ -535,16 +542,6 @@ class DevelopmentWindow(StWindow):
def consume_msg(self, msg: Message):
if "evolving" in msg.tag:
self.E_win.consume_msg(msg)
# elif msg.tag.endswith('result'):
# self.container.subheader('Results')
# if isinstance(msg.content[0], FactorFBWorkspace):
# ObjectsTabsWindow(self.container.expander('Factor Workspaces'),
# inner_class=WorkspaceWindow,
# mapper=lambda x: x.target_task.factor_name).consume_msg(msg)
# elif isinstance(msg.content[0], ModelFBWorkspace):
# ObjectsTabsWindow(self.container.expander('Model Workspaces'),
# inner_class=WorkspaceWindow,
# mapper=lambda x: x.target_task.name).consume_msg(msg)
class FeedbackWindow(StWindow):
@@ -552,7 +549,11 @@ class FeedbackWindow(StWindow):
self.container = container
def consume_msg(self, msg: Message):
if isinstance(msg.content, HypothesisFeedback):
if msg.tag.endswith("returns"):
fig = px.line(msg.content)
self.container.markdown("**Returns📈**")
self.container.plotly_chart(fig)
elif isinstance(msg.content, HypothesisFeedback):
HypothesisFeedbackWindow(self.container.container(border=True)).consume_msg(msg)
elif isinstance(msg.content, QlibModelExperiment):
QlibModelExpWindow(self.container.container(border=True)).consume_msg(msg)
@@ -584,13 +585,15 @@ class TraceWindow(StWindow):
):
self.show_llm = show_llm
self.show_common_logs = show_common_logs
image_c, scen_c = container.columns([2, 3], vertical_alignment="center")
image_c.image("scen.jpg")
scen_c.container(border=True).markdown(QlibModelScenario().rich_style_description)
top_container = container.container()
col1, col2 = top_container.columns([2, 3])
chart_c = col2.container(border=True, height=300)
chart_c = col2.container(border=True, height=500)
chart_c.markdown("**Metrics📈**")
self.chart_c = chart_c.empty()
hypothesis_status_c = col1.container(border=True, height=300)
hypothesis_status_c = col1.container(border=True, height=500)
hypothesis_status_c.markdown("**Hypotheses🏅**")
self.summary_c = hypothesis_status_c.empty()
@@ -602,7 +605,7 @@ class TraceWindow(StWindow):
)
self.hypothesis_decisions = defaultdict(bool)
self.current_hypothesis = None
self.hypotheses: list[Hypothesis] = []
self.results = []
@@ -614,12 +617,14 @@ class TraceWindow(StWindow):
if isinstance(msg.content, dict):
return
if msg.tag.endswith("hypothesis generation"):
self.current_hypothesis = msg.content.hypothesis
self.hypotheses.append(msg.content)
elif msg.tag.endswith("ef.feedback"):
self.hypothesis_decisions[self.current_hypothesis] = msg.content.decision
self.hypothesis_decisions[self.hypotheses[-1]] = msg.content.decision
self.summary_c.markdown(
"\n".join(
f"{id+1}. :green[{h}]\n" if d else f"{id+1}. {h}\n"
f"{id+1}. :green[{self.hypotheses[id].hypothesis}]\n\t>*{self.hypotheses[id].concise_reason}*"
if d
else f"{id+1}. {self.hypotheses[id].hypothesis}\n\t>*{self.hypotheses[id].concise_reason}*"
for id, (h, d) in enumerate(self.hypothesis_decisions.items())
)
)