### Update Example App Index and Run Source: https://github.com/devflowinc/trieve/blob/main/clients/trieve-fumadocs-adapter/README.md Updates the index for the example Fumadocs application after linking the adapter and then starts the development server. ```sh clients/trieve-fumadocs-adapter/example $ npm run build clients/trieve-fumadocs-adapter/example $ npm run dev ``` -------------------------------- ### Link Trieve Fumadocs Adapter to Example App Source: https://github.com/devflowinc/trieve/blob/main/clients/trieve-fumadocs-adapter/README.md Links the Trieve Fumadocs adapter package into a local example Fumadocs application for development and testing. ```sh clients/trieve-fumadocs-adapter $ npm link clients/trieve-fumadocs-adapter/example $ npm link trieve-fumadocs-adapter ``` -------------------------------- ### Setup Environment Variables Source: https://github.com/devflowinc/trieve/blob/main/README.md Copies example environment files to their respective frontend and server directories. ```bash cp .env.analytics ./frontends/analytics/.env cp .env.chat ./frontends/chat/.env cp .env.search ./frontends/search/.env cp .env.example ./server/.env cp .env.dashboard ./frontends/dashboard/.env ``` -------------------------------- ### Environment File Preparation Source: https://github.com/devflowinc/trieve/blob/main/website/src/content/blog-posts/trieve-self-hosting-on-vps/index.mdx Copies the example environment file to a new file and modifies a specific configuration for the hostname. ```bash su - trieve -c "cd trieve && cp .env.example .env" sed -i 's/KC_HOSTNAME="localhost"/KC_HOSTNAME=""/' /home/trieve/trieve/.env ``` -------------------------------- ### Shopify App Template - Remix Setup Source: https://github.com/devflowinc/trieve/blob/main/clients/trieve-shopify-extension/README.md This section outlines the initial setup steps for the Shopify App Template using Remix, including prerequisites like Node.js and a Shopify Partner Account, and the installation command. ```shell # Install dependencies yarn install # Link Shopify app configuration yarn shopify app config link # Run local development server yarn dev ``` -------------------------------- ### Install Trieve MCP Server Source: https://github.com/devflowinc/trieve/blob/main/clients/mcp-server/README.md Provides instructions for installing the trieve-mcp-server using both Smithery for automatic client setup and npm for manual installation. ```bash npx -y @smithery/cli install trieve-mcp-server --client claude ``` ```bash npm install trieve-mcp-server ``` -------------------------------- ### Starting Search Development Server Source: https://github.com/devflowinc/trieve/blob/main/README.md Navigates to the 'search' directory, installs dependencies using Yarn, and starts the development server. This is used for running the search-related components of Trieve locally. ```bash cd search yarn yarn dev ``` -------------------------------- ### Trieve MCP Server Development Setup Source: https://github.com/devflowinc/trieve/blob/main/clients/mcp-server/README.md Provides the necessary steps for setting up the development environment for trieve-mcp-server, including cloning the repository, installing dependencies, configuring credentials, and building the project. ```bash npm install ``` ```bash npm run build ``` -------------------------------- ### Local n8n Node Setup Source: https://github.com/devflowinc/trieve/blob/main/clients/n8n-nodes-trieve/README.md Provides instructions for setting up the n8n-nodes-trieve project for local development. This includes installing n8n globally, running it for the first time, and linking the custom node directory. ```bash npm install n8n -g npm run build mkdir ~/.n8n/custom/ ln -s "$(pwd)/n8n-nodes-trieve" ~/.n8n/custom/n8n-nodes-trieve ``` -------------------------------- ### Start Trieve Docker Containers Source: https://github.com/devflowinc/trieve/blob/main/website/src/content/blog-posts/trieve-self-hosting-on-vps/index.mdx Starts the Trieve services defined in the 'docker-compose.yml' file in detached mode, forcing a recreation of containers if they already exist. ```bash docker compose up -d --force-recreate ``` -------------------------------- ### Start Docusaurus Development Server Source: https://github.com/devflowinc/trieve/blob/main/clients/docusaurus-theme-search/example/docs/intro.md Navigates to the website directory and starts the local development server for Docusaurus. ```bash cd my-website npm run start ``` -------------------------------- ### Development: Running Example Application Source: https://github.com/devflowinc/trieve/blob/main/clients/search-component/README.md Commands to navigate to the example application directory and run its development server. ```sh $clients/search-component cd example/ $clients/search-component yarn $clients/search-component yarn dev ``` -------------------------------- ### Install Trieve Python Client via Setuptools Source: https://github.com/devflowinc/trieve/blob/main/clients/python-sdk/README.md Installs the Trieve Python client using the setup.py script, a traditional method for Python package installation. This allows for local installation or installation for all users. ```sh python setup.py install --user (or `sudo python setup.py install` to install the package for all users) ``` -------------------------------- ### Run Example Docusaurus Application Source: https://github.com/devflowinc/trieve/blob/main/clients/docusaurus-theme-search/README.md Starts an example Docusaurus application that utilizes the Trieve search theme. A restart may be required for theme updates to take effect. ```sh clients/docusaurus-theme-search/example $ npm run start ``` -------------------------------- ### Trieve Self-Hosting Setup and Configuration Source: https://github.com/devflowinc/trieve/blob/main/scripts/README.md Scripts for setting up and configuring a self-hosted Trieve instance. setup-self-hosting.sh installs dependencies like jq, git, caddy, curl, and gawk, and sets up Caddy and Docker. configure-self-hosting.sh detects GPU and system resources, configures Docker Compose, generates a Caddyfile, modifies environment files, and sets up Keycloak realm. ```bash #!/bin/bash # Example placeholder for setup-self-hosting.sh echo "Setting up Trieve self-hosting..." # Install jq, git, caddy, curl, gawk sudo apt-get update && sudo apt-get install -y jq git caddy curl gawk # Add Caddy GPG key and repository # ... (actual commands would go here) # Check and install Docker # ... (actual commands would go here) echo "Setup complete." ``` ```bash #!/bin/bash # Example placeholder for configure-self-hosting.sh # Function to check GPU and resources check_gpu_and_resources() { echo "Checking GPU and system resources..." # Logic to detect GPU architecture and resources # Determine Docker Compose configuration based on capabilities } # Function to check CPU and RAM check_cpu_and_ram() { echo "Checking CPU and RAM..." # Logic to check CPU cores and RAM # Decide on CPU-based embeddings } # Caddyfile Generation generate_caddyfile() { local domain=$1 echo "Generating Caddyfile for domain: $domain" # Create Caddyfile content } # Environment File Configuration configure_env_file() { echo "Configuring .env file..." # Modify .env file with appropriate values } # Docker Compose File Modification modify_docker_compose() { echo "Modifying docker-compose.yml..." # Update docker-compose.yml } # Keycloak Realm Configuration configure_keycloak_realm() { echo "Configuring Keycloak realm..." # Modify realm-export.json } # Main execution flow if [ -z "$DOMAIN" ]; then read -p "Enter your domain name: " DOMAIN fi check_gpu_and_resources check_cpu_and_ram generate_caddyfile "$DOMAIN" configure_env_file modify_docker_compose configure_keycloak_realm # Ensure Caddy service is enabled, started, and reloaded sudo systemctl enable caddy sudo systemctl start caddy sudo systemctl reload caddy echo "Trieve configuration complete." ``` ```bash # Usage Example: # ./setup-self-hosting.sh # DOMAIN=yourdomain.com ./configure-self-hosting.sh ``` -------------------------------- ### CI Setup (GitHub Actions Workflow) Source: https://github.com/devflowinc/trieve/blob/main/clients/trieve-vitepress-adapter/README.md A GitHub Actions workflow to automate the update of Trieve chunks. It checks out the repository, installs the adapter, and runs the adapter with environment variables sourced from repository secrets. ```yml name: Update Trieve concurrency: group: ${{ github.workflow }}-${{ github.head_ref }} cancel-in-progress: true on: push: branches: - main jobs: run: runs-on: ubuntu-latest steps: - name: Checkout repository uses: actions/checkout@v4 - name: Install Trieve Vitepress Adapter run: npm install -g trieve-vitepress-adapter - name: Update Trieve Chunks env: TRIEVE_API_HOST: ${{ secrets.TRIEVE_API_HOST }} TRIEVE_API_KEY: ${{ secrets.TRIEVE_API_KEY }} TRIEVE_ORGANIZATION_ID: ${{ secrets.TRIEVE_ORGANIZATION_ID }} TRIEVE_DATASET_TRACKING_ID: ${{ secrets.TRIEVE_DATASET_TRACKING_ID }} run: trieve-vitepress-adapter --file -s -r -a ``` -------------------------------- ### Running Trieve Application Source: https://github.com/devflowinc/trieve/blob/main/website/src/content/blog-posts/trieve-self-hosting-on-vps/index.mdx Starts the Trieve application using Docker Compose, ensuring all services are running in detached mode. It also provides a command to monitor the application logs in real-time. ```bash docker compose -f docker-compose-cpu-embeddings.yml up -d docker compose up -d docker compose logs -f ``` -------------------------------- ### Trieve Website Installation Source: https://github.com/devflowinc/trieve/blob/main/clients/docusaurus-theme-search/example/README.md Installs the necessary project dependencies for the Trieve website using Yarn. ```bash yarn ``` -------------------------------- ### Trieve Docker Compose Execution Source: https://github.com/devflowinc/trieve/blob/main/website/src/content/blog-posts/trieve-self-hosting-on-vps/index.mdx Starts the Trieve application using Docker Compose, first with CPU embeddings and then with the main compose file. Includes a short delay and then stops the containers. ```bash su - trieve -c "cd trieve && docker compose -f docker-compose-cpu-embeddings.yml up -d && sleep 3 && docker compose down" ``` -------------------------------- ### Install Trieve SDK Source: https://github.com/devflowinc/trieve/blob/main/clients/ts-sdk/README.md Instructions for installing the Trieve Typescript SDK using yarn, npm, or pnpm. ```bash yarn add trieve-ts-sdk # or npm install trieve-ts-sdk # or pnpm install trieve-ts-sdk ``` -------------------------------- ### SuggestedQueriesReqPayload Example Source: https://github.com/devflowinc/trieve/blob/main/clients/python-sdk/docs/SuggestedQueriesReqPayload.md Example of how to create and use the SuggestedQueriesReqPayload model in Python, including conversion from JSON and to a dictionary. ```python from trieve_py_client.models.suggested_queries_req_payload import SuggestedQueriesReqPayload # TODO update the JSON string below json = "{}" # create an instance of SuggestedQueriesReqPayload from a JSON string suggested_queries_req_payload_instance = SuggestedQueriesReqPayload.from_json(json) # print the JSON string representation of the object print(SuggestedQueriesReqPayload.to_json()) # convert the object into a dict suggested_queries_req_payload_dict = suggested_queries_req_payload_instance.to_dict() # create an instance of SuggestedQueriesReqPayload from a dict suggested_queries_req_payload_form_dict = suggested_queries_req_payload.from_dict(suggested_queries_req_payload_dict) ``` -------------------------------- ### Get RAG Analytics Example Source: https://github.com/devflowinc/trieve/blob/main/clients/python-sdk/docs/AnalyticsApi.md Python example demonstrating how to retrieve RAG analytics for a dataset using the Trieve client library. It includes setup, authentication, and placeholder for analytics data. ```python import trieve_py_client from trieve_py_client.models.rag_analytics import RAGAnalytics from trieve_py_client.models.rag_analytics_response import RAGAnalyticsResponse from trieve_py_client.rest import ApiException from pprint import pprint import os # Defining the host is optional and defaults to https://api.trieve.ai # See configuration.py for a list of all supported configuration parameters. configuration = trieve_py_client.Configuration( host = "https://api.trieve.ai" ) # The client must configure the authentication and authorization parameters # in accordance with the API server security policy. # Examples for each auth method are provided below, use the example that # satisfies your auth use case. # Configure API key authorization: ApiKey configuration.api_key['ApiKey'] = os.environ["API_KEY"] # Uncomment below to setup prefix (e.g. Bearer) for API key, if needed # configuration.api_key_prefix['ApiKey'] = 'Bearer' # Enter a context with an instance of the API client with trieve_py_client.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = trieve_py_client.AnalyticsApi(api_client) tr_dataset = 'tr_dataset_example' # str | The dataset id or tracking_id to use for the request. We assume you intend to use an id if the value is a valid uuid. rag_analytics = RAGAnalytics() # RAGAnalytics | The RAG analytics to use for the request. try: # Get RAG Analytics api_response = api_instance.get_rag_analytics(tr_dataset, rag_analytics) print("The response of AnalyticsApi->get_rag_analytics:\n") pprint(api_response) except Exception as e: print("Exception when calling AnalyticsApi->get_rag_analytics: %s\n" % e) ``` -------------------------------- ### Install Trieve Fumadocs Dependencies Source: https://github.com/devflowinc/trieve/blob/main/clients/trieve-fumadocs-adapter/README.md Installs the necessary Trieve packages for Fumadocs integration. Requires npm. ```sh npm install trieve-fumadocs-adapter trieve-ts-sdk ``` -------------------------------- ### Get User Event By ID Example Source: https://github.com/devflowinc/trieve/blob/main/clients/python-sdk/docs/AnalyticsApi.md Python example demonstrating how to retrieve a user event by its ID using the Trieve client library. It includes configuration, authentication, and error handling. ```python import trieve_py_client from trieve_py_client.models.event_data import EventData from trieve_py_client.rest import ApiException from pprint import pprint import os # Defining the host is optional and defaults to https://api.trieve.ai # See configuration.py for a list of all supported configuration parameters. configuration = trieve_py_client.Configuration( host = "https://api.trieve.ai" ) # The client must configure the authentication and authorization parameters # in accordance with the API server security policy. # Examples for each auth method are provided below, use the example that # satisfies your auth use case. # Configure API key authorization: ApiKey configuration.api_key['ApiKey'] = os.environ["API_KEY"] # Uncomment below to setup prefix (e.g. Bearer) for API key, if needed # configuration.api_key_prefix['ApiKey'] = 'Bearer' # Enter a context with an instance of the API client with trieve_py_client.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = trieve_py_client.AnalyticsApi(api_client) tr_dataset = 'tr_dataset_example' # str | The dataset id or tracking_id to use for the request. We assume you intend to use an id if the value is a valid uuid. event_id = 'event_id_example' # str | The event id to use for the request try: # Get User Event By ID api_response = api_instance.get_event_by_id(tr_dataset, event_id) print("The response of AnalyticsApi->get_event_by_id:\n") pprint(api_response) except Exception as e: print("Exception when calling AnalyticsApi->get_event_by_id: %s\n" % e) ``` -------------------------------- ### Initializing a Bun Project Source: https://github.com/devflowinc/trieve/blob/main/website/src/content/blog-posts/building-search-for-yc-company-directory/index.mdx This command initializes a new Bun project, setting up the basic directory structure and configuration files required to start a new application using the Bun runtime. ```bash bun init ``` -------------------------------- ### Python Example for GetAllTagsResponse Source: https://github.com/devflowinc/trieve/blob/main/clients/python-sdk/docs/GetAllTagsResponse.md Demonstrates how to use the GetAllTagsResponse model in Python, including creating an instance from a JSON string, converting it to a dictionary, and creating an instance from a dictionary. This example assumes the `trieve_py_client` library is installed. ```python from trieve_py_client.models.get_all_tags_response import GetAllTagsResponse # TODO update the JSON string below json_string = "{}" # create an instance of GetAllTagsResponse from a JSON string get_all_tags_response_instance = GetAllTagsResponse.from_json(json_string) # print the JSON string representation of the object print(GetAllTagsResponse.to_json()) # convert the object into a dict get_all_tags_response_dict = get_all_tags_response_instance.to_dict() # create an instance of GetAllTagsResponse from a dict get_all_tags_response_form_dict = GetAllTagsResponse.from_dict(get_all_tags_response_dict) ``` -------------------------------- ### Serve Production Build Locally Source: https://github.com/devflowinc/trieve/blob/main/clients/docusaurus-theme-search/example/docs/tutorial-basics/deploy-your-site.md Tests the production build locally by serving the 'build' folder. The site will be available at http://localhost:3000/. ```bash npm run serve ``` -------------------------------- ### Stripe CLI Setup for Webhooks and Product Creation Source: https://github.com/devflowinc/trieve/blob/main/README.md Provides commands for setting up the Stripe CLI locally. This includes logging in, forwarding webhooks to a local server, setting the webhook secret, and creating a Stripe product and plan for Trieve. ```bash stripe login stripe listen --forward-to localhost:8090/api/stripe/webhook # Set the STRIPE_WEBHOOK_SECRET in the server/.env file stripe products create --name trieve --default-price-data.unit-amount 1200 --default-price-data.currency usd stripe plans create --amount=1200 --currency=usd --interval=month --product={id from response of step 3} ``` -------------------------------- ### Python Client for Trieve Get Recommended Chunks Source: https://github.com/devflowinc/trieve/blob/main/clients/python-sdk/docs/ChunkApi.md Example of how to use the Trieve Python client to get recommended chunks. This includes setting up the client, authentication, and making the API call. ```python import trieve_py_client from trieve_py_client.models.recommend_chunks_request import RecommendChunksRequest from trieve_py_client.models.recommend_response_types import RecommendResponseTypes from trieve_py_client.rest import ApiException from pprint import pprint import os # Defining the host is optional and defaults to https://api.trieve.ai # See configuration.py for a list of all supported configuration parameters. configuration = trieve_py_client.Configuration( host = "https://api.trieve.ai" ) # The client must configure the authentication and authorization parameters # in accordance with the API server security policy. # Examples for each auth method are provided below, use the example that # satisfies your auth use case. # Configure API key authorization: ApiKey configuration.api_key['ApiKey'] = os.environ["API_KEY"] # Uncomment below to setup prefix (e.g. Bearer) for API key, if needed # configuration.api_key_prefix['ApiKey'] = 'Bearer' # Enter a context with an instance of the API client with trieve_py_client.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = trieve_py_client.ChunkApi(api_client) tr_dataset = 'tr_dataset_example' # str | The dataset id or tracking_id to use for the request. We assume you intend to use an id if the value is a valid uuid. recommend_chunks_request = trieve_py_client.RecommendChunksRequest() # RecommendChunksRequest | JSON request payload to get recommendations of chunks similar to the chunks in the request x_api_version = trieve_py_client.APIVersion() # APIVersion | The API version to use for this request. Defaults to V2 for orgs created after July 12, 2024 and V1 otherwise. (optional) try: # Get Recommended Chunks api_response = api_instance.get_recommended_chunks(tr_dataset, recommend_chunks_request, x_api_version=x_api_version) print("The response of ChunkApi->get_recommended_chunks:\n") pprint(api_response) except Exception as e: print("Exception when calling ChunkApi->get_recommended_chunks: %s\n" % e) ``` -------------------------------- ### Delete Topic Example Source: https://github.com/devflowinc/trieve/blob/main/clients/python-sdk/docs/TopicApi.md Illustrates how to delete a chat topic using the Trieve Python client. This example covers API key authentication setup and the correct usage of the delete_topic method with dataset and topic IDs. ```python import trieve_py_client from trieve_py_client.rest import ApiException from pprint import pprint import os configuration = trieve_py_client.Configuration( host = "https://api.trieve.ai" ) configuration.api_key['ApiKey'] = os.environ["API_KEY"] with trieve_py_client.ApiClient(configuration) as api_client: api_instance = trieve_py_client.TopicApi(api_client) tr_dataset = 'tr_dataset_example' topic_id = 'topic_id_example' try: api_instance.delete_topic(tr_dataset, topic_id) except Exception as e: print("Exception when calling TopicApi->delete_topic: %s\n" % e) ``` -------------------------------- ### Generate New Docusaurus Site Source: https://github.com/devflowinc/trieve/blob/main/clients/docusaurus-theme-search/example/docs/intro.md Creates a new Docusaurus site using the classic template and installs necessary dependencies. ```bash npm init docusaurus@latest my-website classic ``` -------------------------------- ### Navigate to Trieve Directory Source: https://github.com/devflowinc/trieve/blob/main/website/src/content/blog-posts/trieve-self-hosting-on-vps/index.mdx Changes the current working directory to the Trieve installation directory, typically '/home/trieve/trieve'. ```bash cd /home/trieve/trieve ``` -------------------------------- ### Monitoring Cloud-init Logs Source: https://github.com/devflowinc/trieve/blob/main/website/src/content/blog-posts/trieve-self-hosting-on-vps/index.mdx Connects to the server via SSH and displays real-time logs from the systemd journal, useful for monitoring the cloud-init initialization process. ```bash sudo -s journalctl -f ``` -------------------------------- ### Clean Trieve Docker Environment Source: https://github.com/devflowinc/trieve/blob/main/website/src/content/blog-posts/trieve-self-hosting-on-vps/index.mdx Removes all Trieve-related Docker containers, networks, and volumes, effectively cleaning the environment before a fresh start. ```bash make clean ``` -------------------------------- ### Starting Docker Services and Convenience Script Source: https://github.com/devflowinc/trieve/blob/main/README.md This command concatenates environment files and then executes a convenience script. This is typically used to set up the necessary environment for local development services. ```bash cat .env.chat .env.search .env.server .env.docker-compose > .env ./convenience.sh -l ``` -------------------------------- ### Example: Upload PDF and Ask Questions Source: https://github.com/devflowinc/trieve/blob/main/clients/cli/README.md Demonstrates uploading a PDF file, checking its processing status, and then asking a question about its content using the Trieve CLI. ```bash # Upload a document trieve upload ./documents/report.pdf # Check if processing is complete trieve check-upload-status # Ask a question about the content trieve ask "What are the key findings in the report?" ``` -------------------------------- ### Install Trieve via Smithery Source: https://github.com/devflowinc/trieve/blob/main/README.md Installs Trieve for Claude Desktop automatically using the Smithery CLI. ```bash npx -y @smithery/cli install trieve-mcp-server --client claude ``` -------------------------------- ### Create Topic Example Source: https://github.com/devflowinc/trieve/blob/main/clients/python-sdk/docs/TopicApi.md Demonstrates how to create a new chat topic using the Trieve Python client. It shows the setup for API key authentication and the process of instantiating the client and calling the create_topic method. ```python import trieve_py_client from trieve_py_client.rest import ApiException from pprint import pprint import os configuration = trieve_py_client.Configuration( host = "https://api.trieve.ai" ) configuration.api_key['ApiKey'] = os.environ["API_KEY"] with trieve_py_client.ApiClient(configuration) as api_client: api_instance = trieve_py_client.TopicApi(api_client) tr_dataset = 'tr_dataset_example' create_topic_req_payload = trieve_py_client.CreateTopicReqPayload() try: api_response = api_instance.create_topic(tr_dataset, create_topic_req_payload) print("The response of TopicApi->create_topic:\n") pprint(api_response) except Exception as e: print("Exception when calling TopicApi->create_topic: %s\n" % e) ``` -------------------------------- ### Run Development Server Source: https://github.com/devflowinc/trieve/blob/main/clients/trieve-fumadocs-adapter/example/README.md Commands to start the development server for the Trieve project. These commands can be executed using npm, pnpm, or yarn. ```bash npm run dev # or pnpm dev # or yarn dev ``` -------------------------------- ### Python Example: Get Dataset by ID Source: https://github.com/devflowinc/trieve/blob/main/clients/python-sdk/docs/DatasetApi.md Demonstrates how to use the Trieve Python client to retrieve a dataset by its ID. This includes setting up the client configuration, authenticating with an API key, and handling potential API exceptions. ```python import trieve_py_client from trieve_py_client.models.dataset import Dataset from trieve_py_client.rest import ApiException from pprint import pprint import os configuration = trieve_py_client.Configuration( host = "https://api.trieve.ai" ) configuration.api_key['ApiKey'] = os.environ["API_KEY"] with trieve_py_client.ApiClient(configuration) as api_client: api_instance = trieve_py_client.DatasetApi(api_client) tr_dataset = 'tr_dataset_example' dataset_id = 'dataset_id_example' try: api_response = api_instance.get_dataset(tr_dataset, dataset_id) print("The response of DatasetApi->get_dataset:\n") pprint(api_response) except Exception as e: print("Exception when calling DatasetApi->get_dataset: %s\n" % e) ``` -------------------------------- ### Product Recommendation UI Setup Source: https://github.com/devflowinc/trieve/blob/main/server/src/public/product.html This snippet demonstrates the process of fetching product recommendations based on a search query and updating the UI. It includes making a POST request to the '/api/chunk_group/group_oriented_search' endpoint and handling the response to replace loading states with product information. ```javascript const recs = document.querySelector(".recs"); recs.querySelectorAll(":scope > div:not(.rec)").forEach((div) => { recs.replaceChild(recDivs.pop(), div); }); try { if (window.paramsData.singleProductOptions.recSearchQuery) { const recommendations = await fetch( `${window.paramsData.baseUrl}/api/chunk_group/group_oriented_search`, { method: "POST", headers: { "Content-Type": "application/json", Authorization: "Bearer " + window.paramsData.apiKey, "TR-Dataset": window.paramsData.datasetId, }, body: JSON.stringify({ query: window.paramsData.singleProductOptions.recSearchQuery, use_quote_negated_terms: true, search_type: "semantic", group_size: 1, page_size: 15, }), credentials: "omit", } ); const recommendationsData = await recommendations.json(); replaceLoadingStateProducts(recommendationsData.results); setRecProductEventListeners(); } } catch (e) { console.error("Error setting up recommendations on demo page", e); } ``` -------------------------------- ### Get Public Page - Python Source: https://github.com/devflowinc/trieve/blob/main/clients/python-sdk/docs/PublicApi.md Demonstrates how to use the `public_page` method from the Trieve Python client to retrieve a public dataset page. It includes setup for the API client, calling the method, and basic error handling. ```python import trieve_py_client from trieve_py_client.rest import ApiException from pprint import pprint configuration = trieve_py_client.Configuration( host = "https://api.trieve.ai" ) with trieve_py_client.ApiClient(configuration) as api_client: api_instance = trieve_py_client.PublicApi(api_client) dataset_id = 'dataset_id_example' try: api_instance.public_page(dataset_id) except Exception as e: print("Exception when calling PublicApi->public_page: %s\n" % e) ``` -------------------------------- ### Get Chunks By Tracking IDs Source: https://github.com/devflowinc/trieve/blob/main/clients/python-sdk/docs/ChunkApi.md Retrieves chunks using their tracking IDs. This function is similar to `get_chunks_by_ids` but specifically targets chunks identified by tracking IDs. It includes setup, API call, and error handling. ```python import trieve_py_client from trieve_py_client.models.chunk_return_types import ChunkReturnTypes from trieve_py_client.models.get_tracking_chunks_data import GetTrackingChunksData from trieve_py_client.rest import ApiException from pprint import pprint configuration = trieve_py_client.Configuration( host = "https://api.trieve.ai" ) configuration.api_key['ApiKey'] = os.environ["API_KEY"] with trieve_py_client.ApiClient(configuration) as api_client: api_instance = trieve_py_client.ChunkApi(api_client) tr_dataset = 'tr_dataset_example' get_tracking_chunks_data = trieve_py_client.GetTrackingChunksData() x_api_version = trieve_py_client.APIVersion() try: api_response = api_instance.get_chunks_by_tracking_ids(tr_dataset, get_tracking_chunks_data, x_api_version=x_api_version) print("The response of ChunkApi->get_chunks_by_tracking_ids:\n") pprint(api_response) except Exception as e: print("Exception when calling ChunkApi->get_chunks_by_tracking_ids: %s\n" % e) ```