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