@capagents/forgeqe 2.10.5 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (110) hide show
  1. package/HOW_TO_USE.md +93 -19
  2. package/THIRD_PARTY_NOTICES.md +1 -1
  3. package/dist/docs-site/docs/index.html +78 -16
  4. package/dist/docs-site/docs/search.js +1 -1
  5. package/dist/forgeqe.js +1946 -1929
  6. package/dist/web/assets/Agent-DISh0THc.js +8 -0
  7. package/dist/web/assets/ApiTests-CK0HqEH4.js +10 -0
  8. package/dist/web/assets/Browse-WylAQZvD.js +2 -0
  9. package/dist/web/assets/Chat-B7IOg3I3.js +5 -0
  10. package/dist/web/assets/{CommandPalette-D7ufvlUN.js → CommandPalette-CkreEJ8R.js} +1 -1
  11. package/dist/web/assets/Compare-CgOfZofk.js +1 -0
  12. package/dist/web/assets/{Cost-DGZ5t-Q_.js → Cost-Dl5-viu4.js} +1 -1
  13. package/dist/web/assets/{Data-DqGA1ZtQ.js → Data-Bv2S5wkW.js} +4 -4
  14. package/dist/web/assets/Desktop-CifPwy5u.js +1 -0
  15. package/dist/web/assets/DesktopReview-fpGdtU4r.js +1 -0
  16. package/dist/web/assets/Evidence-hOZDzfKt.js +1 -0
  17. package/dist/web/assets/{Explore-TtfTWmGW.js → Explore-c85VGE9Q.js} +2 -2
  18. package/dist/web/assets/{Features-DazoSiEi.js → Features-DXL_vSjn.js} +1 -1
  19. package/dist/web/assets/{Flags-Brja-ZXF.js → Flags-B7x2pDud.js} +2 -2
  20. package/dist/web/assets/Flaky-BM3syqCt.js +1 -0
  21. package/dist/web/assets/Impact-BUCh8OAI.js +3 -0
  22. package/dist/web/assets/Jobs-B8sBDYRI.js +5 -0
  23. package/dist/web/assets/KindPage-yVmpQm7L.js +6 -0
  24. package/dist/web/assets/Migration-BOLN1duU.js +2 -0
  25. package/dist/web/assets/Product-C0FeEaJg.js +7 -0
  26. package/dist/web/assets/Production-BSMQyWKd.js +1 -0
  27. package/dist/web/assets/{Quality-C4Aak_hw.js → Quality-DsM9gWZb.js} +1 -1
  28. package/dist/web/assets/Readiness-BhqkAJYN.js +1 -0
  29. package/dist/web/assets/Record-CPx-lK53.js +2 -0
  30. package/dist/web/assets/Regression-BXbX46nO.js +5 -0
  31. package/dist/web/assets/{RelationGraph-DLeEarQd.js → RelationGraph-eoGXXz5t.js} +1 -1
  32. package/dist/web/assets/{Reports-ClSAzQOh.js → Reports-36YQzVhA.js} +2 -2
  33. package/dist/web/assets/Response-DplUOsue.js +4 -0
  34. package/dist/web/assets/{RunDiff-0ibEcmI5.js → RunDiff-D0fDhRmK.js} +1 -1
  35. package/dist/web/assets/{Runs-T8yF8Hi0.js → Runs-Bv1Ef8zq.js} +2 -2
  36. package/dist/web/assets/{Steps-CB30w6BA.js → Steps-Cm-atRtk.js} +2 -2
  37. package/dist/web/assets/TestCases-B9x9W3zJ.js +1 -0
  38. package/dist/web/assets/TestData-DsJ6Z2YI.js +2 -0
  39. package/dist/web/assets/TestDebt-B_FUbMOb.js +1 -0
  40. package/dist/web/assets/Tosca-nxVCubA5.js +3 -0
  41. package/dist/web/assets/{WhatsNew-D7n48IsG.js → WhatsNew-CdnbMvrr.js} +1 -1
  42. package/dist/web/assets/agentLink-BGKAF6xd.js +1 -0
  43. package/dist/web/assets/{dataParts-CZAcb4L_.js → dataParts-Bn-tzbKg.js} +3 -3
  44. package/dist/web/assets/{families-D2ygriY6.js → families-DPlFfKf2.js} +1 -1
  45. package/dist/web/assets/filters-Bj5K1WaL.js +1 -0
  46. package/dist/web/assets/{fold-BhYvId2X.js → fold-BhRpA0sy.js} +1 -1
  47. package/dist/web/assets/frame-D_TPoUTD.js +16 -0
  48. package/dist/web/assets/index-BRB-oAMd.js +67 -0
  49. package/dist/web/assets/index-CIw5WfL8.css +2 -0
  50. package/dist/web/assets/{logos-DmK40tlV.js → logos-839CfoKx.js} +1 -1
  51. package/dist/web/assets/{markdown-Bej6qyls.js → markdown-6z0km3hN.js} +3 -3
  52. package/dist/web/assets/paletteCommands-CZFdKGhh.js +1 -0
  53. package/dist/web/assets/{parts-BOpbd90H.js → parts-VPcxh6Jc.js} +1 -1
  54. package/dist/web/assets/{productParts-B3_FGd-T.js → productParts-BjfWgMtq.js} +1 -1
  55. package/dist/web/assets/{qualityParts-B8yJRVpP.js → qualityParts-PGN65yfI.js} +1 -1
  56. package/dist/web/assets/{recordTest-CZUrGm8I.js → recordTest-EkxSMWbe.js} +1 -1
  57. package/dist/web/assets/{rows-BcG6gFCy.js → rows-uLoguIo5.js} +1 -1
  58. package/dist/web/assets/{segmented-ffWUfF8N.js → segmented-DphDskQz.js} +1 -1
  59. package/dist/web/assets/{usePageChat-T6vQY_1C.js → usePageChat-DqEwGcyO.js} +1 -1
  60. package/dist/web/index.html +5 -5
  61. package/docs/user-guide.html +78 -16
  62. package/package.json +3 -1
  63. package/prompts/requests-rule.md +1 -1
  64. package/prompts/talk-summary.md +43 -0
  65. package/prompts/talk.md +49 -0
  66. package/prompts/test-agent.md +1 -0
  67. package/py/forgeqe_data/__init__.py +1 -0
  68. package/py/forgeqe_data/__main__.py +12 -0
  69. package/py/forgeqe_data/connect.py +290 -0
  70. package/py/forgeqe_data/connstr.py +169 -0
  71. package/py/forgeqe_data/flows.py +603 -0
  72. package/py/forgeqe_data/guard.py +214 -0
  73. package/py/forgeqe_data/mongo.py +219 -0
  74. package/py/forgeqe_data/schema.py +431 -0
  75. package/py/forgeqe_data/service.py +651 -0
  76. package/py/forgeqe_data/streams.py +400 -0
  77. package/py/forgeqe_data/subset.py +299 -0
  78. package/py/forgeqe_data/testdata.py +861 -0
  79. package/py/forgeqe_data/vector.py +113 -0
  80. package/py/forgeqe_talk/__init__.py +1 -0
  81. package/py/forgeqe_talk/__main__.py +65 -0
  82. package/py/forgeqe_voice/worker.py +24 -4
  83. package/dist/web/assets/Agent-bSVNDlcU.js +0 -8
  84. package/dist/web/assets/ApiTests-DOxGgoZC.js +0 -10
  85. package/dist/web/assets/Browse-CG8jzqR1.js +0 -2
  86. package/dist/web/assets/Chat-DzufzeGg.js +0 -5
  87. package/dist/web/assets/Compare-6vHuAaKv.js +0 -1
  88. package/dist/web/assets/Desktop-CSOFE8cN.js +0 -1
  89. package/dist/web/assets/DesktopReview-BWtionFH.js +0 -1
  90. package/dist/web/assets/Evidence-D8pLFcbr.js +0 -1
  91. package/dist/web/assets/Flaky-jJlHFFCa.js +0 -1
  92. package/dist/web/assets/Impact-b60dmhJK.js +0 -3
  93. package/dist/web/assets/Jobs-Y9W9nBgx.js +0 -5
  94. package/dist/web/assets/KindPage-Y72w2UwG.js +0 -6
  95. package/dist/web/assets/Migration-CvIeTB9p.js +0 -2
  96. package/dist/web/assets/Product-BEe2GyO6.js +0 -7
  97. package/dist/web/assets/Production-D2qmPFYy.js +0 -1
  98. package/dist/web/assets/Readiness-ClXnnmLo.js +0 -1
  99. package/dist/web/assets/Record-LaLYhQgk.js +0 -2
  100. package/dist/web/assets/Regression-DKz05MC_.js +0 -5
  101. package/dist/web/assets/Response-De60pk_7.js +0 -10
  102. package/dist/web/assets/TestCases-Ba6bUE4i.js +0 -1
  103. package/dist/web/assets/TestData-DefDzeMW.js +0 -2
  104. package/dist/web/assets/TestDebt-zohltDHp.js +0 -1
  105. package/dist/web/assets/Tosca-jAtdiG28.js +0 -3
  106. package/dist/web/assets/filters-CYaF2RvC.js +0 -1
  107. package/dist/web/assets/frame-DeJBYtBX.js +0 -11
  108. package/dist/web/assets/index-CYlacOTX.css +0 -2
  109. package/dist/web/assets/index-DXpBYobT.js +0 -67
  110. package/dist/web/assets/paletteCommands-CKBMmhb4.js +0 -1
