001/** 002 * Copyright (c) 2025-2026, Michael Yang 杨福海 (fuhai999@gmail.com). 003 * <p> 004 * Licensed under the GNU Lesser General Public License (LGPL) ,Version 3.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.gnu.org/licenses/lgpl-3.0.txt 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 dev.tinyflow.core; 017 018import com.agentsflex.core.chain.Chain; 019import com.agentsflex.core.util.StringUtil; 020import dev.tinyflow.core.parser.ChainParser; 021import dev.tinyflow.core.provider.KnowledgeProvider; 022import dev.tinyflow.core.provider.LlmProvider; 023 024public class Tinyflow { 025 026 private String data; 027 private LlmProvider llmProvider; 028 private KnowledgeProvider knowledgeProvider; 029 private ChainParser chainParser = new ChainParser(); 030 031 public Tinyflow() { 032 } 033 034 public Tinyflow(String flowData) { 035 this.data = flowData; 036 } 037 038 public String getData() { 039 return data; 040 } 041 042 public void setData(String data) { 043 this.data = data; 044 } 045 046 public LlmProvider getLlmProvider() { 047 return llmProvider; 048 } 049 050 public void setLlmProvider(LlmProvider llmProvider) { 051 this.llmProvider = llmProvider; 052 } 053 054 public KnowledgeProvider getKnowledgeProvider() { 055 return knowledgeProvider; 056 } 057 058 public void setKnowledgeProvider(KnowledgeProvider knowledgeProvider) { 059 this.knowledgeProvider = knowledgeProvider; 060 } 061 062 public ChainParser getChainParser() { 063 return chainParser; 064 } 065 066 public void setChainParser(ChainParser chainParser) { 067 this.chainParser = chainParser; 068 } 069 070 public Chain toChain() { 071 if (StringUtil.noText(data)) { 072 throw new IllegalStateException("data is empty"); 073 } 074 return chainParser.parse(this); 075 } 076 077}