001/* 002 * Copyright (c) 2023-2026, Agents-Flex (fuhai999@gmail.com). 003 * <p> 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * <p> 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * <p> 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package com.agentsflex.core.model.embedding; 017 018import com.agentsflex.core.util.StringUtil; 019 020public class EmbeddingOptions { 021 public static final EmbeddingOptions DEFAULT = new EmbeddingOptions() { 022 @Override 023 public void setModel(String model) { 024 throw new IllegalStateException("Can not set modal to the default instance."); 025 } 026 027 @Override 028 public void setEncodingFormat(String encodingFormat) { 029 throw new IllegalStateException("Can not set modal to the default instance."); 030 } 031 }; 032 033 /** 034 * 嵌入模型 035 */ 036 private String model; 037 /** 038 * 嵌入编码格式,可用通常为float, base64 039 */ 040 private String encodingFormat; 041 042 private Integer dimensions; 043 044 private String user; 045 046 047 public String getModel() { 048 return model; 049 } 050 051 public String getModelOrDefault(String defaultModel) { 052 return StringUtil.noText(model) ? defaultModel : model; 053 } 054 055 public void setModel(String model) { 056 this.model = model; 057 } 058 059 060 public String getEncodingFormat() { 061 return encodingFormat; 062 } 063 064 public String getEncodingFormatOrDefault(String defaultEncodingFormat) { 065 return StringUtil.noText(encodingFormat) ? defaultEncodingFormat : encodingFormat; 066 } 067 068 public void setEncodingFormat(String encodingFormat) { 069 this.encodingFormat = encodingFormat; 070 } 071 072 public Integer getDimensions() { 073 return dimensions; 074 } 075 076 public void setDimensions(Integer dimensions) { 077 this.dimensions = dimensions; 078 } 079 080 public String getUser() { 081 return user; 082 } 083 084 public void setUser(String user) { 085 this.user = user; 086 } 087 088 @Override 089 public String toString() { 090 return "EmbeddingOptions{" + 091 "model='" + model + '\'' + 092 ", encodingFormat='" + encodingFormat + '\'' + 093 ", dimensions=" + dimensions + 094 ", user='" + user + '\'' + 095 '}'; 096 } 097}