@@ -0,0 +1,113 @@
1
+ """
2
+ DB-GPT's schema index for a database marked ``vector: true``: a summary of every table (its columns, keys and comment)
3
+ embedded and stored in Chroma, and DB-GPT's retriever to find the tables a question is about.
4
+
5
+ The summaries come from the cached catalog (catalog_connector), so building the index sends no query to the database.
6
+ The embedding model is chromadb's all-MiniLM-L6-v2 in ONNX, run on this machine: nothing leaves it, and chromadb checks
7
+ the model's SHA-256 when it downloads it (once, into ~/.forgeqe/data/models).
8
+
9
+ On real schemas this small model ranks tables less well than the word linking in schema.py (measured on an Odoo
10
+ database of 938 tables), so its hits are extra candidates for schema.link, never a replacement.
11
+ """
12
+ from __future__ import annotations
13
+
14
+ import json
15
+ import os
16
+ import shutil
17
+ from pathlib import Path
18
+ from typing import Any, Dict, List, Mapping
19
+
20
+ TOP_K = 10
21
+
22
+
23
+ def _models_dir() -> Path:
24
+ return Path(os.environ.get("FORGEQE_HOME") or Path.home() / ".forgeqe") / "data" / "models" / "all-MiniLM-L6-v2"
25
+
26
+
27
+ class _CatalogConnector:
28
+ """What DB-GPT's table summaries ask of a connector, answered from the catalog: no database round trips."""
29
+
30
+ db_type = "catalog"
31
+
32
+ def __init__(self, catalog: Mapping[str, Any]) -> None:
33
+ self.tables = catalog.get("tables") or {}
34
+
35
+ def get_table_names(self) -> List[str]:
36
+ return list(self.tables)
37
+
38
+ def get_columns(self, table: str) -> List[Dict[str, Any]]:
39
+ return [{"name": c["name"], "type": c["type"], "comment": c.get("comment")} for c in self.tables[table]["columns"]]
40
+
41
+ def get_indexes(self, table: str) -> List[Dict[str, Any]]:
42
+ return [{"name": f"unique_{i}", "column_names": cols} for i, cols in enumerate(self.tables[table].get("unique") or [])]
43
+
44
+ def get_table_comment(self, table: str) -> Dict[str, str]:
45
+ return {"text": self.tables[table].get("comment") or ""}
46
+
47
+ def is_graph_type(self) -> bool:
48
+ return False
49
+
50
+
51
+ def _embeddings() -> Any:
52
+ from chromadb.utils.embedding_functions import ONNXMiniLM_L6_V2
53
+ from dbgpt.core import Embeddings
54
+
55
+ model = ONNXMiniLM_L6_V2()
56
+ model.DOWNLOAD_PATH = _models_dir()
57
+
58
+ class LocalEmbeddings(Embeddings):
59
+ def embed_documents(self, texts: List[str]) -> List[List[float]]:
60
+ return [[float(x) for x in v] for v in model(texts)]
61
+
62
+ def embed_query(self, text: str) -> List[float]:
63
+ return self.embed_documents([text])[0]
64
+
65
+ return LocalEmbeddings()
66
+
67
+
68
+ def _stores(folder: Path, embeddings: Any) -> Any:
69
+ from dbgpt_ext.storage.vector_store.chroma_store import ChromaStore, ChromaVectorConfig
70
+
71
+ cfg = ChromaVectorConfig(persist_path=str(folder))
72
+ return ChromaStore(cfg, name="tables", embedding_fn=embeddings), ChromaStore(cfg, name="fields", embedding_fn=embeddings)
73
+
74
+
75
+ def _meta(folder: Path) -> Dict[str, Any]:
76
+ try:
77
+ return json.loads((folder / "index.json").read_text(encoding="utf-8"))
78
+ except (OSError, ValueError):
79
+ return {}
80
+
81
+
82
+ def ensure(catalog: Mapping[str, Any], folder: Path, log: Any = lambda _: None) -> None:
83
+ """The index for this catalog, built when there is none or the catalog was read again since."""
84
+ if _meta(folder).get("catalog_read_at") == catalog.get("read_at") and (folder / "chromadb").exists():
85
+ return
86
+ from dbgpt_ext.rag.assembler.db_schema import DBSchemaAssembler
87
+
88
+ shutil.rmtree(folder, ignore_errors=True)
89
+ folder.mkdir(parents=True, exist_ok=True)
90
+ count = len(catalog.get("tables") or {})
91
+ log(f"Building the schema index of {count} tables (DB-GPT, a local embedding model; once per schema change).")
92
+ embeddings = _embeddings()
93
+ tables, fields = _stores(folder, embeddings)
94
+ DBSchemaAssembler.load_from_connection(
95
+ connector=_CatalogConnector(catalog), table_vector_store_connector=tables, field_vector_store_connector=fields, embeddings=embeddings
96
+ ).persist()
97
+ (folder / "index.json").write_text(json.dumps({"catalog_read_at": catalog.get("read_at"), "tables": count}), encoding="utf-8")
98
+
99
+
100
+ def search(catalog: Mapping[str, Any], folder: Path, question: str, k: int = TOP_K, log: Any = lambda _: None) -> List[str]:
101
+ """The tables DB-GPT's retriever ranks highest for a question, best first."""
102
+ from dbgpt_ext.rag.retriever.db_schema import DBSchemaRetriever
103
+
104
+ ensure(catalog, folder, log)
105
+ tables, fields = _stores(folder, _embeddings())
106
+ retriever = DBSchemaRetriever(table_vector_store_connector=tables, field_vector_store_connector=fields, top_k=k, separator="--table-field-separator--")
107
+ known = catalog.get("tables") or {}
108
+ hits: List[str] = []
109
+ for chunk in retriever.retrieve(question):
110
+ name = (chunk.metadata or {}).get("table_name")
111
+ if name in known and name not in hits:
112
+ hits.append(name)
113
+ return hits
@@ -0,0 +1 @@
1
+ """Talk's voice agent's model calls (src/talk/agent.ts): one warm client for quick turns."""
@@ -0,0 +1,65 @@
1
+ """
2
+ ``python -m forgeqe_talk serve``: Talk's voice agent's model, kept warm for quick turns (src/talk/agent.ts).
3
+
4
+ The first line on stdin is ``{"llm": <profile>}`` (llms.json's, as the engine takes it); each line after it is one
5
+ call, ``{"id": "<id>", "messages": [...], "max_tokens": n}``, answered on stdout as ``{"id", "ok", "text"}`` or
6
+ ``{"id", "ok": false, "error"}``, in the order asked. The model is asked for JSON (the voice agent's answer, which the
7
+ gateway checks). Each call's time and tokens go out as ``{"type": "call", ...}``; never a prompt or a reply.
8
+ """
9
+ from __future__ import annotations
10
+
11
+ import json
12
+ import re
13
+ import sys
14
+ from typing import Any, Dict, IO
15
+
16
+ MAX_LINE = 400_000
17
+ _ID = re.compile(r"^[A-Za-z0-9_-]{1,64}$")
18
+
19
+
20
+ def _emit(out: IO[str], event: Dict[str, Any]) -> None:
21
+ out.write(json.dumps(event, ensure_ascii=False) + "\n")
22
+ out.flush()
23
+
24
+
25
+ def serve(stdin: IO[str] = sys.stdin, stdout: IO[str] = sys.stdout, model_factory: Any = None) -> int:
26
+ first = stdin.readline()
27
+ try:
28
+ req = json.loads(first or "{}")
29
+ profile = req.get("llm") if isinstance(req, dict) else None
30
+ if not isinstance(profile, dict):
31
+ raise ValueError("the first line must be {\"llm\": <profile>}")
32
+ if model_factory is None:
33
+ from forgeqe_desktop.models import DesktopModel
34
+
35
+ model_factory = DesktopModel
36
+ model = model_factory(profile, on_call=lambda c: _emit(stdout, {"type": "call", **c}), timeout=60.0)
37
+ except Exception as e: # noqa: BLE001 - said to the gateway, which says it to the page
38
+ _emit(stdout, {"type": "fatal", "error": f"{type(e).__name__}: {e}"[:500]})
39
+ return 1
40
+ _emit(stdout, {"type": "ready"})
41
+ for line in stdin:
42
+ if len(line) > MAX_LINE:
43
+ continue
44
+ try:
45
+ call = json.loads(line)
46
+ except ValueError:
47
+ continue
48
+ cid = call.get("id") if isinstance(call, dict) else None
49
+ messages = call.get("messages") if isinstance(call, dict) else None
50
+ if not isinstance(cid, str) or not _ID.match(cid) or not isinstance(messages, list):
51
+ continue
52
+ max_tokens = call.get("max_tokens") if isinstance(call.get("max_tokens"), int) else 400
53
+ try:
54
+ text = model.complete(messages, max_tokens=max(50, min(max_tokens, 1000)), json_mode=True)
55
+ _emit(stdout, {"id": cid, "ok": True, "text": text[:20_000]})
56
+ except Exception as e: # noqa: BLE001 - one failed call; the next may work
57
+ _emit(stdout, {"id": cid, "ok": False, "error": f"{type(e).__name__}: {e}"[:500]})
58
+ return 0
59
+
60
+
61
+ if __name__ == "__main__":
62
+ if sys.argv[1:] != ["serve"]:
63
+ sys.stderr.write("usage: python -m forgeqe_talk serve\n")
64
+ sys.exit(2)
65
+ sys.exit(serve())
@@ -29,10 +29,17 @@ FORMAT = 1
29
29
  RATE_IN = 16_000
