Add CTransformersComponent and update CohereComponent display name
This commit is contained in:
parent
ece26b49c7
commit
980cdca42a
2 changed files with 39 additions and 1 deletions
38
src/backend/langflow/components/models/CTransformers.py
Normal file
38
src/backend/langflow/components/models/CTransformers.py
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
from typing import Dict, Optional
|
||||
|
||||
from langchain_community.llms.ctransformers import CTransformers
|
||||
from langflow.field_typing import Text
|
||||
|
||||
from langflow import CustomComponent
|
||||
|
||||
|
||||
class CTransformersComponent(CustomComponent):
|
||||
display_name = "CTransformers model"
|
||||
description = "C Transformers LLM models"
|
||||
documentation = "https://python.langchain.com/docs/modules/model_io/models/llms/integrations/ctransformers"
|
||||
|
||||
def build_config(self):
|
||||
return {
|
||||
"model": {"display_name": "Model", "required": True},
|
||||
"model_file": {
|
||||
"display_name": "Model File",
|
||||
"required": False,
|
||||
"field_type": "file",
|
||||
"file_types": [".bin"],
|
||||
},
|
||||
"model_type": {"display_name": "Model Type", "required": True},
|
||||
"config": {
|
||||
"display_name": "Config",
|
||||
"advanced": True,
|
||||
"required": False,
|
||||
"field_type": "dict",
|
||||
"value": '{"top_k":40,"top_p":0.95,"temperature":0.8,"repetition_penalty":1.1,"last_n_tokens":64,"seed":-1,"max_new_tokens":256,"stop":"","stream":"False","reset":"True","batch_size":8,"threads":-1,"context_length":-1,"gpu_layers":0}',
|
||||
},
|
||||
"inputs": {"display_name": "Input"},
|
||||
}
|
||||
|
||||
def build(self, model: str, model_file: str,inputs:str, model_type: str, config: Optional[Dict] = None) -> Text:
|
||||
output = CTransformers(model=model, model_file=model_file, model_type=model_type, config=config)
|
||||
message = output.invoke(inputs)
|
||||
self.status = message
|
||||
return message
|
||||
|
|
@ -4,7 +4,7 @@ from langflow.field_typing import Text
|
|||
|
||||
|
||||
class CohereComponent(CustomComponent):
|
||||
display_name = "Cohere"
|
||||
display_name = "Cohere model"
|
||||
description = "Cohere large language models."
|
||||
documentation = "https://python.langchain.com/docs/modules/model_io/models/llms/integrations/cohere"
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue