llm_langchain
thml.llm_langchain
¶
Interface LLM models into LangChain's style to be used in the RAG system.
Classes:
-
G4FLLM–Interface to the G4F service.
-
MyGPT4ALL–A custom LLM class that integrates gpt4all models
-
DuckDuckGo–Initiates a chat session with DuckDuckGo AI.
-
WebBing–Reverse-engineered Bing/Edge Copilot via Web browser.
-
WebOpenGPTs–Reverse-engineered model via Web browser.
-
WebPhind–Reverse-engineered model via Web browser.
-
WebOpenai–Reverse-engineered Openai via Web browser.
G4FLLM
¶
Bases: LLM
Interface to the G4F service.
Parameters:
-
model(str = 'gpt-4') –The model to use for the chat client.
-
provider(str = None) –The provider to use for the chat client.
-
api_key(str = None) –The API key to use for the chat client.
-
kwargs(dict = None) –Additional parameters to pass to the g4f client.
Attributes:
-
model(str) – -
provider(Union[str, ProviderType]) – -
api_key(str) – -
create_kwargs(dict[str, Any]) –
MyGPT4ALL(model_folder_path, model_name, allow_download, allow_streaming)
¶
Bases: LLM
A custom LLM class that integrates gpt4all models
Arguments:
model_folder_path: (str) Folder path where the model lies
model_name: (str) The name of the model to use (
backend: (str) The backend of the model (Supported backends: llama/gptj) n_threads: (str) The number of threads to use n_predict: (str) The maximum numbers of tokens to generate temp: (str) Temperature to use for sampling top_p: (float) The top-p value to use for sampling top_k: (float) The top k values use for sampling n_batch: (int) Batch size for prompt processing repeat_last_n: (int) Last n number of tokens to penalize repeat_penalty: (float) The penalty to apply repeated tokens
Methods:
-
auto_download–This method will download the model to the specified path
Attributes:
-
model_folder_path(str) – -
model_name(str) – -
allow_download(bool) – -
allow_streaming(bool) – -
backend(Optional[str]) – -
temp(Optional[float]) – -
top_p(Optional[float]) – -
top_k(Optional[int]) – -
n_batch(Optional[int]) – -
n_threads(Optional[int]) – -
n_predict(Optional[int]) – -
max_tokens(Optional[int]) – -
repeat_last_n(Optional[int]) – -
repeat_penalty(Optional[float]) – -
gpt4_model_instance(Any) –
model_folder_path: str = model_folder_path
class-attribute
instance-attribute
¶
model_name: str = model_name
class-attribute
instance-attribute
¶
allow_download: bool = allow_download
class-attribute
instance-attribute
¶
allow_streaming: bool = allow_streaming
class-attribute
instance-attribute
¶
backend: Optional[str] = 'llama'
class-attribute
instance-attribute
¶
temp: Optional[float] = 0.7
class-attribute
instance-attribute
¶
top_p: Optional[float] = 0.1
class-attribute
instance-attribute
¶
top_k: Optional[int] = 40
class-attribute
instance-attribute
¶
n_batch: Optional[int] = 8
class-attribute
instance-attribute
¶
n_threads: Optional[int] = 4
class-attribute
instance-attribute
¶
n_predict: Optional[int] = 256
class-attribute
instance-attribute
¶
max_tokens: Optional[int] = 200
class-attribute
instance-attribute
¶
repeat_last_n: Optional[int] = 64
class-attribute
instance-attribute
¶
repeat_penalty: Optional[float] = 1.18
class-attribute
instance-attribute
¶
gpt4_model_instance: Any = GPT4All(model_name=(self.model_name), model_path=(self.model_folder_path))
class-attribute
instance-attribute
¶
auto_download() -> None
¶
This method will download the model to the specified path reference: python.langchain.com/docs/modules/model_io/models/llms/integrations/gpt4all
DuckDuckGo
¶
WebBing
¶
Bases: LLM
Reverse-engineered Bing/Edge Copilot via Web browser.
Parameters:
-
bot(object) –The Edge Chatbot object.
-
conversation_style(str) –The conversation style. Available options: 'creative', 'balanced', 'precise'
NOTE: LangChain does not allow __init__ method in the CustomLLM class. So, don't define any function in class-variables, since it will run when import module. All the running parts should be defined in the _call method. However, it will slow down the response time. Therefore, just pass critical parts to the _call method, all others should be defined outside this class.
Attributes:
-
bot(object) – -
conversation_style–
WebOpenGPTs
¶
Bases: LLM
Reverse-engineered model via Web browser.
Parameters:
-
max_tokens(int) –The maximum number of tokens to generate. Default is 4096.
Attributes:
-
max_tokens(int) – -
timeout(int) –
WebPhind
¶
Bases: LLM
Reverse-engineered model via Web browser.
Parameters:
-
max_tokens(int) –The maximum number of tokens to generate. Default is 4096.
Attributes:
-
model(str) – -
max_tokens(int) – -
timeout(int) –
WebOpenai
¶
Bases: LLM
Reverse-engineered Openai via Web browser.
Parameters:
-
bot(object) –The Edge Chatbot object.
-
conversation_style(str) –The conversation style. Available options: 'creative', 'balanced', 'precise'
Attributes:
-
cookie_file(str) – -
model(str) – -
keep_history(bool) –