every single run was traced btw WTF

This commit is contained in:
lda
2026-04-15 23:47:41 +07:00 Verified
parent 2dbd3de074
commit 08f5bd2d47
3 changed files with 40 additions and 50 deletions
+3 -7
View File
@@ -17,8 +17,6 @@ graph TD;
r_g10(r_g10)
r_g80(r_g80)
r_gs(r_gs)
c_80_p(c_80_p)
c_10_p(c_10_p)
prep(prep)
roll(roll)
c_80(c_80)
@@ -27,9 +25,7 @@ graph TD;
__end__([<p>__end__</p>]):::last
__start__ --> init;
c_10 --> end_roll;
c_10_p --> prep;
c_80 --> end_roll;
c_80_p --> c_10_p;
counter_up -. &nbsp;0&nbsp; .-> rate_same;
counter_up -. &nbsp;65&nbsp; .-> rate_up;
end_roll -.-> __end__;
@@ -37,9 +33,9 @@ graph TD;
init -.-> __end__;
init -.-> tick;
prep --> roll;
r_g10 --> c_10_p;
r_g80 --> c_80_p;
r_gs --> c_80_p;
r_g10 --> prep;
r_g80 --> prep;
r_gs --> prep;
rate_guarantee -. &nbsp;1&nbsp; .-> prep;
rate_guarantee -. &nbsp;10&nbsp; .-> r_g10;
rate_guarantee -. &nbsp;80&nbsp; .-> r_g80;
+3 -7
View File
@@ -14,8 +14,6 @@ graph TD;
r_g10(r_g10)
r_g80(r_g80)
r_gs(r_gs)
c_80_p(c_80_p)
c_10_p(c_10_p)
prep(prep)
roll(roll)
c_80(c_80)
@@ -24,9 +22,7 @@ graph TD;
__end__([<p>__end__</p>]):::last
__start__ --> init;
c_10 --> end_roll;
c_10_p --> prep;
c_80 --> end_roll;
c_80_p --> c_10_p;
counter_up -. &nbsp;0&nbsp; .-> rate_same;
counter_up -. &nbsp;65&nbsp; .-> rate_up;
end_roll -.-> __end__;
@@ -34,9 +30,9 @@ graph TD;
init -.-> __end__;
init -.-> tick;
prep --> roll;
r_g10 --> c_10_p;
r_g80 --> c_80_p;
r_gs --> c_80_p;
r_g10 --> prep;
r_g80 --> prep;
r_gs --> prep;
rate_guarantee -. &nbsp;1&nbsp; .-> prep;
rate_guarantee -. &nbsp;10&nbsp; .-> r_g10;
rate_guarantee -. &nbsp;80&nbsp; .-> r_g80;
+34 -36
View File
@@ -10,6 +10,7 @@ from langgraph.checkpoint.memory import InMemorySaver
from langgraph.graph import END, StateGraph
from langgraph.graph.state import Command, RunnableConfig
from langgraph.runtime import Runtime
from langsmith import traceable
# from langsmith import traceable
@@ -71,7 +72,7 @@ class Context(TypedDict):
"very convoluted logic"
# @traceable(name="initializer")
@traceable(name="initializer")
def init(state: Input, runtime: Runtime[Context]):
if (
runtime.context["type"] == "select"
@@ -86,7 +87,7 @@ def init(state: Input, runtime: Runtime[Context]):
}
# @traceable(name="buff rates post 65")
@traceable(name="buff rates post 65")
def rate_booster(state: State) -> Literal["0", "65"]:
c = state["counter"]
if c.get("c_80", 0) >= 65:
@@ -94,7 +95,7 @@ def rate_booster(state: State) -> Literal["0", "65"]:
return "0"
# @traceable(name="pre-roll router")
@traceable(name="pre-roll router")
def router(state: State, runtime: Runtime[Context]) -> Literal["240", "80", "10", "1"]:
"super match"
sc, c = state["simple_counter"], state["counter"]
@@ -102,30 +103,30 @@ def router(state: State, runtime: Runtime[Context]) -> Literal["240", "80", "10"
sc > 0 and sc % 240 == 0
):
return "240"
if c.get("c_80", 0) == 80:
if c.get("c_80", 0) % 80 == 0:
return "80"
if c.get("c_10", 0) == 10:
if c.get("c_10", 0) % 10 == 0:
return "10"
return "1"
class RateChange:
# @traceable(name="force 6* rating")
@traceable(name="force 6* rating")
@staticmethod
def r80(state: State):
return {"rates": {"r_1": 0, "r_10": 0}}
# @traceable(name="force banner rating")
@traceable(name="force banner rating")
@staticmethod
def r240(state: State):
return {"rates": {"r_1": 0, "r_10": 0, "r_80": 0, "r_240": 1}}
# @traceable(name="force 5*+ rating")
@traceable(name="force 5*+ rating")
@staticmethod
def r10(state: State):
return {"rates": {"r_1": 0}}
# @traceable(name="buff 6* rating")
@traceable(name="buff 6* rating")
@staticmethod
def r65(state: State, runtime: Runtime[Context]):
c = state["counter"]
@@ -150,14 +151,14 @@ class RateChange:
}
}
# @traceable(name="reset rating")
@traceable(name="reset rating")
@staticmethod
def r0(state: State, runtime: Runtime[Context]):
return {"rates": runtime.context["initial_rates"].copy()}
class CounterUp:
# @traceable(name="counter 6* reset")
@traceable(name="counter 6* reset")
@staticmethod
def c80(state: State):
return {
@@ -166,7 +167,7 @@ class CounterUp:
},
}
# @traceable(name="counter 5* reset")
@traceable(name="counter 5* reset")
@staticmethod
def c10(state: State):
return {
@@ -175,7 +176,7 @@ class CounterUp:
},
}
# @traceable(name="counting up")
@traceable(name="counting up")
@staticmethod
def c1(state: State):
c = state["counter"]
@@ -185,7 +186,7 @@ class CounterUp:
}
# @traceable(name="prepare pool")
@traceable(name="prepare pool")
def prep(state: State, runtime: Runtime[Context]):
r = state["rates"]
p = runtime.context["pool"]
@@ -200,7 +201,7 @@ def prep(state: State, runtime: Runtime[Context]):
return {"current_pools": pbc}
# @traceable(name="pull from pool")
@traceable(name="pull from pool")
def roll(state: State):
r = state["current_pools"]
# print(r)
@@ -212,17 +213,17 @@ def roll(state: State):
}
# @traceable(name="router after pull")
@traceable(name="router after pull")
def post_roll_router(state: State) -> Literal["240", "80", "10", "1"]:
return cast(Literal["240", "80", "10", "1"], state["this"]["category"])
# @traceable(name="main")
@traceable(name="main")
def tick(state: State) -> dict | Command[END]: # type: ignore
return {"countdown": state["countdown"] - 1}
# @traceable(name="loop if countdown")
@traceable(name="loop if countdown")
def keep_rolling(state: State):
return "tick" if state.get("countdown", 0) > 0 else END
@@ -238,8 +239,6 @@ graph = (
.add_node("r_g10", RateChange.r10)
.add_node("r_g80", RateChange.r80)
.add_node("r_gs", RateChange.r240)
.add_node("c_80_p", CounterUp.c80)
.add_node("c_10_p", CounterUp.c10)
.add_node(prep)
.add_node(roll)
.add_node("c_80", CounterUp.c80)
@@ -259,11 +258,9 @@ graph = (
{"240": "r_gs", "80": "r_g80", "10": "r_g10", "1": "prep"},
)
.add_edge("prep", "roll")
.add_edge("r_gs", "c_80_p")
.add_edge("r_g80", "c_80_p")
.add_edge("r_g10", "c_10_p")
.add_edge("c_80_p", "c_10_p")
.add_edge("c_10_p", "prep")
.add_edge("r_gs", "prep")
.add_edge("r_g80", "prep")
.add_edge("r_g10", "prep")
.add_conditional_edges(
"roll",
post_roll_router,
@@ -296,10 +293,11 @@ context: Context = {
"Alesh",
],
"n_80": [
# "Tangtang",
"Yvonne",
"Gilberta",
"Laevatain",
"Rossi",
"Tangtang",
# "Yvonne",
# "Gilberta",
# "Laevatain",
"Ember",
"Lifeng",
"Ardelia",
@@ -308,7 +306,8 @@ context: Context = {
],
"n_240": [ # select or banner / logic is hella flawed lowk ong
# "Rossi",
"Tangtang",
# "Tangtang",
"Zhuang Fangyi",
],
},
"type": "banner",
@@ -329,16 +328,15 @@ if __name__ == "__main__":
config: RunnableConfig = {"configurable": {"thread_id": "random ahh"}}
print("running:")
random.seed("6741") # tung tung tung
# random.seed("6741") # tung tung tung
pprint(
app.invoke(
{
"countdown": 20,
"simple_counter": 120 - 9,
"countdown": 39, # hopefully after all of the stuff and gifts
"simple_counter": 0,
"counter": {
"c_10": 10 - 10,
"c_80": 80 - 71,
# wow i got 9 whole rolls after the SECOND failed 50/50!
"c_10": 10 - 1,
"c_80": 80 - 51,
},
},
config,