Update src/llm/langchain_llm.py
Browse files- src/llm/langchain_llm.py +18 -11
src/llm/langchain_llm.py
CHANGED
|
@@ -69,18 +69,25 @@ _API_KEY_VARS = {
|
|
| 69 |
|
| 70 |
|
| 71 |
def _reasoning_kwargs(provider: str, model_name: str) -> dict:
|
| 72 |
-
"""
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
|
|
|
|
|
|
| 83 |
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 84 |
return {}
|
| 85 |
|
| 86 |
|
|
|
|
| 69 |
|
| 70 |
|
| 71 |
def _reasoning_kwargs(provider: str, model_name: str) -> dict:
|
| 72 |
+
"""Ask Groq to hide reasoning-model chain-of-thought from the response.
|
| 73 |
+
|
| 74 |
+
Qwen/MiniMax/DeepSeek are reasoning models that otherwise spend the
|
| 75 |
+
completion's token budget on visible <think>...</think> content before
|
| 76 |
+
ever reaching the answer — observed in production: with a 2048-token
|
| 77 |
+
budget and no hidden-reasoning switch, the model's reasoning alone
|
| 78 |
+
exhausted it, the response was cut off mid-<think> block with no closing
|
| 79 |
+
tag, and engine.strip_reasoning correctly treated that as "the answer
|
| 80 |
+
never arrived", leaving an empty reply. `reasoning_format` is a top-level
|
| 81 |
+
ChatGroq constructor argument in this langchain-groq version, not a
|
| 82 |
+
model_kwargs entry — passing it inside model_kwargs raises a pydantic
|
| 83 |
+
ValidationError, which is why this returns a plain dict of top-level
|
| 84 |
+
kwargs rather than nesting it.
|
| 85 |
"""
|
| 86 |
+
if provider != "groq":
|
| 87 |
+
return {}
|
| 88 |
+
model = (model_name or "").lower()
|
| 89 |
+
if any(fam in model for fam in ("qwen", "minimax", "deepseek")):
|
| 90 |
+
return {"reasoning_format": "hidden"}
|
| 91 |
return {}
|
| 92 |
|
| 93 |
|