Last active
December 5, 2023 16:10
-
-
Save hwchase17/af2230cfc648078e1c4925c9fc183ed1 to your computer and use it in GitHub Desktop.
Revisions
-
hwchase17 revised this gist
Dec 5, 2022 . 1 changed file with 7 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,17 +1,19 @@ from langchain.llms.base import LLM from typing import Optional, List, Mapping, Any import requests from langchain.llms.utils import enforce_stop_tokens class CustomLLM(LLM): def __init__(self, url: str): self.url = url def __call__(self, prompt: str, stop: Optional[List[str]] = None) -> str: res = requests.get(self.url, params={"q": prompt}) text = res.content.decode() if stop is not None: text = enforce_stop_tokens(text, stop) return text llm = CustomLLM("http://127.0.0.1:5001/chat") -
hwchase17 revised this gist
Dec 5, 2022 . 1 changed file with 5 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -10,5 +10,8 @@ def __init__(self, url: str): def __call__(self, prompt: str, stop: Optional[List[str]] = None) -> str: if stop is not None: raise ValueError("stop kwargs are not permitted.") res = requests.get(self.url, params={"q": prompt}) return res.content.decode() llm = CustomLLM("http://127.0.0.1:5001/chat") -
hwchase17 created this gist
Dec 5, 2022 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,14 @@ from langchain.llms.base import LLM from typing import Optional, List, Mapping, Any import requests class CustomLLM(LLM): def __init__(self, url: str): self.url = url def __call__(self, prompt: str, stop: Optional[List[str]] = None) -> str: if stop is not None: raise ValueError("stop kwargs are not permitted.") res = requests.get("http://127.0.0.1:5001/chat", params={"q": prompt}) return res.content.decode()