Skip to content

Commit 8d961b9

Browse files
stavsapbaskaryan
andauthored
add preset ability to textgen llm (#7196)
add an ability for textgen llm to work with preset provided by text gen webui API. --------- Co-authored-by: Bagatur <[email protected]>
1 parent a9c5b4b commit 8d961b9

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

langchain/llms/textgen.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ class TextGen(LLM):
3333
model_url: str
3434
"""The full URL to the textgen webui including http[s]://host:port """
3535

36+
preset: Optional[str] = None
37+
"""The preset to use in the textgen webui """
38+
3639
max_new_tokens: Optional[int] = 250
3740
"""The maximum number of tokens to generate."""
3841

@@ -162,7 +165,10 @@ def _get_parameters(self, stop: Optional[List[str]] = None) -> Dict[str, Any]:
162165
if self.stopping_strings and stop is not None:
163166
raise ValueError("`stop` found in both the input and default params.")
164167

165-
params = self._default_params
168+
if self.preset is None:
169+
params = self._default_params
170+
else:
171+
params = {"preset": self.preset}
166172

167173
# then sets it as configured, or default to an empty list:
168174
params["stop"] = self.stopping_strings or stop or []

0 commit comments

Comments
 (0)