From eafc19754e4c8e55e2641f95090604f5c4869b4a Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Sat, 24 May 2025 11:55:42 +0000 Subject: [PATCH 1/6] Add GenAI documentation page to Introduction section Co-Authored-By: Francisco Javier Arceo --- docs/genai.md | 175 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 175 insertions(+) create mode 100644 docs/genai.md diff --git a/docs/genai.md b/docs/genai.md new file mode 100644 index 00000000000..2e5508c1ff3 --- /dev/null +++ b/docs/genai.md @@ -0,0 +1,175 @@ +# Feast for Generative AI + +## Overview + +Feast provides robust support for Generative AI applications, enabling teams to build, deploy, and manage feature infrastructure for Large Language Models (LLMs) and other generative AI systems. With Feast's vector database integrations and feature management capabilities, teams can implement production-ready Retrieval Augmented Generation (RAG) systems and other GenAI applications with the same reliability and operational excellence as traditional ML systems. + +## Key Capabilities for GenAI + +### Vector Database Support + +Feast integrates with popular vector databases to store and retrieve embedding vectors efficiently: + +* **Milvus**: Full support for vector similarity search with the `retrieve_online_documents_v2` method +* **SQLite**: Local vector storage and retrieval for development and testing +* **Elasticsearch**: Scalable vector search capabilities +* **Postgres with PGVector**: SQL-based vector operations +* **Qdrant**: Purpose-built vector database integration + +These integrations allow you to: +- Store document embeddings as features +- Perform vector similarity search to find relevant context +- Retrieve both vector embeddings and traditional features in a single API call + +### Retrieval Augmented Generation (RAG) + +Feast simplifies building RAG applications by providing: + +1. **Document embedding storage**: Store and version document embeddings alongside your other features +2. **Vector similarity search**: Find the most relevant documents for a given query +3. **Feature retrieval**: Combine document embeddings with structured features for richer context +4. **Versioning and governance**: Track changes to your document repository over time + +The typical RAG workflow with Feast involves: + +``` +┌─────────────┐ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ +│ Document │ │ Document │ │ Feast │ │ LLM │ +│ Processing │────▶│ Embedding │────▶│ Feature │────▶│ Context │ +│ │ │ │ │ Store │ │ Generation │ +└─────────────┘ └─────────────┘ └─────────────┘ └─────────────┘ +``` + +### Feature Transformation for LLMs + +Feast supports on-demand transformations that can be used to: + +* Process raw text into embeddings +* Chunk documents for more effective retrieval +* Normalize and preprocess features before serving to LLMs + +## Getting Started with Feast for GenAI + +### Installation + +To use Feast with vector database support, install with the appropriate extras: + +```bash +# For Milvus support +pip install feast[milvus,nlp] + +# For Elasticsearch support +pip install feast[elasticsearch] + +# For Qdrant support +pip install feast[qdrant] + +# For SQLite support (Python 3.10 only) +pip install feast[sqlite_vec] +``` + +### Configuration + +Configure your feature store to use a vector database as the online store: + +```yaml +project: genai-project +provider: local +registry: data/registry.db +online_store: + type: milvus + path: data/online_store.db + vector_enabled: true + embedding_dim: 384 # Adjust based on your embedding model + index_type: "IVF_FLAT" + +offline_store: + type: file +entity_key_serialization_version: 3 +``` + +### Defining Vector Features + +Create feature views with vector index support: + +```python +from feast import FeatureView, Field, Entity +from feast.types import Array, Float32, String + +document = Entity( + name="document_id", + description="Document identifier", + join_keys=["document_id"], +) + +document_embeddings = FeatureView( + name="document_embeddings", + entities=[document], + schema=[ + Field( + name="vector", + dtype=Array(Float32), + vector_index=True, # Enable vector search + vector_search_metric="COSINE", # Similarity metric + ), + Field(name="document_id", dtype=String), + Field(name="content", dtype=String), + ], + source=document_source, + ttl=timedelta(days=30), +) +``` + +### Retrieving Similar Documents + +Use the `retrieve_online_documents_v2` method to find similar documents: + +```python +# Generate query embedding +query = "How does Feast support vector databases?" +query_embedding = embed_text(query) # Your embedding function + +# Retrieve similar documents +context_data = store.retrieve_online_documents_v2( + features=[ + "document_embeddings:vector", + "document_embeddings:document_id", + "document_embeddings:content", + ], + query=query_embedding, + top_k=3, + distance_metric='COSINE', +).to_df() +``` + +## Use Cases + +### Document Question-Answering + +Build document Q&A systems by: +1. Storing document chunks and their embeddings in Feast +2. Converting user questions to embeddings +3. Retrieving relevant document chunks +4. Providing these chunks as context to an LLM + +### Knowledge Base Augmentation + +Enhance your LLM's knowledge by: +1. Storing company-specific information as embeddings +2. Retrieving relevant information based on user queries +3. Injecting this information into the LLM's context + +### Semantic Search + +Implement semantic search by: +1. Storing document embeddings in Feast +2. Converting search queries to embeddings +3. Finding semantically similar documents using vector search + +## Learn More + +For more detailed information and examples: + +* [Vector Database Reference](reference/alpha-vector-database.md) +* [RAG Tutorial with Docling](tutorials/rag-with-docling.md) +* [Milvus Quickstart Example](https://github.com/feast-dev/feast/tree/master/examples/rag/milvus-quickstart.ipynb) From 2c4e610859ad0c4bf267c6d92f3e83701a621db1 Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Sat, 24 May 2025 15:23:02 +0000 Subject: [PATCH 2/6] Move GenAI page to getting-started directory and update SUMMARY.md Co-Authored-By: Francisco Javier Arceo --- docs/SUMMARY.md | 2 +- docs/genai.md | 175 ---------------------------------- docs/getting-started/genai.md | 96 +++++++++++++++++++ 3 files changed, 97 insertions(+), 176 deletions(-) delete mode 100644 docs/genai.md diff --git a/docs/SUMMARY.md b/docs/SUMMARY.md index 9861db45f5d..d3bbbfc2239 100644 --- a/docs/SUMMARY.md +++ b/docs/SUMMARY.md @@ -9,7 +9,7 @@ ## Getting started * [Quickstart](getting-started/quickstart.md) -* [GenAI](getting-started/genai.md) +* [Feast for Generative AI](getting-started/genai.md) * [Architecture](getting-started/architecture/README.md) * [Overview](getting-started/architecture/overview.md) * [Language](getting-started/architecture/language.md) diff --git a/docs/genai.md b/docs/genai.md deleted file mode 100644 index 2e5508c1ff3..00000000000 --- a/docs/genai.md +++ /dev/null @@ -1,175 +0,0 @@ -# Feast for Generative AI - -## Overview - -Feast provides robust support for Generative AI applications, enabling teams to build, deploy, and manage feature infrastructure for Large Language Models (LLMs) and other generative AI systems. With Feast's vector database integrations and feature management capabilities, teams can implement production-ready Retrieval Augmented Generation (RAG) systems and other GenAI applications with the same reliability and operational excellence as traditional ML systems. - -## Key Capabilities for GenAI - -### Vector Database Support - -Feast integrates with popular vector databases to store and retrieve embedding vectors efficiently: - -* **Milvus**: Full support for vector similarity search with the `retrieve_online_documents_v2` method -* **SQLite**: Local vector storage and retrieval for development and testing -* **Elasticsearch**: Scalable vector search capabilities -* **Postgres with PGVector**: SQL-based vector operations -* **Qdrant**: Purpose-built vector database integration - -These integrations allow you to: -- Store document embeddings as features -- Perform vector similarity search to find relevant context -- Retrieve both vector embeddings and traditional features in a single API call - -### Retrieval Augmented Generation (RAG) - -Feast simplifies building RAG applications by providing: - -1. **Document embedding storage**: Store and version document embeddings alongside your other features -2. **Vector similarity search**: Find the most relevant documents for a given query -3. **Feature retrieval**: Combine document embeddings with structured features for richer context -4. **Versioning and governance**: Track changes to your document repository over time - -The typical RAG workflow with Feast involves: - -``` -┌─────────────┐ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ -│ Document │ │ Document │ │ Feast │ │ LLM │ -│ Processing │────▶│ Embedding │────▶│ Feature │────▶│ Context │ -│ │ │ │ │ Store │ │ Generation │ -└─────────────┘ └─────────────┘ └─────────────┘ └─────────────┘ -``` - -### Feature Transformation for LLMs - -Feast supports on-demand transformations that can be used to: - -* Process raw text into embeddings -* Chunk documents for more effective retrieval -* Normalize and preprocess features before serving to LLMs - -## Getting Started with Feast for GenAI - -### Installation - -To use Feast with vector database support, install with the appropriate extras: - -```bash -# For Milvus support -pip install feast[milvus,nlp] - -# For Elasticsearch support -pip install feast[elasticsearch] - -# For Qdrant support -pip install feast[qdrant] - -# For SQLite support (Python 3.10 only) -pip install feast[sqlite_vec] -``` - -### Configuration - -Configure your feature store to use a vector database as the online store: - -```yaml -project: genai-project -provider: local -registry: data/registry.db -online_store: - type: milvus - path: data/online_store.db - vector_enabled: true - embedding_dim: 384 # Adjust based on your embedding model - index_type: "IVF_FLAT" - -offline_store: - type: file -entity_key_serialization_version: 3 -``` - -### Defining Vector Features - -Create feature views with vector index support: - -```python -from feast import FeatureView, Field, Entity -from feast.types import Array, Float32, String - -document = Entity( - name="document_id", - description="Document identifier", - join_keys=["document_id"], -) - -document_embeddings = FeatureView( - name="document_embeddings", - entities=[document], - schema=[ - Field( - name="vector", - dtype=Array(Float32), - vector_index=True, # Enable vector search - vector_search_metric="COSINE", # Similarity metric - ), - Field(name="document_id", dtype=String), - Field(name="content", dtype=String), - ], - source=document_source, - ttl=timedelta(days=30), -) -``` - -### Retrieving Similar Documents - -Use the `retrieve_online_documents_v2` method to find similar documents: - -```python -# Generate query embedding -query = "How does Feast support vector databases?" -query_embedding = embed_text(query) # Your embedding function - -# Retrieve similar documents -context_data = store.retrieve_online_documents_v2( - features=[ - "document_embeddings:vector", - "document_embeddings:document_id", - "document_embeddings:content", - ], - query=query_embedding, - top_k=3, - distance_metric='COSINE', -).to_df() -``` - -## Use Cases - -### Document Question-Answering - -Build document Q&A systems by: -1. Storing document chunks and their embeddings in Feast -2. Converting user questions to embeddings -3. Retrieving relevant document chunks -4. Providing these chunks as context to an LLM - -### Knowledge Base Augmentation - -Enhance your LLM's knowledge by: -1. Storing company-specific information as embeddings -2. Retrieving relevant information based on user queries -3. Injecting this information into the LLM's context - -### Semantic Search - -Implement semantic search by: -1. Storing document embeddings in Feast -2. Converting search queries to embeddings -3. Finding semantically similar documents using vector search - -## Learn More - -For more detailed information and examples: - -* [Vector Database Reference](reference/alpha-vector-database.md) -* [RAG Tutorial with Docling](tutorials/rag-with-docling.md) -* [Milvus Quickstart Example](https://github.com/feast-dev/feast/tree/master/examples/rag/milvus-quickstart.ipynb) diff --git a/docs/getting-started/genai.md b/docs/getting-started/genai.md index e6c915f7ff5..c0ffcfaa872 100644 --- a/docs/getting-started/genai.md +++ b/docs/getting-started/genai.md @@ -56,6 +56,7 @@ The transformation workflow typically involves: 3. **Chunking**: Split documents into smaller, semantically meaningful chunks 4. **Embedding Generation**: Convert text chunks into vector embeddings 5. **Storage**: Store embeddings and metadata in Feast's feature store + ### Feature Transformation for LLMs Feast supports transformations that can be used to: @@ -65,6 +66,100 @@ Feast supports transformations that can be used to: * Normalize and preprocess features before serving to LLMs * Apply custom transformations to adapt features for specific LLM requirements +## Getting Started with Feast for GenAI + +### Installation + +To use Feast with vector database support, install with the appropriate extras: + +```bash +# For Milvus support +pip install feast[milvus,nlp] + +# For Elasticsearch support +pip install feast[elasticsearch] + +# For Qdrant support +pip install feast[qdrant] + +# For SQLite support (Python 3.10 only) +pip install feast[sqlite_vec] +``` + +### Configuration + +Configure your feature store to use a vector database as the online store: + +```yaml +project: genai-project +provider: local +registry: data/registry.db +online_store: + type: milvus + path: data/online_store.db + vector_enabled: true + embedding_dim: 384 # Adjust based on your embedding model + index_type: "IVF_FLAT" + +offline_store: + type: file +entity_key_serialization_version: 3 +``` + +### Defining Vector Features + +Create feature views with vector index support: + +```python +from feast import FeatureView, Field, Entity +from feast.types import Array, Float32, String + +document = Entity( + name="document_id", + description="Document identifier", + join_keys=["document_id"], +) + +document_embeddings = FeatureView( + name="document_embeddings", + entities=[document], + schema=[ + Field( + name="vector", + dtype=Array(Float32), + vector_index=True, # Enable vector search + vector_search_metric="COSINE", # Similarity metric + ), + Field(name="document_id", dtype=String), + Field(name="content", dtype=String), + ], + source=document_source, + ttl=timedelta(days=30), +) +``` + +### Retrieving Similar Documents + +Use the `retrieve_online_documents_v2` method to find similar documents: + +```python +# Generate query embedding +query = "How does Feast support vector databases?" +query_embedding = embed_text(query) # Your embedding function + +# Retrieve similar documents +context_data = store.retrieve_online_documents_v2( + features=[ + "document_embeddings:vector", + "document_embeddings:document_id", + "document_embeddings:content", + ], + query=query_embedding, + top_k=3, + distance_metric='COSINE', +).to_df() +``` + ## Use Cases ### Document Question-Answering @@ -103,6 +198,7 @@ This integration enables: - Generating embeddings for millions of text chunks - Efficiently materializing features to vector databases - Scaling RAG applications to enterprise-level document repositories + ## Learn More For more detailed information and examples: From c20f921338dae9328b0aca50f5e002004574486d Mon Sep 17 00:00:00 2001 From: Francisco Arceo Date: Sat, 24 May 2025 09:41:02 -0600 Subject: [PATCH 3/6] Update SUMMARY.md --- docs/SUMMARY.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/SUMMARY.md b/docs/SUMMARY.md index d3bbbfc2239..9861db45f5d 100644 --- a/docs/SUMMARY.md +++ b/docs/SUMMARY.md @@ -9,7 +9,7 @@ ## Getting started * [Quickstart](getting-started/quickstart.md) -* [Feast for Generative AI](getting-started/genai.md) +* [GenAI](getting-started/genai.md) * [Architecture](getting-started/architecture/README.md) * [Overview](getting-started/architecture/overview.md) * [Language](getting-started/architecture/language.md) From 68ae2d0c3210200b821d68a2a729879102c2a818 Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Sat, 24 May 2025 15:46:40 +0000 Subject: [PATCH 4/6] Add unstructured data transformation and Spark integration details to GenAI documentation Co-Authored-By: Francisco Javier Arceo --- docs/getting-started/genai.md | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/docs/getting-started/genai.md b/docs/getting-started/genai.md index c0ffcfaa872..b063966d7bf 100644 --- a/docs/getting-started/genai.md +++ b/docs/getting-started/genai.md @@ -51,12 +51,11 @@ Feast provides powerful capabilities for transforming unstructured data (like PD The transformation workflow typically involves: -1. **Raw Data Ingestion**: Load documents or other data from various sources (file systems, databases, etc.) +1. **Document Ingestion**: Load documents from various sources (file systems, databases, etc.) 2. **Text Extraction**: Extract text content from unstructured documents 3. **Chunking**: Split documents into smaller, semantically meaningful chunks 4. **Embedding Generation**: Convert text chunks into vector embeddings 5. **Storage**: Store embeddings and metadata in Feast's feature store - ### Feature Transformation for LLMs Feast supports transformations that can be used to: @@ -193,12 +192,27 @@ Feast integrates with Apache Spark to enable large-scale processing of unstructu * **Spark Batch Materialization**: Efficiently materialize features from offline to online stores * **Distributed Processing**: Handle gigabytes of documents and millions of embeddings +To use Feast with Spark: + +```python +# Configure Spark in feature_store.yaml +offline_store: + type: spark + spark_conf: + spark.master: "local[*]" + spark.sql.session.timeZone: "UTC" + +# Use Spark for batch materialization +batch_engine: + type: spark.engine + partitions: 10 # Adjust based on your data size +``` + This integration enables: - Processing large document collections in parallel - Generating embeddings for millions of text chunks - Efficiently materializing features to vector databases - Scaling RAG applications to enterprise-level document repositories - ## Learn More For more detailed information and examples: From 308c5d13bf4989170de41e50f26b19421839b742 Mon Sep 17 00:00:00 2001 From: Francisco Arceo Date: Tue, 27 May 2025 08:30:31 -0400 Subject: [PATCH 5/6] Update genai.md --- docs/getting-started/genai.md | 112 +--------------------------------- 1 file changed, 1 insertion(+), 111 deletions(-) diff --git a/docs/getting-started/genai.md b/docs/getting-started/genai.md index b063966d7bf..e6c915f7ff5 100644 --- a/docs/getting-started/genai.md +++ b/docs/getting-started/genai.md @@ -51,7 +51,7 @@ Feast provides powerful capabilities for transforming unstructured data (like PD The transformation workflow typically involves: -1. **Document Ingestion**: Load documents from various sources (file systems, databases, etc.) +1. **Raw Data Ingestion**: Load documents or other data from various sources (file systems, databases, etc.) 2. **Text Extraction**: Extract text content from unstructured documents 3. **Chunking**: Split documents into smaller, semantically meaningful chunks 4. **Embedding Generation**: Convert text chunks into vector embeddings @@ -65,100 +65,6 @@ Feast supports transformations that can be used to: * Normalize and preprocess features before serving to LLMs * Apply custom transformations to adapt features for specific LLM requirements -## Getting Started with Feast for GenAI - -### Installation - -To use Feast with vector database support, install with the appropriate extras: - -```bash -# For Milvus support -pip install feast[milvus,nlp] - -# For Elasticsearch support -pip install feast[elasticsearch] - -# For Qdrant support -pip install feast[qdrant] - -# For SQLite support (Python 3.10 only) -pip install feast[sqlite_vec] -``` - -### Configuration - -Configure your feature store to use a vector database as the online store: - -```yaml -project: genai-project -provider: local -registry: data/registry.db -online_store: - type: milvus - path: data/online_store.db - vector_enabled: true - embedding_dim: 384 # Adjust based on your embedding model - index_type: "IVF_FLAT" - -offline_store: - type: file -entity_key_serialization_version: 3 -``` - -### Defining Vector Features - -Create feature views with vector index support: - -```python -from feast import FeatureView, Field, Entity -from feast.types import Array, Float32, String - -document = Entity( - name="document_id", - description="Document identifier", - join_keys=["document_id"], -) - -document_embeddings = FeatureView( - name="document_embeddings", - entities=[document], - schema=[ - Field( - name="vector", - dtype=Array(Float32), - vector_index=True, # Enable vector search - vector_search_metric="COSINE", # Similarity metric - ), - Field(name="document_id", dtype=String), - Field(name="content", dtype=String), - ], - source=document_source, - ttl=timedelta(days=30), -) -``` - -### Retrieving Similar Documents - -Use the `retrieve_online_documents_v2` method to find similar documents: - -```python -# Generate query embedding -query = "How does Feast support vector databases?" -query_embedding = embed_text(query) # Your embedding function - -# Retrieve similar documents -context_data = store.retrieve_online_documents_v2( - features=[ - "document_embeddings:vector", - "document_embeddings:document_id", - "document_embeddings:content", - ], - query=query_embedding, - top_k=3, - distance_metric='COSINE', -).to_df() -``` - ## Use Cases ### Document Question-Answering @@ -192,22 +98,6 @@ Feast integrates with Apache Spark to enable large-scale processing of unstructu * **Spark Batch Materialization**: Efficiently materialize features from offline to online stores * **Distributed Processing**: Handle gigabytes of documents and millions of embeddings -To use Feast with Spark: - -```python -# Configure Spark in feature_store.yaml -offline_store: - type: spark - spark_conf: - spark.master: "local[*]" - spark.sql.session.timeZone: "UTC" - -# Use Spark for batch materialization -batch_engine: - type: spark.engine - partitions: 10 # Adjust based on your data size -``` - This integration enables: - Processing large document collections in parallel - Generating embeddings for millions of text chunks From 7f6a33c0ccc614e3bc78d8c79c89a4c9ccba5032 Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Mon, 2 Jun 2025 20:27:52 +0000 Subject: [PATCH 6/6] feat: Add CURL Generator tab to Feature View pages - Add new CURL Generator tab that generates pre-populated CURL commands for /get-online-features endpoint - Configurable feature selection with checkboxes (all selected by default) - Features organized in rows of exactly 5 for better readability - Entity input fields with customizable comma-separated values - Configurable server URL with localStorage persistence across feature views - Copy to clipboard functionality for generated CURL commands - Real-time updates when feature selection, entity values, or server URL change - Follows existing UI patterns using Elastic UI components Co-Authored-By: Francisco Javier Arceo --- ui/src/FeastUISansProviders.tsx | 27 +- ui/src/custom-tabs/TabsRegistryContext.tsx | 1 + .../pages/feature-views/CurlGeneratorTab.tsx | 278 ++++++++++++++++++ 3 files changed, 305 insertions(+), 1 deletion(-) create mode 100644 ui/src/pages/feature-views/CurlGeneratorTab.tsx diff --git a/ui/src/FeastUISansProviders.tsx b/ui/src/FeastUISansProviders.tsx index 2c00a985c09..9a2207e22dd 100644 --- a/ui/src/FeastUISansProviders.tsx +++ b/ui/src/FeastUISansProviders.tsx @@ -30,6 +30,7 @@ import NoProjectGuard from "./components/NoProjectGuard"; import TabsRegistryContext, { FeastTabsRegistryInterface, } from "./custom-tabs/TabsRegistryContext"; +import CurlGeneratorTab from "./pages/feature-views/CurlGeneratorTab"; import FeatureFlagsContext, { FeatureFlags, } from "./contexts/FeatureFlagsContext"; @@ -98,7 +99,31 @@ const FeastUISansProvidersInner = ({ { + const data = feastObjectQuery.data as any; + const [serverUrl, setServerUrl] = useState(() => { + const savedUrl = localStorage.getItem("feast-feature-server-url"); + return savedUrl || "http://localhost:6566"; + }); + const [entityValues, setEntityValues] = useState>({}); + const [selectedFeatures, setSelectedFeatures] = useState< + Record + >({}); + + useEffect(() => { + localStorage.setItem("feast-feature-server-url", serverUrl); + }, [serverUrl]); + + if (feastObjectQuery.isLoading) { + return Loading...; + } + + if (feastObjectQuery.isError || !data) { + return Error loading feature view data.; + } + + const generateFeatureNames = () => { + if (!data?.name || !data?.features) return []; + + return data.features + .filter((feature: any) => selectedFeatures[feature.name] !== false) + .map((feature: any) => `${data.name}:${feature.name}`); + }; + + const generateEntityObject = () => { + if (!data?.object?.spec?.entities) return {}; + + const entities: Record = {}; + data.object.spec.entities.forEach((entityName: string) => { + const userValue = entityValues[entityName]; + if (userValue) { + const values = userValue.split(",").map((v) => { + const num = parseInt(v.trim()); + return isNaN(num) ? 1001 : num; + }); + entities[entityName] = values; + } else { + entities[entityName] = [1001, 1002, 1003]; + } + }); + return entities; + }; + + const generateCurlCommand = () => { + const features = generateFeatureNames(); + const entities = generateEntityObject(); + + const payload = { + features, + entities, + }; + + const curlCommand = `curl -X POST \\ + "${serverUrl}/get-online-features" \\ + -H "Content-Type: application/json" \\ + -d '${JSON.stringify(payload, null, 2)}'`; + + return curlCommand; + }; + + const curlCommand = generateCurlCommand(); + + return ( + + + +

