Spaces:
Paused
Paused
Alessandro commited on
Commit ·
602cfdc
1
Parent(s): b745266
other things + Embedding Model selection
Browse filesFiles changed (4)
- initialize.py+1-1
- models.py+15
- python/helpers/settings.py+46-9
- webui/settings.css+25-4
32 unmodified lines3334353637383932 unmodified lineschat_model = chat_llm,utility_model = utility_llm,embeddings_model = embedding_llm,prompts_subdir = "dianoia-xl",# memory_subdir = "",knowledge_subdirs = ["default","custom"],auto_memory_count = 0,32 unmodified lines3334353637383932 unmodified lineschat_model = chat_llm,utility_model = utility_llm,embeddings_model = embedding_llm,prompts_subdir = "",# memory_subdir = "",knowledge_subdirs = ["default","custom"],auto_memory_count = 0,
43 unmodified lines4445464748493 unmodified lines5354555657585960616243 unmodified linesOPENROUTER = "OpenRouter"SAMBANOVA = "Sambanova"# Utility function to get API keys from environment variablesdef get_api_key(service):3 unmodified linesdef get_model(type: ModelType, provider: ModelProvider, name: str, **kwargs):fnc_name = f"get_{provider.name.lower()}_{type.name.lower()}" # function name of model gettermodel = globals()[fnc_name](name, **kwargs) # call function by namereturn model# Ollama modelsdef get_ollama_chat(43 unmodified lines444546474849505152535455563 unmodified lines60616263646566676869707172737475767743 unmodified linesOPENROUTER = "OpenRouter"SAMBANOVA = "Sambanova"class EmbeddingProvider(Enum):OPENAI = "OpenAI" # defaultHUGGINGFACE = "HuggingFace"OLLAMA = "Ollama"LMSTUDIO = "LM Studio"OPENROUTER = "OpenRouter"AZURE = "OpenAI Azure"# Utility function to get API keys from environment variablesdef get_api_key(service):3 unmodified linesdef get_model(type: ModelType, provider: ModelProvider, name: str, **kwargs):if type == ModelType.EMBEDDING:# call function for embedding modelsreturn get_embedding_model(provider, name, **kwargs)# for other model typesfnc_name = f"get_{provider.name.lower()}_{type.name.lower()}" # function name of model gettermodel = globals()[fnc_name](name, **kwargs) # call function by namereturn modeldef get_embedding_model(provider: EmbeddingProvider, name: str, **kwargs):fnc_name = f"get_{provider.name.lower()}_embedding" # function name for embedding modelsmodel = globals()[fnc_name](name, **kwargs) # call function by namereturn model# Ollama modelsdef get_ollama_chat(
2 unmodified lines345678922 unmodified lines3233343536373839 unmodified lines7879808182838485868788899038 unmodified lines12913013113213313413513613713813914014158 unmodified lines20020120220320420520621 unmodified lines2282292302312322332342 unmodified linesimport refrom typing import Any, Optional, TypedDictfrom . import filesfrom models import get_model, ModelProvider, ModelTypefrom langchain_core.language_models.chat_models import BaseChatModelfrom langchain_core.embeddings import Embeddings22 unmodified linesdef convert_out(settings: Settings) -> dict[str, Any]:# main model sectionchat_model_fields = []chat_model_fields.append(39 unmodified lines})chat_model_seciton = {"title": "Chat Model","description": "Selection and settings for main chat model used by Agent Zero","fields": chat_model_fields,}# main model sectionutil_model_fields = []util_model_fields.append({38 unmodified lines})util_model_seciton = {"title": "Utility model","description": "Smaller, cheaper, faster model for handling utility tasks like organizing memory, preparing prompts, summarizing.","fields": util_model_fields,}result = {"sections": [chat_model_seciton, util_model_seciton]}return resultdef convert_in(settings: dict[str, Any]) -> Settings:58 unmodified linessettings = get_settings()return get_model(type=ModelType.EMBEDDING,provider=ModelProvider[settings["embed_model_provider"]],name=settings["embed_model_name"],**settings["embed_model_kwargs"],)21 unmodified linesutil_model_name="gpt-4o-mini",util_model_temperature=0,util_model_kwargs={},embed_model_provider=ModelProvider.OPENAI.name,embed_model_name="text-embedding-3-small",embed_model_kwargs={},)2 unmodified lines345678922 unmodified lines32333435363739 unmodified lines7778798081828384858687888938 unmodified lines12812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717858 unmodified lines23723823924024124224321 unmodified lines2652662672682692702712 unmodified linesimport refrom typing import Any, Optional, TypedDictfrom . import filesfrom models import get_model, get_embedding_model, ModelProvider, EmbeddingProvider, ModelTypefrom langchain_core.language_models.chat_models import BaseChatModelfrom langchain_core.embeddings import Embeddings22 unmodified linesdef convert_out(settings: Settings) -> dict[str, Any]:# main model sectionchat_model_fields = []chat_model_fields.append(39 unmodified lines})chat_model_section = {"title": "Chat Model","description": "Selection and settings for main chat model used by Agent Zero","fields": chat_model_fields,}# utility model sectionutil_model_fields = []util_model_fields.append({38 unmodified lines})util_model_section = {"title": "Utility Model","description": "Smaller, cheaper, faster model for handling utility tasks like organizing memory, preparing prompts, summarizing.","fields": util_model_fields,}# embedding model sectionembed_model_fields = []embed_model_fields.append({"id": "embed_model_provider","title": "Embedding model provider","description": "Select provider for embedding model used by the framework","type": "select","value": settings["embed_model_provider"],"options": [{"value": p.name, "label": p.value} for p in EmbeddingProvider],})embed_model_fields.append({"id": "embed_model_name","title": "Embedding model name","description": "Exact name of model from selected provider","type": "input","value": settings["embed_model_name"],})embed_model_fields.append({"id": "embed_model_kwargs","title": "Embedding model additional parameters","description": "Any other parameters supported by the model. Format is KEY=VALUE on individual lines, just like .env file.","type": "textarea","value": _dict_to_env(settings["embed_model_kwargs"]),})embed_model_section = {"title": "Embedding Model","description": "Settings for the embedding model used by Agent Zero.","fields": embed_model_fields,}result = {"sections": [chat_model_section, util_model_section, embed_model_section]}return resultdef convert_in(settings: dict[str, Any]) -> Settings:58 unmodified linessettings = get_settings()return get_model(type=ModelType.EMBEDDING,provider=EmbeddingProvider[settings["embed_model_provider"]],name=settings["embed_model_name"],**settings["embed_model_kwargs"],)21 unmodified linesutil_model_name="gpt-4o-mini",util_model_temperature=0,util_model_kwargs={},embed_model_provider=EmbeddingProvider.OPENAI.name,embed_model_name="text-embedding-3-small",embed_model_kwargs={},)
12319 unmodified lines23242526272829303 unmodified lines343536373839172 unmodified lines21221321421521621721821922022122222322422522622722822923016 unmodified lines247248249250251252.modal-overlay {position: fixed;top: 0;19 unmodified lines}.modal-header {padding: 1.5rem 2rem;border-bottom: 1px solid #eee;}.modal-content {3 unmodified linesbackground-clip: border-box;border: 6px solid transparent;transition: all 0.3s ease;}.modal-content::-webkit-scrollbar {172 unmodified lines.btn-ok {background: #3270e2;color: white;}.btn-ok:hover{background: #274170;}.btn-cancel {background: #ddd;color: #333;}.btn-cancel:hover {background: #222}.btn-field {16 unmodified linesfont-size: inherit;cursor: pointer;font-family: Rubik;}select:disabled {123456789101119 unmodified lines31323334353637383 unmodified lines4243444546474849172 unmodified lines22222322422522622722822923023123223323423523623723823924024124224324424524624724824925016 unmodified lines267268269270271272273* {transition: all var(--transition-speed) ease-in-out;}select {transition: none;}.modal-overlay {position: fixed;top: 0;19 unmodified lines}.modal-header {padding: 0.875rem 2rem;border-bottom: 1px solid var(--color-border);}.modal-content {3 unmodified linesbackground-clip: border-box;border: 6px solid transparent;transition: all 0.3s ease;margin-bottom: 0;padding-bottom: 0;}.modal-content::-webkit-scrollbar {172 unmodified lines.btn-ok {background: #3270e2;color: white;transition: background 0.3s ease-in-out;}.btn-ok:hover{background: #3265c0;}.btn-ok:active{background: #345693;}.btn-cancel {background: #ddd;color: #333;transition: background 0.3s ease-in-out;}.btn-cancel:hover {background: #a6a6a6}.btn-cancel:active {background: #808080}.btn-field {16 unmodified linesfont-size: inherit;cursor: pointer;font-family: Rubik;outline: none;}select:disabled {
initialize.py+1-1
models.py+15
python/helpers/settings.py+46-9
webui/settings.css+25-4