30
30
  MAX_SECONDS = 30
31
31
  MAX_TEXT = 600
32
- VOICE = re.compile(r"^[ab][fm]_[a-z]{2,12}$")
32
+ VOICE = re.compile(r"^[abh][fm]_[a-z]{2,12}$")
33
33
  LANGUAGES = {"en", "de", "es", "fr", "it", "nl", "pt", "pl", "hi", "ja", "zh"}
34
34
  # Words ForgeQE's people say often, so Whisper spells them as they are written.
35
- PROMPT = "ForgeQE, Playwright, Cypress, Selenium, regression pack, staging, test case, Jira, Azure DevOps."
35
+ # The words people say to ForgeQE that Whisper does not know ("ADO" heard as "a do", "TestMu" as "Tasmo"): a fixed list,
36
+ # never what anyone typed, so it only leans what is heard toward these spellings.
37
+ PROMPT = (
38
+ "ForgeQE, ADO, Azure DevOps, Jira, ACs, acceptance criteria, work item, user story, test case, test plan, "
39
+ "TestMu, BrowserStack, Playwright, Cypress, Selenium, Appium, Maestro, Tosca, regression pack, staging, Record, runs."
40
+ )
41
+ # Hindi as people say it to ForgeQE: Hindi with its English terms ("मॉडल सेटिंग्स खोलो", "ADO से 256 के ACs"). Fixed.
42
+ HI_PROMPT = "ForgeQE, ADO, Azure DevOps, Jira, ACs, TestMu, Playwright. मॉडल सेटिंग्स खोलो। मेरे फेल हुए रन दिखाओ। टेस्ट केस।"
36
43
 
