From 8e1d22310ee133bd33ea8afaffa212fd56275d5f Mon Sep 17 00:00:00 2001 From: Rounak Bhatia Date: Wed, 8 Nov 2023 12:43:28 +0530 Subject: [PATCH] fixes --- gui/pages/Content/Models/ModelForm.js | 6 +++--- superagi/controllers/models_controller.py | 8 ++++++-- superagi/models/models_config.py | 2 +- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/gui/pages/Content/Models/ModelForm.js b/gui/pages/Content/Models/ModelForm.js index 45794bf18..83fff48ee 100644 --- a/gui/pages/Content/Models/ModelForm.js +++ b/gui/pages/Content/Models/ModelForm.js @@ -143,7 +143,7 @@ export default function ModelForm({internalId, getModels, sendModelData, env}){
{modelDropdown &&
{models.map((model, index) => ( -
handleModelSelect(index)} style={{padding: '12px 14px', maxWidth: '100%'}}> +
{setModelStatus(null); handleModelSelect(index)}} style={{padding: '12px 14px', maxWidth: '100%'}}> {model}
))}
} @@ -186,14 +186,14 @@ export default function ModelForm({internalId, getModels, sendModelData, env}){ onChange={(event) => setModelTokenLimit(parseInt(event.target.value, 10))}/>
- {modelStatus===false &&
+ {selectedModel === 'Local LLM' && modelStatus===false &&
error-icon
Test model failed
} - {modelStatus===true &&
+ {selectedModel === 'Local LLM' && modelStatus===true &&
Test model successful diff --git a/superagi/controllers/models_controller.py b/superagi/controllers/models_controller.py index 40f202461..e81acee44 100644 --- a/superagi/controllers/models_controller.py +++ b/superagi/controllers/models_controller.py @@ -1,3 +1,4 @@ +from typing import Optional from fastapi import APIRouter, Depends, HTTPException, Query, Body from superagi.helper.auth import check_auth, get_user_organisation from superagi.helper.models_helper import ModelsHelper @@ -28,7 +29,7 @@ class StoreModelRequest(BaseModel): token_limit: int type: str version: str - context_length: int + context_length: Optional[int] class ModelName (BaseModel): model: str @@ -74,7 +75,10 @@ async def store_model(request: StoreModelRequest, organisation=Depends(get_user_ try: #context_length = 4096 logger.info(request) - return Models.store_model_details(db.session, organisation.id, request.model_name, request.description, request.end_point, request.model_provider_id, request.token_limit, request.type, request.version, request.context_length) + if 'context_length' in request.dict(): + return Models.store_model_details(db.session, organisation.id, request.model_name, request.description, request.end_point, request.model_provider_id, request.token_limit, request.type, request.version, request.context_length) + else: + return Models.store_model_details(db.session, organisation.id, request.model_name, request.description, request.end_point, request.model_provider_id, request.token_limit, request.type, request.version, 0) except Exception as e: logging.error(f"Error storing the Model Details: {str(e)}") raise HTTPException(status_code=500, detail="Internal Server Error") diff --git a/superagi/models/models_config.py b/superagi/models/models_config.py index 7d577d331..03833ef05 100644 --- a/superagi/models/models_config.py +++ b/superagi/models/models_config.py @@ -106,7 +106,7 @@ def storeGptModels(cls, session, organisation_id, model_provider_id, model_api_k for model in models: if model not in installed_models and model in default_models: result = Models.store_model_details(session, organisation_id, model, model, '', - model_provider_id, default_models[model], 'Custom', '') + model_provider_id, default_models[model], 'Custom', '', 0) @classmethod def fetch_api_keys(cls, session, organisation_id):