Feature Server CURL Generator

+
+ + +

+ Generate a CURL command to fetch online features from the feature + server. The command is pre-populated with all features and entities + from this feature view. +

+
+ + + + setServerUrl(e.target.value)} + placeholder="http://localhost:6566" + /> + + + + + {data?.features && data.features.length > 0 && ( + <> + + + +

+ Features to Include ( + { + Object.values(selectedFeatures).filter((v) => v !== false) + .length + } + /{data.features.length}) +

+
+
+ + + + { + const allSelected: Record = {}; + data.features.forEach((feature: any) => { + allSelected[feature.name] = true; + }); + setSelectedFeatures(allSelected); + }} + > + Select All + + + + { + const noneSelected: Record = {}; + data.features.forEach((feature: any) => { + noneSelected[feature.name] = false; + }); + setSelectedFeatures(noneSelected); + }} + > + Select None + + + + +
+ + + {Array.from( + { length: Math.ceil(data.features.length / 5) }, + (_, rowIndex) => ( + + {data.features + .slice(rowIndex * 5, (rowIndex + 1) * 5) + .map((feature: any) => ( + + + setSelectedFeatures((prev) => ({ + ...prev, + [feature.name]: e.target.checked, + })) + } + /> + + ))} + + ), + )} + + + + )} + + {data?.object?.spec?.entities && + data.object.spec.entities.length > 0 && ( + <> + +

Entity Values (comma-separated)

+
+ + {data.object.spec.entities.map((entityName: string) => ( + + + setEntityValues((prev) => ({ + ...prev, + [entityName]: e.target.value, + })) + } + placeholder="1001, 1002, 1003" + /> + + ))} + + + )} + + + + +

Generated CURL Command

+
+
+ + + {(copy) => ( + + Copy to Clipboard + + )} + + +
+ + + + + + + + +

+ Features included:{" "} + {generateFeatureNames().join(", ")} +

+ {data?.object?.spec?.entities && ( +

+ Entities: {data.object.spec.entities.join(", ")} +

+ )} +
+
+
+ ); +}; + +export default CurlGeneratorTab;