Second-Me/lpm_kernel/api/models/user_llm_config.py
ryangyuan 9fe511f0f2
Feature/0416/add thinking mode (#264)
* fix: modify thinking_model loading configuration

* feat: realize thinkModel ui

* feat:store

* feat: add combined_llm_config_dto

* add thinking_model_config & database migration

* directly add thinking model to user_llm_config

* delete thinking model repo dto service

* delete thinkingmodel table migration

* add is_cot config

* feat: allow define  is_cot

* feat: simplify logs info

* feat: add training model

* feat: fix is_cot problem

* fix: fix chat message

* fix: fix progress error

* fix: disable no settings thinking

* feat: add thinking warning

* fix: fix start service error

* feat:fix init trainparams problem

* feat: change playGround prompt

* feat: Add Dimension Mismatch Handling for ChromaDB (#157) (#207)

* Fix Issue #157

Add chroma_utils.py to manage chromaDB and added docs for explanation

* Add logging and debugging process

- Enhanced the`reinitialize_chroma_collections` function in`chroma_utils.py` to properly check if collections exist before attempting to delete them, preventing potential errors when collections don't exist.
- Improved error handling in the`_handle_dimension_mismatch` method in`embedding_service.py` by adding more robust exception handling and verification steps after reinitialization.
- Enhanced the collection initialization process in`embedding_service.py` to provide more detailed error messages and better handle cases where collections still have incorrect dimensions after reinitialization.
- Added additional verification steps to ensure that collection dimensions match the expected dimension after creation or retrieval.
- Improved logging throughout the code to provide more context in error messages, making debugging easier.

* Change topics_generator timeout to 30 (#263)

* quick fix

* fix: shade -> shade_merge_info (#265)

* fix: shade -> shade_merge_info

* add convert array

* quick fix import error

* add log

* add heartbeat

* new strategy

* sse version

* add heartbeat

* zh to en

* optimize code

* quick fix convert function

* Feat/new branch management (#267)

* feat: new branch management

* feat: fix multi-upload

* optimize contribute management

---------

Co-authored-by: Crabboss Mr <1123357821@qq.com>
Co-authored-by: Ye Xiangle <yexiangle@mail.mindverse.ai>
Co-authored-by: Xinghan Pan <sampan090611@gmail.com>
Co-authored-by: doubleBlack2 <108928143+doubleBlack2@users.noreply.github.com>
Co-authored-by: kevin-mindverse <kevin@mindverse.ai>
Co-authored-by: KKKKKKKevin <115385420+kevin-mindverse@users.noreply.github.com>
2025-04-24 14:19:23 +08:00

72 lines
3.3 KiB
Python

from datetime import datetime
from sqlalchemy import Column, Integer, String, DateTime
from lpm_kernel.common.repository.database_session import Base
class UserLLMConfig(Base):
"""User-defined LLM configuration model with separate chat and embedding settings"""
__tablename__ = 'user_llm_configs'
id = Column(Integer, primary_key=True)
provider_type = Column(String(50), nullable=False, default='openai', comment='Provider type (e.g., openai)')
key = Column(String(200), nullable=True, comment='Common API key for provider-specific configurations')
# Chat configuration
chat_endpoint = Column(String(200), nullable=True, comment='Chat API endpoint')
chat_api_key = Column(String(200), nullable=True, comment='Chat API key')
chat_model_name = Column(String(200), nullable=True, comment='Chat model name')
# Embedding configuration
embedding_endpoint = Column(String(200), nullable=True, comment='Embedding API endpoint')
embedding_api_key = Column(String(200), nullable=True, comment='Embedding API key')
embedding_model_name = Column(String(200), nullable=True, comment='Embedding model name')
# Thinking configuration
thinking_model_name = Column(String(200), nullable=True, comment='Thinking model name')
thinking_endpoint = Column(String(200), nullable=True, comment='Thinking API endpoint')
thinking_api_key = Column(String(200), nullable=True, comment='Thinking API key')
created_at = Column(DateTime, default=datetime.utcnow, comment='Creation time')
updated_at = Column(DateTime, default=datetime.utcnow, onupdate=datetime.utcnow, comment='Update time')
def __repr__(self):
return f'<UserLLMConfig {self.id}>'
def to_dict(self):
"""Convert to dictionary"""
return {
'id': self.id,
'provider_type': self.provider_type,
'key': self.key,
'chat_endpoint': self.chat_endpoint,
'chat_api_key': self.chat_api_key,
'chat_model_name': self.chat_model_name,
'embedding_endpoint': self.embedding_endpoint,
'embedding_api_key': self.embedding_api_key,
'embedding_model_name': self.embedding_model_name,
'thinking_model_name': self.thinking_model_name,
'thinking_endpoint': self.thinking_endpoint,
'thinking_api_key': self.thinking_api_key,
'created_at': self.created_at,
'updated_at': self.updated_at
}
@classmethod
def from_dict(cls, data):
"""Create instance from dictionary"""
return cls(
id=data.get('id'),
provider_type=data.get('provider_type', 'openai'),
key=data.get('key'),
chat_endpoint=data.get('chat_endpoint'),
chat_api_key=data.get('chat_api_key'),
chat_model_name=data.get('chat_model_name'),
embedding_endpoint=data.get('embedding_endpoint'),
embedding_api_key=data.get('embedding_api_key'),
embedding_model_name=data.get('embedding_model_name'),
thinking_model_name=data.get('thinking_model_name'),
thinking_endpoint=data.get('thinking_endpoint'),
thinking_api_key=data.get('thinking_api_key'),
created_at=data.get('created_at'),
updated_at=data.get('updated_at')
)