diff --git a/backend/app/evaluation/evals.py b/backend/app/evaluation/evals.py index d0ec58ccf..30073d577 100644 --- a/backend/app/evaluation/evals.py +++ b/backend/app/evaluation/evals.py @@ -77,7 +77,7 @@ def __init__( llm_provider = llm_provider.lower() if llm_provider == "openai": - self._llama_llm = OpenAI(model="gpt-4o") + self._llama_llm = OpenAI(model="gpt-4.1-2025-04-14") elif llm_provider == "gemini": self._llama_llm = Gemini(model="models/gemini-2.0-flash") else: @@ -86,7 +86,7 @@ def __init__( self._metrics = { "language": LanguageEvaluator(llm=self._llama_llm), "toxicity": ToxicityEvaluator(llm=self._llama_llm), - "e2e_rag": E2ERagEvaluator(model="gpt-4o"), + "e2e_rag": E2ERagEvaluator(model="gpt-4.1-2025-04-14"), } def runeval_dataset( @@ -162,7 +162,7 @@ def runeval_dataset( pd.DataFrame(error_list).to_csv(error_file, index=False) ragas_dataset = EvaluationDataset.from_list(ragas_list) - evaluator_llm = LangchainLLMWrapper(ChatOpenAI(model="gpt-4o")) + evaluator_llm = LangchainLLMWrapper(ChatOpenAI(model="gpt-4.1-2025-04-14")) evaluator_embeddings = LangchainEmbeddingsWrapper( OpenAIEmbeddings(model="text-embedding-3-large") ) diff --git a/backend/app/evaluation/evaluators/e2e_rag_evaluator.py b/backend/app/evaluation/evaluators/e2e_rag_evaluator.py index 6d60a5502..236378f61 100644 --- a/backend/app/evaluation/evaluators/e2e_rag_evaluator.py +++ b/backend/app/evaluation/evaluators/e2e_rag_evaluator.py @@ -16,7 +16,7 @@ class E2ERagEvaluator: - def __init__(self, model="gpt-4o", threshold=0.7) -> None: + def __init__(self, model="gpt-4.1-2025-04-14", threshold=0.7) -> None: self._model = model self._threshold = threshold diff --git a/backend/app/rag/llms/provider.py b/backend/app/rag/llms/provider.py index 9ab8a56a0..20dc7dbb9 100644 --- a/backend/app/rag/llms/provider.py +++ b/backend/app/rag/llms/provider.py @@ -37,7 +37,7 @@ class LLMProviderOption(BaseModel): provider_display_name="OpenAI", provider_description="The OpenAI API provides a simple interface for developers to create an intelligence layer in their applications, powered by OpenAI's state of the art models.", provider_url="https://platform.openai.com", - default_llm_model="gpt-4o", + default_llm_model="gpt-4.1-2025-04-14", llm_model_description="", credentials_display_name="OpenAI API Key", credentials_description="The API key of OpenAI, you can find it in https://platform.openai.com/api-keys", @@ -154,7 +154,7 @@ class LLMProviderOption(BaseModel): provider_display_name="Azure OpenAI", provider_description="Azure OpenAI is a cloud-based AI service that provides access to OpenAI's advanced language models.", provider_url="https://azure.microsoft.com/en-us/products/ai-services/openai-service", - default_llm_model="gpt-4o", + default_llm_model="gpt-4.1-2025-04-14", llm_model_description="", config_description="Refer to this document https://learn.microsoft.com/en-us/azure/ai-services/openai/quickstart to have more information about the Azure OpenAI API.", default_config={ diff --git a/backend/app/tasks/evaluate.py b/backend/app/tasks/evaluate.py index a77cd1f94..8670c578d 100644 --- a/backend/app/tasks/evaluate.py +++ b/backend/app/tasks/evaluate.py @@ -126,7 +126,7 @@ def evaluate_task(evaluation_task_item: EvaluationTaskItem): logger.debug(f"Dataset {ragas_dataset.to_pandas().head()}") evaluator_llm = LlamaIndexLLMWrapper( - OpenAI(model="gpt-4o", api_key=settings.EVALUATION_OPENAI_API_KEY) + OpenAI(model="gpt-4.1-2025-04-14", api_key=settings.EVALUATION_OPENAI_API_KEY) ) evaluator_embeddings = LlamaIndexEmbeddingsWrapper( OpenAIEmbedding( diff --git a/backend/dspy_program.py b/backend/dspy_program.py index 91d0bebae..0991c499a 100644 --- a/backend/dspy_program.py +++ b/backend/dspy_program.py @@ -5,7 +5,7 @@ def save_decompose_query_program(): - dspy_lm = dspy.LM(model="gpt-4o-mini", api_key=os.getenv("OPENAI_API_KEY")) + dspy_lm = dspy.LM(model="gpt-4.1-2025-04-14-mini", api_key=os.getenv("OPENAI_API_KEY")) module = DecomposeQueryModule(dspy_lm) module.save("dspy_compiled_program/decompose_query/program.json") diff --git a/backend/tests/test_llms.py b/backend/tests/test_llms.py index d7254de93..d5aba6fc5 100644 --- a/backend/tests/test_llms.py +++ b/backend/tests/test_llms.py @@ -66,7 +66,7 @@ def check_dspy_lm_extract_graph(lm: dspy.LM): def test_openai(): llm = resolve_llm( provider=LLMProvider.OPENAI, - model="gpt-4o-mini", + model="gpt-4.1-2025-04-14-mini", config={}, credentials=os.getenv("OPENAI_API_KEY"), ) @@ -152,11 +152,11 @@ def test_gemini(): def test_azure_ai(): llm = resolve_llm( provider=LLMProvider.AZURE_OPENAI, - model="gpt-4o-mini", + model="gpt-4.1-2025-04-14-mini", credentials=os.getenv("AZURE_AI_API_KEY"), config={ "azure_endpoint": os.getenv("AZURE_AI_ENDPOINT"), - "engine": "gpt-4o", + "engine": "gpt-4.1-2025-04-14", "api_version": "2025-01-01-preview", }, ) diff --git a/core/autoflow/configs/models/llms/common.py b/core/autoflow/configs/models/llms/common.py index 84bdbd6bd..51ea3e19e 100644 --- a/core/autoflow/configs/models/llms/common.py +++ b/core/autoflow/configs/models/llms/common.py @@ -6,7 +6,7 @@ class BaseLLMConfig(BaseModel): model: str = Field( description="The model to use for the LLM", - default="gpt-4o", + default="gpt-4.1-2025-04-14", ) max_tokens: Optional[int] = None temperature: float = 0.1 diff --git a/core/examples/quickstart/quickstart.ipynb b/core/examples/quickstart/quickstart.ipynb index 4812f9329..4532b432f 100644 --- a/core/examples/quickstart/quickstart.ipynb +++ b/core/examples/quickstart/quickstart.ipynb @@ -240,7 +240,7 @@ "from autoflow.models.embedding_models import EmbeddingModel\n", "from IPython.display import JSON\n", "\n", - "llm = LLM(\"gpt-4o-mini\")\n", + "llm = LLM(\"gpt-4.1-2025-04-14-mini\")\n", "embed_model = EmbeddingModel(\"text-embedding-3-small\")\n", "\n", "kb = af.create_knowledge_base(\n", diff --git a/core/examples/streamlit/build-knowledge-search-with-autoflow-and-streamlit.py b/core/examples/streamlit/build-knowledge-search-with-autoflow-and-streamlit.py index 6adca3497..872be99b0 100644 --- a/core/examples/streamlit/build-knowledge-search-with-autoflow-and-streamlit.py +++ b/core/examples/streamlit/build-knowledge-search-with-autoflow-and-streamlit.py @@ -53,7 +53,7 @@ st.stop() af = Autoflow(create_engine(database_url)) -chat_model = ChatModel("gpt-4o-mini", api_key=openai_api_key) +chat_model = ChatModel("gpt-4.1-2025-04-14-mini", api_key=openai_api_key) embedding_model = EmbeddingModel( model_name="text-embedding-3-small", dimensions=1536, diff --git a/core/tests/conftest.py b/core/tests/conftest.py index 36177975b..e08386ad7 100644 --- a/core/tests/conftest.py +++ b/core/tests/conftest.py @@ -35,7 +35,7 @@ def db_engine(): @pytest.fixture(scope="session") def llm(): - return LLM(model="openai/gpt-4o-mini") + return LLM(model="openai/gpt-4.1-2025-04-14-mini") @pytest.fixture(scope="session") diff --git a/core/tests/models/test_model_manager.py b/core/tests/models/test_model_manager.py index b2fc12f62..815943e29 100644 --- a/core/tests/models/test_model_manager.py +++ b/core/tests/models/test_model_manager.py @@ -36,7 +36,7 @@ def test_llm(): llm = model_manager.resolve_llm( provider=ModelProviders.OPENAI, config={ - "model": "gpt-4o", + "model": "gpt-4.1-2025-04-14", }, ) diff --git a/docs/src/content/faq.mdx b/docs/src/content/faq.mdx index 678e98de5..2d7665e89 100644 --- a/docs/src/content/faq.mdx +++ b/docs/src/content/faq.mdx @@ -35,7 +35,7 @@ export function FAQBox({ title, children }) { AutoFlow uses LLM to extract knowledge graph from docs and generate responses to user queries, so the LLM is the core of this RAG app, the Smarter LLM, the better the performance. Currently the online demo(https://tidb.ai) is using OpenAI as chat model by default, and the following LLMs are supported/tested by this RAG app: -- [gpt-4/gpt-4o/gpt-4o-mini/o1/o1-mini](https://platform.openai.com/docs/models) +- [gpt-4/gpt-4.1-2025-04-14/gpt-4.1-2025-04-14-mini/o1/o1-mini](https://platform.openai.com/docs/models) - [gemini-1.5-pro/gemini-2.0-flash](https://gemini.google.com/) - [claude-3.5-sonnet](https://claude.ai/) - [glm-4-plus](https://bigmodel.cn/) diff --git a/frontend/app/public/chats.mock.txt b/frontend/app/public/chats.mock.txt index 408a002db..132f68295 100644 --- a/frontend/app/public/chats.mock.txt +++ b/frontend/app/public/chats.mock.txt @@ -1,5 +1,5 @@ 0:"" -2:[{"chat":{"origin": null,"""updated_at":"2024-07-09T09:55:30","id":"00000000-0000-0000-0000-00000000000","title":"what is tidb?","engine_id":1,"engine_options":"{\"llm\":{\"provider\":\"openai\",\"openai_chat_model\":\"gpt-4o\",\"gemini_chat_model\":\"models/gemini-1.5-flash\",\"reranker_provider\":\"jinaai\",\"reranker_top_k\":10,\"intent_graph_knowledge\":\"Given a list of relationships of a knowledge graph as follows. When there is a conflict in meaning between knowledge relationships, the relationship with the higher `weight` and newer `last_modified_at` value takes precedence.\\n\\nKnowledge sub-queries:\\n\\n{% for sub_query, data in sub_queries.items() %}\\n\\nSub-query: {{ sub_query }}\\n\\n - Entities:\\n\\n{% for entity in data['entities'] %}\\n\\n - Name: {{ entity.name }}\\n - Description: {{ entity.description }}\\n\\n{% endfor %}\\n\\n - Relationships:\\n\\n{% for relationship in data['relationships'] %}\\n\\n - Description: {{ relationship.rag_description }}\\n - Last Modified At: {{ relationship.last_modified_at }}\\n - Meta: {{ relationship.meta | tojson(indent=2) }}\\n\\n{% endfor %}\\n\\n{% endfor %}\\n\",\"normal_graph_knowledge\":\"Given a list of relationships of a knowledge graph as follows. When there is a conflict in meaning between knowledge relationships, the relationship with the higher `weight` and newer `last_modified_at` value takes precedence.\\n\\n---------------------\\nEntities:\\n\\n{% for entity in entities %}\\n\\n- Name: {{ entity.name }}\\n- Description: {{ entity.description }}\\n\\n{% endfor %}\\n\\n---------------------\\n\\nKnowledge relationships:\\n\\n{% for relationship in relationships %}\\n\\n- Description: {{ relationship.rag_description }}\\n- Weight: {{ relationship.weight }}\\n- Last Modified At: {{ relationship.last_modified_at }}\\n- Meta: {{ relationship.meta | tojson(indent=2) }}\\n\\n{% endfor %}\\n\"},\"knowledge_graph\":{\"enabled\":true,\"depth\":2,\"include_meta\":true,\"with_degree\":false,\"using_intent_search\":true}}","user_id":"01907db8-8850-795d-855b-552663c18c9f","created_at":"2024-07-09T09:55:30","deleted_at":null},"user_message":{"id":120007,"created_at":"2024-07-09T09:55:31","role":"user","trace_url":null,"finished_at":null,"user_id":"01907db8-8850-795d-855b-552663c18c9f","updated_at":"2024-07-09T09:55:31","ordinal":1,"content":"what is tidb?","error":null,"sources":[],"chat_id":"00000000-0000-0000-0000-00000000000"},"assistant_message":{"id":120008,"created_at":"2024-07-09T09:55:31","role":"assistant","trace_url":"https://us.cloud.langfuse.com/trace/ccf8aea4-086b-4d72-a7a1-a05ef2e6830a","finished_at":null,"user_id":"01907db8-8850-795d-855b-552663c18c9f","updated_at":"2024-07-09T09:55:31","ordinal":2,"content":"","error":null,"sources":[],"chat_id":"00000000-0000-0000-0000-00000000000"}}] +2:[{"chat":{"origin": null,"""updated_at":"2024-07-09T09:55:30","id":"00000000-0000-0000-0000-00000000000","title":"what is tidb?","engine_id":1,"engine_options":"{\"llm\":{\"provider\":\"openai\",\"openai_chat_model\":\"gpt-4.1-2025-04-14\",\"gemini_chat_model\":\"models/gemini-1.5-flash\",\"reranker_provider\":\"jinaai\",\"reranker_top_k\":10,\"intent_graph_knowledge\":\"Given a list of relationships of a knowledge graph as follows. When there is a conflict in meaning between knowledge relationships, the relationship with the higher `weight` and newer `last_modified_at` value takes precedence.\\n\\nKnowledge sub-queries:\\n\\n{% for sub_query, data in sub_queries.items() %}\\n\\nSub-query: {{ sub_query }}\\n\\n - Entities:\\n\\n{% for entity in data['entities'] %}\\n\\n - Name: {{ entity.name }}\\n - Description: {{ entity.description }}\\n\\n{% endfor %}\\n\\n - Relationships:\\n\\n{% for relationship in data['relationships'] %}\\n\\n - Description: {{ relationship.rag_description }}\\n - Last Modified At: {{ relationship.last_modified_at }}\\n - Meta: {{ relationship.meta | tojson(indent=2) }}\\n\\n{% endfor %}\\n\\n{% endfor %}\\n\",\"normal_graph_knowledge\":\"Given a list of relationships of a knowledge graph as follows. When there is a conflict in meaning between knowledge relationships, the relationship with the higher `weight` and newer `last_modified_at` value takes precedence.\\n\\n---------------------\\nEntities:\\n\\n{% for entity in entities %}\\n\\n- Name: {{ entity.name }}\\n- Description: {{ entity.description }}\\n\\n{% endfor %}\\n\\n---------------------\\n\\nKnowledge relationships:\\n\\n{% for relationship in relationships %}\\n\\n- Description: {{ relationship.rag_description }}\\n- Weight: {{ relationship.weight }}\\n- Last Modified At: {{ relationship.last_modified_at }}\\n- Meta: {{ relationship.meta | tojson(indent=2) }}\\n\\n{% endfor %}\\n\"},\"knowledge_graph\":{\"enabled\":true,\"depth\":2,\"include_meta\":true,\"with_degree\":false,\"using_intent_search\":true}}","user_id":"01907db8-8850-795d-855b-552663c18c9f","created_at":"2024-07-09T09:55:30","deleted_at":null},"user_message":{"id":120007,"created_at":"2024-07-09T09:55:31","role":"user","trace_url":null,"finished_at":null,"user_id":"01907db8-8850-795d-855b-552663c18c9f","updated_at":"2024-07-09T09:55:31","ordinal":1,"content":"what is tidb?","error":null,"sources":[],"chat_id":"00000000-0000-0000-0000-00000000000"},"assistant_message":{"id":120008,"created_at":"2024-07-09T09:55:31","role":"assistant","trace_url":"https://us.cloud.langfuse.com/trace/ccf8aea4-086b-4d72-a7a1-a05ef2e6830a","finished_at":null,"user_id":"01907db8-8850-795d-855b-552663c18c9f","updated_at":"2024-07-09T09:55:31","ordinal":2,"content":"","error":null,"sources":[],"chat_id":"00000000-0000-0000-0000-00000000000"}}] 8:[{"state":"TRACE","display":"Start knowledge graph searching ...","context":{"langfuse_url":"https://us.cloud.langfuse.com/trace/ccf8aea4-086b-4d72-a7a1-a05ef2e6830a"}}] 8:[{"state":"REFINE_QUESTION","display":"Refine the user question ...","context":""}] 8:[{"state":"SEARCH_RELATED_DOCUMENTS","display":"Search related documents ...","context":""}] @@ -1310,4 +1310,4 @@ 0:")" 0:"" 8:[{"state":"FINISHED","display":"","context":""}] -2:[{"chat":{"origin": null,""updated_at":"2024-07-09T09:55:30","id":"00000000-0000-0000-0000-00000000000","title":"what is tidb?","engine_id":1,"engine_options":"{\"llm\":{\"provider\":\"openai\",\"openai_chat_model\":\"gpt-4o\",\"gemini_chat_model\":\"models/gemini-1.5-flash\",\"reranker_provider\":\"jinaai\",\"reranker_top_k\":10,\"intent_graph_knowledge\":\"Given a list of relationships of a knowledge graph as follows. When there is a conflict in meaning between knowledge relationships, the relationship with the higher `weight` and newer `last_modified_at` value takes precedence.\\n\\nKnowledge sub-queries:\\n\\n{% for sub_query, data in sub_queries.items() %}\\n\\nSub-query: {{ sub_query }}\\n\\n - Entities:\\n\\n{% for entity in data['entities'] %}\\n\\n - Name: {{ entity.name }}\\n - Description: {{ entity.description }}\\n\\n{% endfor %}\\n\\n - Relationships:\\n\\n{% for relationship in data['relationships'] %}\\n\\n - Description: {{ relationship.rag_description }}\\n - Last Modified At: {{ relationship.last_modified_at }}\\n - Meta: {{ relationship.meta | tojson(indent=2) }}\\n\\n{% endfor %}\\n\\n{% endfor %}\\n\",\"normal_graph_knowledge\":\"Given a list of relationships of a knowledge graph as follows. When there is a conflict in meaning between knowledge relationships, the relationship with the higher `weight` and newer `last_modified_at` value takes precedence.\\n\\n---------------------\\nEntities:\\n\\n{% for entity in entities %}\\n\\n- Name: {{ entity.name }}\\n- Description: {{ entity.description }}\\n\\n{% endfor %}\\n\\n---------------------\\n\\nKnowledge relationships:\\n\\n{% for relationship in relationships %}\\n\\n- Description: {{ relationship.rag_description }}\\n- Weight: {{ relationship.weight }}\\n- Last Modified At: {{ relationship.last_modified_at }}\\n- Meta: {{ relationship.meta | tojson(indent=2) }}\\n\\n{% endfor %}\\n\"},\"knowledge_graph\":{\"enabled\":true,\"depth\":2,\"include_meta\":true,\"with_degree\":false,\"using_intent_search\":true}}","user_id":"01907db8-8850-795d-855b-552663c18c9f","created_at":"2024-07-09T09:55:30","deleted_at":null},"user_message":{"post_verification_result_url": null,"id":120007,"created_at":"2024-07-09T09:55:31","role":"user","trace_url":null,"finished_at":null,"user_id":"01907db8-8850-795d-855b-552663c18c9f","updated_at":"2024-07-09T09:55:31","ordinal":1,"content":"what is tidb?","error":null,"sources":[],"chat_id":"00000000-0000-0000-0000-00000000000"},"assistant_message":{"post_verification_result_url": null,"id":120008,"created_at":"2024-07-09T09:55:31","role":"assistant","trace_url":"https://us.cloud.langfuse.com/trace/ccf8aea4-086b-4d72-a7a1-a05ef2e6830a","finished_at":"2024-07-09T09:58:07.692084Z","user_id":"01907db8-8850-795d-855b-552663c18c9f","ordinal":2,"content":"### Comprehensive Overview of TiDB\n\n#### What is TiDB?\n\nTiDB is an open-source distributed SQL database designed to support Hybrid Transactional and Analytical Processing (HTAP) workloads. It is MySQL-compatible and features horizontal scalability, strong consistency, and high availability[^1][^2]. TiDB aims to provide a one-stop database solution that covers OLTP (Online Transactional Processing), OLAP (Online Analytical Processing), and HTAP services[^3].\n\n#### Architecture\n\nThe TiDB cluster consists of three main components[^4]:\n\n1. **TiDB Server**: Handles SQL parsing, query planning, and execution.\n2. **TiKV Server**: Acts as the distributed key-value storage engine, storing the actual data.\n3. **PD (Placement Driver) Server**: Manages cluster metadata, allocates timestamps, and handles data placement and load balancing.\n\nAdditionally, TiDB includes other components such as TiFlash for columnar storage, TiSpark for Spark integration, TiDB Binlog for data replication, and TiDB Lightning for high-performance data import[^5].\n\n#### Key Features\n\n1. **Scalability**: TiDB allows for easy horizontal scaling of both computing and storage resources. The architecture separates computing from storage, enabling independent scaling[^6]. This design ensures flexibility and adaptability to changing workloads[^7].\n\n2. **High Availability**: TiDB guarantees strong consistency and availability through its multi-replica architecture and Multi-Raft protocol. Data is stored in multiple replicas, and a transaction can only be committed when data has been successfully written into the majority of replicas[^8]. This ensures data integrity even in the event of failures[^9].\n\n3. **HTAP Capabilities**: TiDB supports both row-based (TiKV) and columnar (TiFlash) storage engines, enabling real-time processing of both transactional and analytical workloads. TiFlash uses the Multi-Raft Learner protocol to replicate data from TiKV in real time, ensuring consistent data across both engines[^10].\n\n4. **Cloud-Native Design**: TiDB is built for cloud environments, offering flexible scalability, reliability, and security on various cloud platforms. It integrates seamlessly with Kubernetes and offers a fully managed service, TiDB Cloud[^11].\n\n5. **MySQL Compatibility**: TiDB is compatible with the MySQL 5.7 protocol and ecosystem, allowing for easy migration of applications with minimal code changes[^12]. However, it does not support certain MySQL features like triggers, stored procedures, user-defined functions, and foreign keys[^13].\n\n#### Distributed Transactions\n\nTiDB supports distributed transactions across the cluster using a two-phase commit protocol with optimizations inspired by Google's Percolator. This model relies on a timestamp allocator to assign monotone increasing timestamps for each transaction, ensuring conflict detection[^14]. The PD server acts as the timestamp allocator in a TiDB cluster[^15].\n\n#### Ease of Use\n\nTiDB is designed to be user-friendly, allowing users to manage it with familiar MySQL tools and replace MySQL in applications without significant code changes[^16]. It supports various programming languages through MySQL clients or drivers[^17].\n\n#### Data Migration Tools\n\nTiDB provides a suite of tools for migrating, replicating, and backing up data. These tools facilitate the transition from MySQL to TiDB, making the migration process straightforward[^18].\n\n### Conclusion\n\nTiDB is a robust, scalable, and highly available distributed SQL database that offers comprehensive support for HTAP workloads. Its compatibility with MySQL, combined with its advanced features and cloud-native design, makes it a versatile choice for various data-intensive applications.\n\n[^1]: [TiDB Overview | PingCAP Docs](https://docs.pingcap.com/tidb/stable/overview)\n[^2]: [TiDB Introduction | PingCAP Docs](https://docs.pingcap.com/tidb/v5.4/overview)\n[^3]: [TiDB Introduction | PingCAP Docs](https://docs.pingcap.com/tidb/v7.1/tidb-faq)\n[^4]: [TiDB Architecture | PingCAP Docs](https://docs.pingcap.com/tidb/v7.1/tidb-architecture)\n[^5]: [TiDB Architecture | PingCAP Docs](https://docs.pingcap.com/tidb/v5.3/tidb-architecture)\n[^6]: [TiDB Key Features | PingCAP Docs](https://docs.pingcap.com/tidb/v7.1/overview)\n[^7]: [TiDB Key Features | PingCAP Docs](https://docs.pingcap.com/tidb/v5.4/overview)\n[^8]: [TiDB High Availability | PingCAP Docs](https://docs.pingcap.com/tidb/v7.1/overview)\n[^9]: [TiDB High Availability | PingCAP Docs](https://docs.pingcap.com/tidb/v5.4/overview)\n[^10]: [TiDB HTAP Capabilities | PingCAP Docs](https://docs.pingcap.com/tidb/v7.1/overview)\n[^11]: [TiDB Cloud-Native Design | PingCAP Docs](https://docs.pingcap.com/tidb/v5.4/overview)\n[^12]: [TiDB MySQL Compatibility | PingCAP Docs](https://docs.pingcap.com/tidb/v7.1/tidb-faq)\n[^13]: [TiDB MySQL Compatibility | PingCAP Docs](https://docs.pingcap.com/tidb/v6.5/tidb-faq)\n[^14]: [TiDB Distributed Transactions | PingCAP Docs](https://docs.pingcap.com/tidb/v7.1/tidb-faq)\n[^15]: [TiDB Distributed Transactions | PingCAP Docs](https://docs.pingcap.com/tidb/v6.5/tidb-faq)\n[^16]: [TiDB Ease of Use | PingCAP Docs](https://docs.pingcap.com/tidb/v7.1/tidb-faq)\n[^17]: [TiDB Programming Language Support | PingCAP Docs](https://docs.pingcap.com/tidb/v7.1/tidb-faq)\n[^18]: [TiDB Data Migration Tools | PingCAP Docs](https://docs.pingcap.com/tidb/v5.3/tidb-architecture)","error":null,"sources":[{"id":8600,"name":"TiDB FAQs","source_uri":"https://docs.pingcap.com/tidb/v7.5/tidb-faq"},{"id":9057,"name":"Overview","source_uri":"https://docs.pingcap.com/tidbcloud/tidb-architecture"},{"id":9373,"name":"TiDB Introduction","source_uri":"https://docs.pingcap.com/tidb/v7.1/overview"},{"id":9865,"name":"Overview","source_uri":"https://docs.pingcap.com/tidb/v7.1/tidb-architecture"},{"id":10191,"name":"TiDB FAQs","source_uri":"https://docs.pingcap.com/tidb/v7.1/tidb-faq"},{"id":11370,"name":"TiDB FAQs","source_uri":"https://docs.pingcap.com/tidb/v6.5/tidb-faq"},{"id":12985,"name":"TiDB Introduction","source_uri":"https://docs.pingcap.com/tidb/v5.4/overview"},{"id":13942,"name":"Overview","source_uri":"https://docs.pingcap.com/tidb/v5.3/tidb-architecture"},{"id":14218,"name":"TiDB FAQs","source_uri":"https://docs.pingcap.com/tidb/v5.3/tidb-faq"}],"chat_id":"00000000-0000-0000-0000-00000000000"}}] +2:[{"chat":{"origin": null,""updated_at":"2024-07-09T09:55:30","id":"00000000-0000-0000-0000-00000000000","title":"what is tidb?","engine_id":1,"engine_options":"{\"llm\":{\"provider\":\"openai\",\"openai_chat_model\":\"gpt-4.1-2025-04-14\",\"gemini_chat_model\":\"models/gemini-1.5-flash\",\"reranker_provider\":\"jinaai\",\"reranker_top_k\":10,\"intent_graph_knowledge\":\"Given a list of relationships of a knowledge graph as follows. When there is a conflict in meaning between knowledge relationships, the relationship with the higher `weight` and newer `last_modified_at` value takes precedence.\\n\\nKnowledge sub-queries:\\n\\n{% for sub_query, data in sub_queries.items() %}\\n\\nSub-query: {{ sub_query }}\\n\\n - Entities:\\n\\n{% for entity in data['entities'] %}\\n\\n - Name: {{ entity.name }}\\n - Description: {{ entity.description }}\\n\\n{% endfor %}\\n\\n - Relationships:\\n\\n{% for relationship in data['relationships'] %}\\n\\n - Description: {{ relationship.rag_description }}\\n - Last Modified At: {{ relationship.last_modified_at }}\\n - Meta: {{ relationship.meta | tojson(indent=2) }}\\n\\n{% endfor %}\\n\\n{% endfor %}\\n\",\"normal_graph_knowledge\":\"Given a list of relationships of a knowledge graph as follows. When there is a conflict in meaning between knowledge relationships, the relationship with the higher `weight` and newer `last_modified_at` value takes precedence.\\n\\n---------------------\\nEntities:\\n\\n{% for entity in entities %}\\n\\n- Name: {{ entity.name }}\\n- Description: {{ entity.description }}\\n\\n{% endfor %}\\n\\n---------------------\\n\\nKnowledge relationships:\\n\\n{% for relationship in relationships %}\\n\\n- Description: {{ relationship.rag_description }}\\n- Weight: {{ relationship.weight }}\\n- Last Modified At: {{ relationship.last_modified_at }}\\n- Meta: {{ relationship.meta | tojson(indent=2) }}\\n\\n{% endfor %}\\n\"},\"knowledge_graph\":{\"enabled\":true,\"depth\":2,\"include_meta\":true,\"with_degree\":false,\"using_intent_search\":true}}","user_id":"01907db8-8850-795d-855b-552663c18c9f","created_at":"2024-07-09T09:55:30","deleted_at":null},"user_message":{"post_verification_result_url": null,"id":120007,"created_at":"2024-07-09T09:55:31","role":"user","trace_url":null,"finished_at":null,"user_id":"01907db8-8850-795d-855b-552663c18c9f","updated_at":"2024-07-09T09:55:31","ordinal":1,"content":"what is tidb?","error":null,"sources":[],"chat_id":"00000000-0000-0000-0000-00000000000"},"assistant_message":{"post_verification_result_url": null,"id":120008,"created_at":"2024-07-09T09:55:31","role":"assistant","trace_url":"https://us.cloud.langfuse.com/trace/ccf8aea4-086b-4d72-a7a1-a05ef2e6830a","finished_at":"2024-07-09T09:58:07.692084Z","user_id":"01907db8-8850-795d-855b-552663c18c9f","ordinal":2,"content":"### Comprehensive Overview of TiDB\n\n#### What is TiDB?\n\nTiDB is an open-source distributed SQL database designed to support Hybrid Transactional and Analytical Processing (HTAP) workloads. It is MySQL-compatible and features horizontal scalability, strong consistency, and high availability[^1][^2]. TiDB aims to provide a one-stop database solution that covers OLTP (Online Transactional Processing), OLAP (Online Analytical Processing), and HTAP services[^3].\n\n#### Architecture\n\nThe TiDB cluster consists of three main components[^4]:\n\n1. **TiDB Server**: Handles SQL parsing, query planning, and execution.\n2. **TiKV Server**: Acts as the distributed key-value storage engine, storing the actual data.\n3. **PD (Placement Driver) Server**: Manages cluster metadata, allocates timestamps, and handles data placement and load balancing.\n\nAdditionally, TiDB includes other components such as TiFlash for columnar storage, TiSpark for Spark integration, TiDB Binlog for data replication, and TiDB Lightning for high-performance data import[^5].\n\n#### Key Features\n\n1. **Scalability**: TiDB allows for easy horizontal scaling of both computing and storage resources. The architecture separates computing from storage, enabling independent scaling[^6]. This design ensures flexibility and adaptability to changing workloads[^7].\n\n2. **High Availability**: TiDB guarantees strong consistency and availability through its multi-replica architecture and Multi-Raft protocol. Data is stored in multiple replicas, and a transaction can only be committed when data has been successfully written into the majority of replicas[^8]. This ensures data integrity even in the event of failures[^9].\n\n3. **HTAP Capabilities**: TiDB supports both row-based (TiKV) and columnar (TiFlash) storage engines, enabling real-time processing of both transactional and analytical workloads. TiFlash uses the Multi-Raft Learner protocol to replicate data from TiKV in real time, ensuring consistent data across both engines[^10].\n\n4. **Cloud-Native Design**: TiDB is built for cloud environments, offering flexible scalability, reliability, and security on various cloud platforms. It integrates seamlessly with Kubernetes and offers a fully managed service, TiDB Cloud[^11].\n\n5. **MySQL Compatibility**: TiDB is compatible with the MySQL 5.7 protocol and ecosystem, allowing for easy migration of applications with minimal code changes[^12]. However, it does not support certain MySQL features like triggers, stored procedures, user-defined functions, and foreign keys[^13].\n\n#### Distributed Transactions\n\nTiDB supports distributed transactions across the cluster using a two-phase commit protocol with optimizations inspired by Google's Percolator. This model relies on a timestamp allocator to assign monotone increasing timestamps for each transaction, ensuring conflict detection[^14]. The PD server acts as the timestamp allocator in a TiDB cluster[^15].\n\n#### Ease of Use\n\nTiDB is designed to be user-friendly, allowing users to manage it with familiar MySQL tools and replace MySQL in applications without significant code changes[^16]. It supports various programming languages through MySQL clients or drivers[^17].\n\n#### Data Migration Tools\n\nTiDB provides a suite of tools for migrating, replicating, and backing up data. These tools facilitate the transition from MySQL to TiDB, making the migration process straightforward[^18].\n\n### Conclusion\n\nTiDB is a robust, scalable, and highly available distributed SQL database that offers comprehensive support for HTAP workloads. Its compatibility with MySQL, combined with its advanced features and cloud-native design, makes it a versatile choice for various data-intensive applications.\n\n[^1]: [TiDB Overview | PingCAP Docs](https://docs.pingcap.com/tidb/stable/overview)\n[^2]: [TiDB Introduction | PingCAP Docs](https://docs.pingcap.com/tidb/v5.4/overview)\n[^3]: [TiDB Introduction | PingCAP Docs](https://docs.pingcap.com/tidb/v7.1/tidb-faq)\n[^4]: [TiDB Architecture | PingCAP Docs](https://docs.pingcap.com/tidb/v7.1/tidb-architecture)\n[^5]: [TiDB Architecture | PingCAP Docs](https://docs.pingcap.com/tidb/v5.3/tidb-architecture)\n[^6]: [TiDB Key Features | PingCAP Docs](https://docs.pingcap.com/tidb/v7.1/overview)\n[^7]: [TiDB Key Features | PingCAP Docs](https://docs.pingcap.com/tidb/v5.4/overview)\n[^8]: [TiDB High Availability | PingCAP Docs](https://docs.pingcap.com/tidb/v7.1/overview)\n[^9]: [TiDB High Availability | PingCAP Docs](https://docs.pingcap.com/tidb/v5.4/overview)\n[^10]: [TiDB HTAP Capabilities | PingCAP Docs](https://docs.pingcap.com/tidb/v7.1/overview)\n[^11]: [TiDB Cloud-Native Design | PingCAP Docs](https://docs.pingcap.com/tidb/v5.4/overview)\n[^12]: [TiDB MySQL Compatibility | PingCAP Docs](https://docs.pingcap.com/tidb/v7.1/tidb-faq)\n[^13]: [TiDB MySQL Compatibility | PingCAP Docs](https://docs.pingcap.com/tidb/v6.5/tidb-faq)\n[^14]: [TiDB Distributed Transactions | PingCAP Docs](https://docs.pingcap.com/tidb/v7.1/tidb-faq)\n[^15]: [TiDB Distributed Transactions | PingCAP Docs](https://docs.pingcap.com/tidb/v6.5/tidb-faq)\n[^16]: [TiDB Ease of Use | PingCAP Docs](https://docs.pingcap.com/tidb/v7.1/tidb-faq)\n[^17]: [TiDB Programming Language Support | PingCAP Docs](https://docs.pingcap.com/tidb/v7.1/tidb-faq)\n[^18]: [TiDB Data Migration Tools | PingCAP Docs](https://docs.pingcap.com/tidb/v5.3/tidb-architecture)","error":null,"sources":[{"id":8600,"name":"TiDB FAQs","source_uri":"https://docs.pingcap.com/tidb/v7.5/tidb-faq"},{"id":9057,"name":"Overview","source_uri":"https://docs.pingcap.com/tidbcloud/tidb-architecture"},{"id":9373,"name":"TiDB Introduction","source_uri":"https://docs.pingcap.com/tidb/v7.1/overview"},{"id":9865,"name":"Overview","source_uri":"https://docs.pingcap.com/tidb/v7.1/tidb-architecture"},{"id":10191,"name":"TiDB FAQs","source_uri":"https://docs.pingcap.com/tidb/v7.1/tidb-faq"},{"id":11370,"name":"TiDB FAQs","source_uri":"https://docs.pingcap.com/tidb/v6.5/tidb-faq"},{"id":12985,"name":"TiDB Introduction","source_uri":"https://docs.pingcap.com/tidb/v5.4/overview"},{"id":13942,"name":"Overview","source_uri":"https://docs.pingcap.com/tidb/v5.3/tidb-architecture"},{"id":14218,"name":"TiDB FAQs","source_uri":"https://docs.pingcap.com/tidb/v5.3/tidb-faq"}],"chat_id":"00000000-0000-0000-0000-00000000000"}}] diff --git a/frontend/app/src/components/chat/chat-stream.state.test.ts b/frontend/app/src/components/chat/chat-stream.state.test.ts index efef95414..4ef993f89 100644 --- a/frontend/app/src/components/chat/chat-stream.state.test.ts +++ b/frontend/app/src/components/chat/chat-stream.state.test.ts @@ -7,7 +7,7 @@ it('pass', () => { 'id': '019091e3-5cfc-74a3-b5e0-653a73f52af2', 'title': 'What is TiDB?', 'engine_id': 1, - 'engine_options': {"llm":{"provider":"openai","openai_chat_model":"gpt-4o","gemini_chat_model":"models/gemini-2.0-flash","reranker_provider":"jinaai","reranker_top_k":10,"intent_graph_knowledge":"Given a list of relationships of a knowledge graph as follows. When there is a conflict in meaning between knowledge relationships, the relationship with the higher `weight` and newer `last_modified_at` value takes precedence.\\n\\nKnowledge sub-queries:\\n\\n{% for sub_query, data in sub_queries.items() %}\\n\\nSub-query: {{ sub_query }}\\n\\n - Entities:\\n\\n{% for entity in data[\'entities\'] %}\\n\\n - Name: {{ entity.name }}\\n - Description: {{ entity.description }}\\n\\n{% endfor %}\\n\\n - Relationships:\\n\\n{% for relationship in data[\'relationships\'] %}\\n\\n - Description: {{ relationship.rag_description }}\\n - Last Modified At: {{ relationship.last_modified_at }}\\n - Meta: {{ relationship.meta | tojson(indent=2) }}\\n\\n{% endfor %}\\n\\n{% endfor %}\\n","normal_graph_knowledge":"Given a list of relationships of a knowledge graph as follows. When there is a conflict in meaning between knowledge relationships, the relationship with the higher `weight` and newer `last_modified_at` value takes precedence.\\n\\n---------------------\\nEntities:\\n\\n{% for entity in entities %}\\n\\n- Name: {{ entity.name }}\\n- Description: {{ entity.description }}\\n\\n{% endfor %}\\n\\n---------------------\\n\\nKnowledge relationships:\\n\\n{% for relationship in relationships %}\\n\\n- Description: {{ relationship.rag_description }}\\n- Weight: {{ relationship.weight }}\\n- Last Modified At: {{ relationship.last_modified_at }}\\n- Meta: {{ relationship.meta | tojson(indent=2) }}\\n\\n{% endfor %}\\n"},"knowledge_graph":{"enabled":true,"depth":2,"include_meta":true,"with_degree":false,"using_intent_search":true}}, + 'engine_options': {"llm":{"provider":"openai","openai_chat_model":"gpt-4.1-2025-04-14","gemini_chat_model":"models/gemini-2.0-flash","reranker_provider":"jinaai","reranker_top_k":10,"intent_graph_knowledge":"Given a list of relationships of a knowledge graph as follows. When there is a conflict in meaning between knowledge relationships, the relationship with the higher `weight` and newer `last_modified_at` value takes precedence.\\n\\nKnowledge sub-queries:\\n\\n{% for sub_query, data in sub_queries.items() %}\\n\\nSub-query: {{ sub_query }}\\n\\n - Entities:\\n\\n{% for entity in data[\'entities\'] %}\\n\\n - Name: {{ entity.name }}\\n - Description: {{ entity.description }}\\n\\n{% endfor %}\\n\\n - Relationships:\\n\\n{% for relationship in data[\'relationships\'] %}\\n\\n - Description: {{ relationship.rag_description }}\\n - Last Modified At: {{ relationship.last_modified_at }}\\n - Meta: {{ relationship.meta | tojson(indent=2) }}\\n\\n{% endfor %}\\n\\n{% endfor %}\\n","normal_graph_knowledge":"Given a list of relationships of a knowledge graph as follows. When there is a conflict in meaning between knowledge relationships, the relationship with the higher `weight` and newer `last_modified_at` value takes precedence.\\n\\n---------------------\\nEntities:\\n\\n{% for entity in entities %}\\n\\n- Name: {{ entity.name }}\\n- Description: {{ entity.description }}\\n\\n{% endfor %}\\n\\n---------------------\\n\\nKnowledge relationships:\\n\\n{% for relationship in relationships %}\\n\\n- Description: {{ relationship.rag_description }}\\n- Weight: {{ relationship.weight }}\\n- Last Modified At: {{ relationship.last_modified_at }}\\n- Meta: {{ relationship.meta | tojson(indent=2) }}\\n\\n{% endfor %}\\n"},"knowledge_graph":{"enabled":true,"depth":2,"include_meta":true,"with_degree":false,"using_intent_search":true}}, 'user_id': null, 'browser_id': null, 'created_at': '2024-07-08T10:28:39',