37
44
 
38
45
  def _say(msg: dict) -> None:
@@ -45,7 +52,10 @@ class Voice:
45
52
  from faster_whisper import WhisperModel
46
53
  from kokoro_onnx import Kokoro
47
54
 
55
+ self.models = models
48
56
  self.whisper = WhisperModel(str(models / "whisper-base"), device="cpu", compute_type="int8")
57
+ # Hindi's listening model (whisper-small), loaded the first time Hindi is heard, when it was downloaded.
58
+ self.whisper_hi = None
49
59
  self.kokoro = Kokoro(str(models / "kokoro" / "kokoro-v1.0.int8.onnx"), str(models / "kokoro" / "voices-v1.0.bin"))
50
60
  self.voices = set(self.kokoro.get_voices())
51
61
 
@@ -59,7 +69,16 @@ class Voice:
59
69
  if language not in LANGUAGES:
60
70
  raise ValueError("That language is not one Talk offers.")
61
71
  audio = np.frombuffer(raw, dtype="<i2").astype(np.float32) / 32768.0
62
- segments, _ = self.whisper.transcribe(audio, language=language, beam_size=1, vad_filter=True, initial_prompt=PROMPT, condition_on_previous_text=False)
72
+ model, prompt = self.whisper, PROMPT
73
+ if language == "hi":
74
+ small = self.models / "whisper-small"
75
+ if self.whisper_hi is None and (small / "model.bin").is_file():
76
+ from faster_whisper import WhisperModel
77
+
78
+ self.whisper_hi = WhisperModel(str(small), device="cpu", compute_type="int8")
79
+ if self.whisper_hi is not None:
80
+ model, prompt = self.whisper_hi, HI_PROMPT
81
+ segments, _ = model.transcribe(audio, language=language, beam_size=1, vad_filter=True, initial_prompt=prompt, condition_on_previous_text=False)
63
82
  return {"text": " ".join(s.text.strip() for s in segments).strip()}
64
83
 
65
84
  def speak(self, req: dict) -> dict:
@@ -71,7 +90,8 @@ class Voice:
71
90
  raise ValueError("Nothing to say, or too much.")
72
91
  if not isinstance(voice, str) or not VOICE.match(voice) or voice not in self.voices:
73
92
  raise ValueError("That voice is not one Talk offers.")
74
- samples, rate = self.kokoro.create(text, voice=voice, speed=1.0, lang="en-gb" if voice.startswith("b") else "en-us")
93
+ lang = "hi" if voice.startswith("h") else "en-gb" if voice.startswith("b") else "en-us"
94
+ samples, rate = self.kokoro.create(text, voice=voice, speed=1.0, lang=lang)
75
95
  pcm = (np.clip(samples, -1.0, 1.0) * 32767).astype("<i2").tobytes()
76
96
  out = io.BytesIO()
77
97
  with wave.open(out, "wb") as w: