zed with the phantom diagnostics

This commit is contained in:
lda
2026-03-30 22:49:38 +07:00 Unverified
parent 6cfde5beaf
commit c376fba3ea
8 changed files with 1811 additions and 9 deletions
+6
View File
@@ -0,0 +1,6 @@
LANGSMITH_TRACING=true
LANGSMITH_ENDPOINT=https://api.smith.langchain.com
LANGSMITH_API_KEY=lsv2_pt_67
LANGSMITH_PROJECT="Default project"
GROQ_API_KEY=gsk_nom
+1
View File
@@ -1 +1,2 @@
.env .env
__pycache__
+3
View File
@@ -0,0 +1,3 @@
# what the helly
you needa setup langsmith tracing or something and groq/celebras/openrouter if you want idfk
+50
View File
@@ -0,0 +1,50 @@
# graph
```mermaid
---
config:
flowchart:
curve: linear
---
graph TD;
__start__([<p>__start__</p>]):::first
init(init)
rate_up(rate_up)
rate_same(rate_same)
rate_guarantee(rate_guarantee)
r_g10(r_g10)
r_g80(r_g80)
r_gs(r_gs)
prep(prep)
roll(roll)
c_80(c_80)
c_10(c_10)
counter_up(counter_up)
main(main)
__end__([<p>__end__</p>]):::last
__start__ --> init;
c_10 --> counter_up;
c_80 --> counter_up;
counter_up -.-> __end__;
counter_up -.-> main;
init --> main;
main -. &nbsp;0&nbsp; .-> rate_same;
main -. &nbsp;65&nbsp; .-> rate_up;
prep --> roll;
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;
rate_guarantee -. &nbsp;240&nbsp; .-> r_gs;
rate_same --> rate_guarantee;
rate_up --> rate_guarantee;
roll -. &nbsp;10&nbsp; .-> c_10;
roll -. &nbsp;240&nbsp; .-> c_80;
roll -. &nbsp;1&nbsp; .-> counter_up;
classDef default fill:#f2f0ff,line-height:1.2
classDef first fill-opacity:0
classDef last fill:#bfb6fc
```
+303 -9
View File
@@ -1,20 +1,314 @@
"0 langgraph just yet. we use what here." """I mimic the roll system that wrecked my Head Ass just now"""
import langsmith import operator
import random
from pathlib import Path
from pprint import pprint
from typing import Annotated, Literal, Sequence, TypedDict, cast
from langgraph.checkpoint.memory import InMemorySaver
from langgraph.graph import END, StateGraph
from langgraph.graph.state import RunnableConfig
from langgraph.runtime import Runtime
# from langsmith import traceable
# state, which is the state of the entire thing? idfk.
# dog why am i designing some haskell shit
@langsmith.traceable class SophisticatedCounter(TypedDict):
def demo_fn(a: int, b: int): c_10: Annotated[int, operator.add]
return a + b c_80: Annotated[int, operator.add]
@langsmith.traceable class SophisticatedRates(TypedDict):
def aimn(): r_1: float
return demo_fn(2, 3) r_10: float
r_80: float # 0.5 sometimes, 1
r_240: float # 1 sometimes, 0.5, 0.004 mf
class Input(TypedDict):
countdown: int
class State(TypedDict):
countdown: int
simple_counter: Annotated[int, operator.add] # only up!
counter: Annotated[SophisticatedCounter, operator.or_]
rates: Annotated[SophisticatedRates, operator.or_]
current_pools: list[PoolByCategory]
this: Entity
storage: Annotated[list[Entity], operator.add]
class Entity(TypedDict):
category: str
name: str
class PoolByCategory(TypedDict):
pool: list[str]
category: str
rates: float
# context outside? what is input?
class UnsophisticatedPool(TypedDict):
n_1: list[str]
n_10: list[str]
n_80: list[str] # normal + limited
n_240: list[str] # special
class Context(TypedDict):
pool: UnsophisticatedPool
initial_rates: SophisticatedRates
# @traceable(name="initializer")
def init(state: Input, runtime: Runtime[Context]):
return {
"countdown": state["countdown"],
"simple_counter": 0,
"counter": {"c_10": 0, "c_80": 0},
"rates": runtime.context["initial_rates"].copy(),
}
# @traceable(name="buff rates post 65")
def rate_booster(state: State) -> Literal["0", "65"]:
c = state["counter"]
if c.get("c_80", 0) >= 65:
return "65"
return "0"
# @traceable(name="pre-roll router")
def router(state: State) -> Sequence[Literal["240", "80", "10", "1"]]:
sc, c = state["simple_counter"], state["counter"]
if sc == 120 or (sc > 0 and sc % 240 == 0):
return ["240", "80", "10"]
if c.get("c_80", 0) == 80:
return ["80", "10"]
if c.get("c_10", 0) == 10:
return ["10"]
return ["1"]
class RateChange:
# @traceable(name="force 6* rating")
@staticmethod
def r80(state: State, runtime: Runtime[Context]):
return {"rates": {"r_1": 0, "r_10": 0}}
# @traceable(name="force banner rating")
@staticmethod
def r240(state: State, runtime: Runtime[Context]):
return {"rates": {"r_1": 0, "r_10": 0, "r_80": 0}}
# @traceable(name="force 5*+ rating")
@staticmethod
def r10(state: State, runtime: Runtime[Context]):
return {"rates": {"r_1": 0}}
# @traceable(name="buff 6* rating")
@staticmethod
def r65(state: State, runtime: Runtime[Context]):
c = state["counter"]
if c["c_80"] < 65:
return {}
n = c["c_80"] - 64
rpn = n * 0.05
br = runtime.context["initial_rates"]
if br["r_240"]:
r240 = br["r_240"] * (1 + rpn / 2)
r80 = br["r_80"] * (1 + rpn / 2)
else:
r240 = 0
r80 = br["r_80"] * (1 + rpn)
return {
"rates": {
"r_1": 1 - r240 - r80 - br["r_10"],
"r_10": br["r_10"],
"r_80": r80,
"r_240": r240,
}
}
# @traceable(name="reset rating")
@staticmethod
def r0(state: State, runtime: Runtime[Context]):
return {"rates": runtime.context["initial_rates"]}
class CounterUp:
# @traceable(name="counter 6* reset")
@staticmethod
def c80(state: State):
return {
"counter": {
"c_80": 0,
},
}
# @traceable(name="counter 5* reset")
@staticmethod
def c10(state: State):
return {
"counter": {
"c_10": 0,
},
}
# @traceable(name="counting up")
@staticmethod
def c1(state: State):
c = state["counter"]
return {
"simple_counter": 1,
"counter": {"c_10": c["c_10"] + 1, "c_80": c["c_80"] + 1},
}
# @traceable(name="prepare pool")
def prep(state: State, runtime: Runtime[Context]):
r = state["rates"]
p = runtime.context["pool"]
t = (
("1", "r_1", "n_1"),
("10", "r_10", "n_10"),
("80", "r_80", "n_80"),
("240", "r_240", "n_240"),
)
return {
"current_pools": [
PoolByCategory(pool=p[pc], category=ty, rates=r[pr]) for ty, pr, pc in t
]
}
# @traceable(name="pull from pool")
def roll(state: State):
r = state["current_pools"]
(t,) = random.choices(r, weights=[*map(operator.itemgetter("rates"), r)])
this = Entity(category=t["category"], name=random.choice(t["pool"]))
return {
"this": this,
"storage": [this],
}
# @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")
def tick(state: State):
return {"countdown": state["countdown"] - 1}
# @traceable(name="loop if countdown")
def keep_rolling(state: State):
return "tick" if state["countdown"] > 0 else END
graph = (
StateGraph(State, context_schema=Context, input_schema=Input)
.add_node(init)
.add_node("rate_up", RateChange.r65)
.add_node("rate_same", RateChange.r0)
.add_node("rate_guarantee", lambda state: {})
.add_node("r_g10", RateChange.r10)
.add_node("r_g80", RateChange.r80)
.add_node("r_gs", RateChange.r240)
.add_node(prep)
.add_node(roll)
.add_node("c_80", CounterUp.c80)
.add_node("c_10", CounterUp.c10)
.add_node("counter_up", CounterUp.c1)
.add_node("tick", tick)
.set_entry_point("init")
.add_edge("init", "tick")
.add_conditional_edges("tick", rate_booster, {"0": "rate_same", "65": "rate_up"})
.add_edge("rate_up", "rate_guarantee")
.add_edge("rate_same", "rate_guarantee")
.add_conditional_edges(
"rate_guarantee",
router,
{"240": "r_gs", "80": "r_g80", "10": "r_g10", "1": "prep"},
)
.add_edge("prep", "roll")
.add_edge("r_gs", "prep")
.add_edge("r_g80", "prep")
.add_edge("r_g10", "prep")
.add_conditional_edges(
"roll",
post_roll_router,
{"240": "c_80", "80": "c_80", "10": "c_10", "1": "counter_up"},
)
.add_edge("c_80", "counter_up")
.add_edge("c_10", "counter_up")
.add_conditional_edges("counter_up", keep_rolling, ["tick", END])
)
app = graph.compile(checkpointer=InMemorySaver())
context: Context = {
"initial_rates": {
"r_1": 0.912,
"r_10": 0.08,
"r_80": 0.004,
"r_240": 0.004,
},
"pool": {
"n_1": ["Akekuri", "Catcher", "Flourite", "Estella", "Antal"],
"n_10": [
"Perlica",
"Arclight",
"Avywenna",
"Da Pan",
"Chen Qianyu",
"Wulfgard",
"Xaihi",
"Snowshine",
"Alesh",
],
"n_80": [
"TangTang",
"Yvonne",
"Gilberta",
"Laevatain",
"Ember",
"Lifeng",
"Ardelia",
"Last Rite",
"Pogranichnik",
],
"n_240": ["Rossi"],
},
}
if __name__ == "__main__": if __name__ == "__main__":
from dotenv import load_dotenv from dotenv import load_dotenv
load_dotenv() load_dotenv()
aimn() Path("graph.md").write_text(f"""# graph
```mermaid
{app.get_graph().draw_mermaid()}
```
""") # good
config: RunnableConfig = {"configurable": {"thread_id": "1"}}
pprint(
app.invoke(
{"countdown": 100},
config,
context=context,
stream_mode="updates",
),
)
v = app.get_state(config).values
pprint(v)
+10
View File
@@ -5,8 +5,18 @@ description = "Add your description here"
readme = "README.md" readme = "README.md"
requires-python = ">=3.14" requires-python = ">=3.14"
dependencies = [ dependencies = [
"ddgs>=9.11.4",
"deepagents>=0.4.12",
"duckduckgo-search>=8.1.1",
"langchain>=1.2.13", "langchain>=1.2.13",
"langchain-cerebras>=0.8.2",
"langchain-community>=0.4.1",
"langchain-groq>=1.1.2",
"langchain-modal>=0.0.2",
"langchain-openrouter>=0.2.0",
"langgraph>=1.1.3", "langgraph>=1.1.3",
"langsmith>=0.7.22", "langsmith>=0.7.22",
"modal>=1.4.0",
"pydantic>=2.12.5",
"python-dotenv>=1.2.2", "python-dotenv>=1.2.2",
] ]
Generated
+1387
View File
File diff suppressed because it is too large Load Diff
+51
View File
@@ -0,0 +1,51 @@
"move all the other unrelated shit here"
from typing import Literal
# import deepagents
# import langchain
# import langchain.agents
# import langchain.chat_models
import langchain_community.tools
# import langsmith
# import modal
# from deepagents import create_deep_agent
# from deepagents.backends.protocol import SandboxBackendProtocol
from langchain.tools import tool
# from langchain_core.callbacks import get_usage_metadata_callback
# from langchain_core.messages import BaseMessage
# from langchain_groq import ChatGroq
# from langchain_modal import ModalSandbox
# app = modal.App.lookup("ahhh", create_if_missing=True)
# sb = modal.Sandbox.create(app=app)
# ms = ModalSandbox(sandbox=sb)
# e = ChatGroq(model="qwen/qwen3-32b", reasoning_format="parsed", reasoning_effort="none")
# what are these imports and can they go
@tool
def add(a: int, b: int) -> int:
"perform a plus b"
return a + b
@tool
def search_web_list(
query: str, num_results: int = 4, source: Literal["text", "images", "news"] = "text"
) -> list:
'this one returns a list. dont use "image" it returns urls'
return langchain_community.tools.DuckDuckGoSearchResults(
output_format="list", num_results=num_results, backend=source
).invoke(query)
@tool
def search_web_text(query: str) -> str:
"you tell me what is better"
return langchain_community.tools.DuckDuckGoSearchRun().invoke(query)
# e.bind_tools([add, search_web_list, search_web_text])
# why is it when i use langgraph this is all Gone and Unavailable