### Initialize Next.js Project and Install Core Dependencies Source: https://docs.peaka.com/api-reference/blogs/rag-example-with-api Guides through the initial setup of a Next.js application, including global installation of `create-next-app`, project generation, and installation of essential AI/SDK libraries for integration with Peaka, OpenAI, and other services. This ensures all necessary tools and packages are available for development. ```bash npm install -g create-next-app npx create-next-app@latest ``` ```bash npm i @ai-sdk/openai @ai-sdk/react @nlux/react @nlux/themes @peaka/client @upstash/vector ai langchain lodash zod ``` -------------------------------- ### Next.js Application Setup and Dependency Installation Source: https://docs.peaka.com/api-reference/blogs Commands to globally install `create-next-app`, initialize a new Next.js project, install required AI/SDK libraries for integration with OpenAI, Peaka, and other services, and finally, a command to run the development server. ```shell npm install -g create-next-app npx create-next-app@latest ``` ```shell npm i @ai-sdk/openai @ai-sdk/react @nlux/react @nlux/themes @peaka/client @upstash/vector ai langchain lodash zod ``` ```shell npm run dev ``` -------------------------------- ### cURL Example for GET List Queries Source: https://docs.peaka.com/api-reference/api-reference/data-queries/list-queries An example cURL command demonstrating how to make a GET request to the List Queries API endpoint, including the necessary authorization header with a placeholder token. ```cURL curl --request GET \ --url https://partner.peaka.studio/api/v1/data/projects/{projectId}/queries \ --header 'Authorization: Bearer ' ``` -------------------------------- ### Get Project Metadata API Reference and Examples Source: https://docs.peaka.com/api-reference/api-reference/data-metadata/get-project-metadata Detailed API documentation for retrieving project metadata, including authentication requirements, path and query parameters, expected response format, and an example cURL command. ```APIDOC Endpoint: GET /metadata/{projectId} Base URLs: https://partner.peaka.studio/api/v1 https://partner.eu.peaka.studio/api/v1 Authorizations: Authorization: Type: Bearer authentication Location: header Required: true Description: Bearer authentication header of the form `Bearer `, where `` is your auth token. Path Parameters: projectId: Type: string Required: true Query Parameters: catalogId: Type: string Required: false schemaName: Type: string Required: false Response: 200 - */*: Status: OK Description: The response is of type `object`. ``` ```cURL curl --request GET \ --url https://partner.peaka.studio/api/v1/metadata/{projectId} \ --header 'Authorization: Bearer ' ``` -------------------------------- ### Configure Environment Variables for API Keys Source: https://docs.peaka.com/api-reference/blogs/rag-example-with-api Instructions for creating a `.env` file to securely store sensitive API keys for Peaka, OpenAI, and Pinecone. It also specifies the required Pinecone index configuration, including dimension and metric, which are crucial for successful API interactions. ```bash PEAKA_API_KEY= OPENAI_API_KEY= PINECONE_API_KEY= PINECONE_INDEX= ``` -------------------------------- ### Example: Get Connection Configuration using cURL Source: https://docs.peaka.com/api-reference/api-reference/connections/get-connection-config Illustrates how to query the connection configuration API using a cURL command. This example includes the necessary Authorization header for authentication. ```curl curl --request GET \ --url https://partner.peaka.studio/api/v1/connections/config/{connectionType} \ --header 'Authorization: Bearer ' ``` -------------------------------- ### Example Peaka SQL Alchemy URI for Apache Preset Source: https://docs.peaka.com/api-reference/bi-tools/preset This snippet demonstrates a concrete example of the SQL Alchemy URI, showing how to connect to the 'stripe' catalog and 'payment' schema using a placeholder API key 'abc'. This helps users understand how to fill in the dynamic parts of the URI for their specific Peaka setup. ```Trino SQL trino://dbc.peaka.studio:4567/stripe/payment?http_scheme=https&extra_credential=[["peakaKey","abc"]]&access_token=true ``` -------------------------------- ### TypeScript Peaka Service Class Implementation Source: https://docs.peaka.com/api-reference/blogs/rag-example-with-api The complete TypeScript implementation of the `PeakaService` class, which acts as an interface to the Peaka API. It includes a singleton pattern for managing the connection, a method to fetch all SpaceX launch data, and a method to perform vector-based searches, demonstrating how to integrate with external data sources and AI capabilities. ```typescript export class PeakaService { private connection: Peaka; private constructor() { this.connection = connectToPeaka(process.env.PEAKA_API_KEY ?? ""); } static #instance: PeakaService; public static get instance(): PeakaService { if (!PeakaService.#instance) { PeakaService.#instance = new PeakaService(); } return PeakaService.#instance; } public async getAllSpacexLaunches(): Promise { const iter = await this.connection.query( 'SELECT id, name, links_article FROM "spacex"."public"."launches"' ); const launches: SpacexLaunchInfo[] = []; const data: QueryData[] = await iter .map((r) => r.data ?? []) .fold([], (row, acc) => [...acc, ...row]); for (const queryData of data) { const launch: SpacexLaunchInfo = { id: queryData[0], name: queryData[1], links_article: queryData[2] }; launches.push(launch); } return launches; } public async vectorSearch( vectors: number[], topK: number ): Promise { const iter = await this.connection.query( VECTOR_LAUNCHES_VECTOR_SEARCH_SQL_TEMPLATE({ vectors, topK }) ); const data: QueryData[] = await iter .map((r) => r.data ?? []) .fold([], (row, acc) => [...acc, ...row]); return data; } } ``` -------------------------------- ### List Project API Keys Endpoint Documentation and Examples Source: https://docs.peaka.com/api-reference/api-reference/projects-api-key/list-api-keys Comprehensive documentation for the GET /projects/{projectId}/apiKeys endpoint, including authorization requirements, path parameters, and an example cURL request with its corresponding JSON response structure. ```APIDOC GET /projects/{projectId}/apiKeys Authorizations: Authorization: string (header, required) Bearer authentication header of the form `Bearer `, where `` is your auth token. Path Parameters: projectId: string (required) Project ID Response: 200 - */* OK Type: object[] Example: [ { "name": "", "apiKey": "", "apiKeyId": "3c90c3cc-0d44-4b50-8888-8dd25736052a" } ] ``` ```cURL curl --request GET \\ --url https://partner.peaka.studio/api/v1/projects/{projectId}/apiKeys \\ --header 'Authorization: Bearer ' ``` ```JSON [ { "name": "", "apiKey": "", "apiKeyId": "3c90c3cc-0d44-4b50-8888-8dd25736052a" } ] ``` -------------------------------- ### SQL Query for All SpaceX Launches Source: https://docs.peaka.com/api-reference/blogs/rag-example-with-api A simple SQL query designed to retrieve basic information about SpaceX launches. It selects the `id`, `name`, and `links_article` columns from the `spacex.public.launches` table, providing a foundational dataset for further processing. ```sql SELECT id, name, links_article FROM "spacex"."public"."launches" ``` -------------------------------- ### Example JSON Response for Project Details API Source: https://docs.peaka.com/api-reference/api-reference/organization-projects/read-project An example of the JSON object returned by the 'Get Project' API endpoint, containing various project attributes such as ID, name, description, domain, webhook base URL, creation timestamp, and workspace ID. ```JSON { "id": "SksnYuxH", "name": "Anapp23334", "description": null, "domain": "anapp2-rfto", "webhookBaseUrl": "https://anapp2-rfto--test.api.peaka.host", "createdAt": "2023-08-21T11:09:04.699714310Z", "workspaceId": "d7f282d2-b392-4b5c-8cea-05f7523df2d2" } ``` -------------------------------- ### Make Tableau Start Script Executable (Mac) Source: https://docs.peaka.com/api-reference/bi-tools/tableau Grants execute permissions to the 'tableau.sh' script on macOS, allowing it to be run as a program. ```Bash chmod +x ``` -------------------------------- ### Populate Pinecone Vector Database with SpaceX Launch Data Source: https://docs.peaka.com/api-reference/blogs/rag-example-with-api This TypeScript code defines a Next.js API endpoint (`GET`) that populates a Pinecone vector database. It first clears the existing index, then fetches SpaceX launch data, extracts article content using `RecursiveUrlLoader`, splits the content into chunks, and finally embeds and stores these documents in Pinecone. It leverages Langchain for document loading, splitting, and Pinecone integration, along with OpenAIEmbeddings. ```typescript export const dynamic = "force-dynamic"; import { PeakaService } from "@/service/peaka.service"; import { Pinecone } from "@pinecone-database/pinecone"; import { NextResponse } from "next/server"; import { RecursiveUrlLoader } from "@langchain/community/document_loaders/web/recursive_url"; import { compile } from "html-to-text"; import { PineconeStore } from "@langchain/pinecone"; import { Document } from "@langchain/core/documents"; import { OpenAIEmbeddings } from "@langchain/openai"; import { RecursiveCharacterTextSplitter } from "langchain/text_splitter"; export async function GET() { const pc = new Pinecone({ apiKey: process.env.PINECONE_API_KEY!, }); const pineconeIndex = pc.index(process.env.PINECONE_INDEX!); try { await pineconeIndex.deleteAll(); } catch (e) { console.log("Could not delete index"); } const peakaService = PeakaService.instance; const launches = await peakaService.getAllSpacexLaunches(); const compiledConvert = compile({ wordwrap: 130 }); // returns (text: string) => string; const splitter = new RecursiveCharacterTextSplitter({}); const docs: Document[] = []; for (const launch of launches) { const url = launch.links_article; if (url) { const loader = new RecursiveUrlLoader(url, { extractor: compiledConvert, maxDepth: 0, }); const urlDocs = await loader.load(); if (urlDocs.length === 0) continue; const output = await splitter.createDocuments([urlDocs[0].pageContent]); for (const text of output) { docs.push( new Document({ metadata: { id: launch.id, name: launch.name, link: launch.links_article, }, pageContent: text.pageContent, }) ); } } } await PineconeStore.fromDocuments(docs, new OpenAIEmbeddings(), { pineconeIndex, maxConcurrency: 5, }); return NextResponse.json({ success: true }); } ``` -------------------------------- ### List Tables API cURL Example Source: https://docs.peaka.com/api-reference/api-reference/data-internal-tables/list-tables Example cURL command to call the List Tables API endpoint, demonstrating how to construct the GET request with the necessary authorization header for authentication. ```cURL curl --request GET \ --url https://partner.peaka.studio/api/v1/data/projects/{projectId}/table \ --header 'Authorization: Bearer ' ``` -------------------------------- ### Create Tableau Shell Script Directory (Mac) Source: https://docs.peaka.com/api-reference/bi-tools/tableau Creates a directory named 'tableau.sh' on macOS. This directory is intended to hold the Tableau start script. ```Bash mkdir tableau.sh ``` -------------------------------- ### Run Tableau Start Script (Mac) Source: https://docs.peaka.com/api-reference/bi-tools/tableau Executes the 'tableau.sh' script on macOS to launch Tableau Desktop with the specified configuration, including disabled connector signature verification. ```Bash sh tableau.sh ``` -------------------------------- ### Example Response: List of Workspaces Source: https://docs.peaka.com/api-reference/api-reference/organization-workspaces/list-workspaces A sample JSON array representing the successful response from the 'Get Workspaces' API call. Each object in the array details a single workspace, including its ID, name, creator, organization ID, description, creation timestamp, and default status. ```JSON [ { "id": "3c90c3cc-0d44-4b50-8888-8dd25736052a", "name": "", "createdBy": "3c90c3cc-0d44-4b50-8888-8dd25736052a", "organizationId": "3c90c3cc-0d44-4b50-8888-8dd25736052a", "description": "", "createdAt": "", "defaultWorkspace": true } ] ``` -------------------------------- ### Get JDBC Driver JSON Response Example Source: https://docs.peaka.com/api-reference/api-reference/supported-drivers/get-jdbc-driver Example JSON response body for the Get JDBC Driver API call. ```json "{\n \"JDBC\": \"jdbc:peaka://dbc.peaka.studio:4567/?extraCredentials=peakaKey:gk4aUnCO.IYxkP1NxP67YkVViqYGZe3INpUAr04TE\",\n}\ " ``` -------------------------------- ### cURL Example: Get Project Catalog Metadata Relations Source: https://docs.peaka.com/api-reference/api-reference/data-metadata/get-project-catalog-metadata-relations Example cURL command to fetch catalog metadata relations for a given project and catalog ID, requiring a Bearer token for authorization. The command demonstrates how to construct the GET request. ```cURL curl --request GET \ --url https://partner.peaka.studio/api/v1/metadata/{projectId}/relations/{catalogId} \ --header 'Authorization: Bearer ' ``` -------------------------------- ### Peaka API Documentation Overview Source: https://docs.peaka.com/api-reference/api-reference/embedded-peaka-api/init-session Provides an introduction to the Peaka API, covering general topics like server configurations and authentication methods. ```APIDOC API Documentation: Introduction Servers Authentication ``` -------------------------------- ### Configure Tableau Start Script for Mac Source: https://docs.peaka.com/api-reference/bi-tools/tableau Defines a Bash script to launch Tableau Desktop on macOS, disabling signature verification for connector plugins. Users must replace '' with their specific Tableau Desktop version. ```Bash #!/bin/bash "/Applications/Tableau Desktop .app/Contents/MacOS/Tableau" -DDisableVerifyConnectorPluginSignature=true ``` -------------------------------- ### SQL USE Command Examples Source: https://docs.peaka.com/api-reference/sql/reference/use Illustrates practical usage of the USE command with specific catalog and schema names to update the current session context. ```SQL USE hive.finance; USE information_schema; ``` -------------------------------- ### Example: Get Workspace Details using cURL Source: https://docs.peaka.com/api-reference/api-reference/organization-workspaces/read-workspace Provides a cURL command example to demonstrate how to make a GET request to retrieve workspace information. An authorization bearer token is required for authentication. ```curl curl --request GET \ --url https://partner.peaka.studio/api/v1/organizations/{organizationId}/workspaces/{workspaceId} \ --header 'Authorization: Bearer ' ``` -------------------------------- ### API Documentation Introduction Source: https://docs.peaka.com/api-reference/api-reference/data-catalogs/read-catalog Provides an introduction to the Peaka API, including information on servers and authentication. ```APIDOC Introduction: /api-reference/introduction Servers: /api-reference/servers Authentication: /api-reference/authentication ``` -------------------------------- ### Peaka API Documentation Introduction Source: https://docs.peaka.com/api-reference/api-reference/data-internal-tables/create-bi-table An introductory section to the Peaka API, outlining general concepts such as server configurations and authentication methods. ```APIDOC API Documentation: Introduction Servers Authentication ``` -------------------------------- ### Configure OpenAI Chatbot Prompt and Parameters Source: https://docs.peaka.com/api-reference/blogs/rag-example-with-api This TypeScript code defines configuration for an OpenAI chatbot. It includes a Lodash template (`SPACEX_CHATBOT_INSTRUCTION`) for the system prompt, designed to incorporate context and user queries. It also sets standard OpenAI model parameters (`SPACEX_CHATBOT_PARAMS`) such as temperature, model name, and max tokens for the chatbot. ```typescript export const SPACEX_CHATBOT_INSTRUCTION = _.template(` You are a helpful chatbot which answers questions about given context. --------------------- <%= context %> --------------------- Given the context information and not prior knowledge, answer the query. Query: <%= query %> Answer: `); export const SPACEX_CHATBOT_PARAMS = { temperature: 0, modelName: "gpt-4o", max_tokens: 2000, }; ``` -------------------------------- ### Peaka API Documentation Overview Source: https://docs.peaka.com/api-reference/api-reference/organization-workspaces/list-workspaces An introductory section listing general API documentation topics such as authentication, servers, and the overall API reference structure. ```APIDOC API Documentation: Introduction Servers Authentication ``` -------------------------------- ### Get JDBC Driver cURL Example Source: https://docs.peaka.com/api-reference/api-reference/supported-drivers/get-jdbc-driver Example cURL command to retrieve the JDBC driver URL. ```curl curl --request GET \ --url https://partner.peaka.studio/api/v1/supportedDrivers/jdbc \ --header 'Authorization: Bearer ' ``` -------------------------------- ### Peaka API: General Documentation Sections Source: https://docs.peaka.com/api-reference/api-reference/data-queries/execute-query Links to introductory sections of the Peaka API documentation, including general introduction, server configurations, and authentication methods. ```APIDOC General API Documentation: Introduction: /api-reference/introduction Servers: /api-reference/servers Authentication: /api-reference/authentication ``` -------------------------------- ### Examples of Quantified Comparison Predicates Source: https://docs.peaka.com/api-reference/sql/functions/comparison Provides practical SQL examples demonstrating the usage of `ANY`, `ALL`, and `SOME` quantifiers with comparison operators. These examples illustrate how to compare a single value against a set of values returned by a subquery or value list. ```SQL SELECT 'hello' = ANY (VALUES 'hello', 'world'); -- true SELECT 21 < ALL (VALUES 19, 20, 21); -- false SELECT 42 >= SOME (SELECT 41 UNION ALL SELECT 42 UNION ALL SELECT 43); -- true ``` -------------------------------- ### SQL SHOW CATALOGS Command Syntax and Example Source: https://docs.peaka.com/api-reference/sql/reference/show-catalogs Provides the general syntax for the SQL SHOW CATALOGS command, which lists available catalogs in Peaka. It also includes an example demonstrating how to use the optional LIKE clause to filter catalogs based on a pattern. ```SQL SHOW CATALOGS [ LIKE pattern ] ``` ```SQL SHOW CATALOGS LIKE 't%' ``` -------------------------------- ### Get Array Length (JavaScript) Source: https://docs.peaka.com/api-reference/jexl/built-in-functions Provides an example of using the `len` function to get the number of elements in an array. ```JavaScript len([1, 2, 3, 4, 5, 6]); // => 6 ``` -------------------------------- ### Peaka Partner API Introduction and Key Features Source: https://docs.peaka.com/api-reference/api-reference This section provides an introduction to the Peaka Partner API, outlining its purpose as a gateway for integrating Peaka's features, and detailing its key functionalities such as secure authentication, robust functionality, real-time data access, customizable integration, scalability, and dedicated support. ```APIDOC # Introduction API endpoints ## Overview The Peaka Partner API is a powerful gateway designed for our partners to seamlessly integrate Peaka’s features into their own applications and services. With secure access provided through a unique API key, partners can leverage the full potential of Peaka’s capabilities to enhance their user experience and streamline operations. ## Key Features * Secure Authentication: Access the API with confidence using the apiKey provided by Peaka, ensuring secure and authorized interactions. * Robust Functionality: Utilize a wide range of functions, from data retrieval to executing complex operations, all tailored to meet the diverse needs of our partners. * Real-Time Data Access: Retrieve up-to-the-minute information to keep your services synchronized with the latest developments within Peaka. * Customizable Integration: Tailor the API’s extensive features to fit your platform’s specific requirements, providing a personalized experience for your users. * Scalability: Designed to handle requests at scale, the Peaka Partner API can accommodate growing traffic as your business expands. * Dedicated Support: Benefit from Peaka’s commitment to partnership success with dedicated support for API integration and usage. ``` -------------------------------- ### SQL LIKE Operator: Matching Start of String Source: https://docs.peaka.com/api-reference/sql/functions/comparison Demonstrates using the LIKE operator with the '%' wildcard to find strings that start with a specific character. This example retrieves continents starting with 'E'. ```SQL SELECT * FROM (VALUES 'America', 'Asia', 'Africa', 'Europe', 'Australia', 'Antarctica') AS t (continent) WHERE continent LIKE 'E%'; ``` -------------------------------- ### Get AI Chat History using cURL Source: https://docs.peaka.com/api-reference/api-reference/ai-agent/get-ai-chat-history Example cURL command to fetch AI chat history. It demonstrates how to use the GET method and include the Bearer token for authorization. ```curl curl --request GET \ --url https://partner.peaka.studio/api/v1/ai/{projectId}/agent/history \ --header 'Authorization: Bearer ' ``` -------------------------------- ### Peaka API Documentation Overview Source: https://docs.peaka.com/api-reference/api-reference/projects-api-key/create-api-key This section provides an overview of the Peaka API documentation structure, including introductory topics, server information, and authentication methods. ```APIDOC API Documentation: - Introduction - Servers - Authentication ``` -------------------------------- ### Peaka API: Supported Drivers 200 OK Response Source: https://docs.peaka.com/api-reference/api-reference/supported-drivers/get-sql-alchemy-driver Documents the successful 200 OK response for the supported drivers endpoint, detailing the expected output format and content, including an example JSON structure for a specific driver. ```APIDOC HTTP Status: 200 OK Content-Type: */* Description: URL for given driver Response Type: string (direct URL) or JSON object for specific drivers Example JSON Response for SQL_ALCHEMY driver with Catalog provided: { "SQL_ALCHEMY": "peaka://dbc.peaka.studio:4567/sampleCatalog?http_scheme=https&extra_credential=[["peakaKey","gk4aUnCO.IYxkP1NxP67YkVViqYGZe3INpUAr04TE"]]&access_token=true" } ``` -------------------------------- ### Peaka API Documentation Overview Source: https://docs.peaka.com/api-reference/api-reference/supported-drivers/get-jdbc-driver Provides an introduction to the Peaka API, including general information about servers and authentication methods required for API access. ```APIDOC API Documentation: - Introduction - Servers - Authentication ``` -------------------------------- ### API Reference and Examples: Get Connection by ID Source: https://docs.peaka.com/api-reference/api-reference/connections/get-connection Comprehensive documentation for the 'Get Connection by ID' API endpoint, including its method, path parameters, authorization requirements, and expected JSON response. This snippet also provides a practical cURL command example for direct usage. ```APIDOC Endpoint: GET https://partner.peaka.studio/api/v1/connections/{projectId}/{connectionId} Authorization: Type: Bearer authentication header Format: Bearer Required: Yes Path Parameters: projectId: Type: string Description: ID of the project Required: Yes connectionId: Type: string Description: ID of the connection Required: Yes Response (200 - application/json): Description: Get Connection by ID Type: object Example: { "id": "8db17e23-29de-4dab-8886-af9717e0e742", "name": "airtable2", "type": "airtable" } ``` ```cURL curl --request GET \ --url https://partner.peaka.studio/api/v1/connections/{projectId}/{connectionId} \ --header 'Authorization: Bearer ' ``` ```JSON { "id": "8db17e23-29de-4dab-8886-af9717e0e742", "name": "airtable2", "type": "airtable" } ``` -------------------------------- ### Get Connection Detail using cURL Source: https://docs.peaka.com/api-reference/api-reference/connections/get-connection-detail Example cURL command to retrieve connection details from the Peaka API, requiring an authorization token. ```curl curl --request GET \ --url https://partner.peaka.studio/api/v1/connections/{projectId}/{connectionId}/detail \ --header 'Authorization: Bearer ' ``` -------------------------------- ### Create Catalog-Stored SQL Routine Source: https://docs.peaka.com/api-reference/sql/routines/examples Shows how to create and store a SQL function in a specified catalog and schema (`example.default`) using `CREATE FUNCTION`, making it reusable across multiple queries without redefinition. ```SQL USE example.default; CREATE FUNCTION example.default.answer() RETURNS BIGINT RETURN 42; ``` -------------------------------- ### Successful Response for Get SQL Alchemy Driver API Source: https://docs.peaka.com/api-reference/api-reference/supported-drivers/get-sql-alchemy-driver Example JSON response body for a successful call to the Get SQL Alchemy Driver API. It illustrates the structure and content of the SQL_ALCHEMY driver details returned by the API. ```JSON { "SQL_ALCHEMY": "peaka://dbc.peaka.studio:4567/sampleCatalog?http_scheme=https&extra_credential=[["peakaKey","gk4aUnCO.IYxkP1NxP67YkVViqYGZe3INpUAr04TE"]]&access_token=true" } ``` -------------------------------- ### Implement Basic Chatbot UI with NLUX and React Source: https://docs.peaka.com/api-reference/blogs/rag-example-with-api This code snippet demonstrates how to create a basic chatbot UI using the `@nlux/react` library in a Next.js application. It defines a `ChatAdapter` to handle streaming text from a `/api/chat` POST endpoint, managing the communication between the frontend and backend. The `AiChat` component is configured with display options, a custom persona, and predefined conversation starters, providing a functional and interactive chat interface. ```TypeScript "use client"; import "@nlux/themes/nova.css"; import { AiChat, AiChatUI, ChatAdapter, StreamingAdapterObserver, } from "@nlux/react"; export default function Chat() { const chatAdapter: ChatAdapter = { streamText: async (prompt: string, observer: StreamingAdapterObserver) => { const response = await fetch("/api/chat", { method: "POST", body: JSON.stringify({ prompt: prompt }), headers: { "Content-Type": "application/json" }, }); if (response.status !== 200) { observer.error(new Error("Failed to connect to the server")); return; } if (!response.body) { return; } // Read a stream of server-sent events // and feed them to the observer as they are being generated const reader = response.body.getReader(); const textDecoder = new TextDecoder(); while (true) { const { value, done } = await reader.read(); if (done) { break; } const content = textDecoder.decode(value); if (content) { observer.next(content); } } observer.complete(); }, }; return (
Hello! 👋
This is a rag pipeline is implemented with Peaka. The data is fetched from SpaceX public API's by using Peaka's Rest Table and uses Peaka's Pinecone connector to search for information in vector database using sql. Then the results are sent to OpenAI to generate the response.
Try by clicking sample prompts or get to the full code from{" "} Github
); } ``` -------------------------------- ### SQL EXECUTE Example: With Parameters Source: https://docs.peaka.com/api-reference/sql/reference/execute Illustrates how to prepare a SQL `SELECT` statement containing placeholders for parameters and then execute it by providing specific values for these parameters using the `USING` clause. An equivalent direct `SELECT` statement is also provided for clarity. ```SQL PREPARE my_select2 FROM SELECT name FROM nation WHERE regionkey = ? and nationkey < ?; ``` ```SQL EXECUTE my_select2 USING 1, 3; ``` ```SQL SELECT name FROM nation WHERE regionkey = 1 AND nationkey < 3; ``` -------------------------------- ### Peaka Partner API Introduction and Key Features Source: https://docs.peaka.com/api-reference/api-reference/introduction Provides an overview of the Peaka Partner API, its purpose, and key features such as secure authentication, robust functionality, real-time data access, customizable integration, scalability, and dedicated support. ```APIDOC # Introduction API endpoints ## Overview The Peaka Partner API is a powerful gateway designed for our partners to seamlessly integrate Peaka’s features into their own applications and services. With secure access provided through a unique API key, partners can leverage the full potential of Peaka’s capabilities to enhance their user experience and streamline operations. ## Key Features * Secure Authentication: Access the API with confidence using the apiKey provided by Peaka, ensuring secure and authorized interactions. * Robust Functionality: Utilize a wide range of functions, from data retrieval to executing complex operations, all tailored to meet the diverse needs of our partners. * Real-Time Data Access: Retrieve up-to-the-minute information to keep your services synchronized with the latest developments within Peaka. * Customizable Integration: Tailor the API’s extensive features to fit your platform’s specific requirements, providing a personalized experience for your users. * Scalability: Designed to handle requests at scale, the Peaka Partner API can accommodate growing traffic as your business expands. * Dedicated Support: Benefit from Peaka’s commitment to partnership success with dedicated support for API integration and usage. ``` -------------------------------- ### SQL NOT LIKE Operator: Excluding Start of String Source: https://docs.peaka.com/api-reference/sql/functions/comparison Shows how to use the NOT LIKE operator to exclude strings that match a specific pattern. This example retrieves continents that do not start with 'E'. ```SQL SELECT * FROM (VALUES 'America', 'Asia', 'Africa', 'Europe', 'Australia', 'Antarctica') AS t (continent) WHERE continent NOT LIKE 'E%'; ``` -------------------------------- ### cURL Example for GET Semantic Query Metadata Source: https://docs.peaka.com/api-reference/api-reference/data-metadata/semantic-query-metadata-for-the-project Example cURL command to retrieve semantic query metadata for a project, demonstrating the required URL and Authorization header. ```cURL curl --request GET \ --url https://partner.peaka.studio/api/v1/metadata/{projectId}/query \ --header 'Authorization: Bearer ' ``` -------------------------------- ### Peaka API Documentation Overview Source: https://docs.peaka.com/api-reference/api-reference/projects-api-key/list-api-keys Provides an overview of the Peaka API, including general introduction, server information, and authentication methods. ```APIDOC API Documentation: - Introduction - Servers - Authentication ``` -------------------------------- ### Example Request: Get Data Cache Status (cURL) Source: https://docs.peaka.com/api-reference/api-reference/data-cache/get-cache-status A cURL command example to retrieve the status of a data cache for a given project and cache ID, requiring a Bearer token for authorization. ```curl curl --request GET \ --url https://partner.peaka.studio/api/v1/data/projects/{projectId}/cache/{cacheId}/status \ --header 'Authorization: Bearer ' ``` -------------------------------- ### Peaka API Reference Introduction Source: https://docs.peaka.com/api-reference/api-reference/data-catalogs/list-tables This section introduces the Peaka API, covering essential topics such as server configurations, authentication methods, and general guidelines for API usage. ```APIDOC API Reference: Introduction Servers Authentication ``` -------------------------------- ### Successful AI Agent Thread Retrieval Response Source: https://docs.peaka.com/api-reference/api-reference/ai-agentv2/get-ai-agent-thread Example of a successful 200 OK response body when retrieving an AI agent thread. The actual content of the object is not specified in this example. ```JSON {} ``` -------------------------------- ### Example cURL Request for Get Project Details Source: https://docs.peaka.com/api-reference/api-reference/projects-deprecated/read-project Demonstrates how to make a GET request to the deprecated /projects/{projectId} endpoint using cURL, including the necessary Authorization header. ```cURL curl --request GET \ --url https://partner.peaka.studio/api/v1/projects/{projectId} \ --header 'Authorization: Bearer ' ``` -------------------------------- ### Invoke Catalog-Stored SQL Routine Source: https://docs.peaka.com/api-reference/sql/routines/examples Illustrates how to call a previously defined catalog-stored SQL function (`example.default.answer()`) multiple times in different contexts, including arithmetic operations and string concatenation. ```SQL SELECT example.default.answer() + 1; -- 43 SELECT 'The answer is' || CAST(example.default.answer() as varchar); -- The answer is 42 ``` -------------------------------- ### Peaka API: General Information Source: https://docs.peaka.com/api-reference/api-reference/data-internal-tables/create-table General API documentation links covering introduction, server details, and authentication methods for the Peaka platform. ```APIDOC API Documentation: Introduction Servers Authentication ``` -------------------------------- ### SQL Example: Get Hash Counts Source: https://docs.peaka.com/api-reference/sql/functions/setdigest Provides a SQL example demonstrating how to use the `hash_counts` function. It applies `make_set_digest` to a list of values and then retrieves a map showing the counts of unique hashed values within the digest. ```SQL SELECT hash_counts(make_set_digest(value)) FROM (VALUES 1, 1, 1, 2, 2) T(value); -- {19144387141682250=3, -2447670524089286488=2} ``` -------------------------------- ### Example JSON Response for Project Details Source: https://docs.peaka.com/api-reference/api-reference/organization-projects/read-project Provides a sample JSON object illustrating the structure and typical data returned upon a successful project retrieval. This includes fields such as ID, name, description, domain, webhook base URL, creation timestamp, and the associated workspace ID. ```JSON { "id": "SksnYuxH", "name": "Anapp23334", "description": null, "domain": "anapp2-rfto", "webhookBaseUrl": "https://anapp2-rfto--test.api.peaka.host", "createdAt": "2023-08-21T11:09:04.699714310Z", "workspaceId": "d7f282d2-b392-4b5c-8cea-05f7523df2d2" } ``` -------------------------------- ### Example JSON Response for List Connections Source: https://docs.peaka.com/api-reference/api-reference/connections/list-connections An example JSON array representing a successful response from the GET /connections/{projectId} endpoint. It shows multiple connection objects, each with an 'id', 'name', and 'type' property. ```JSON [ { "id": "c6883de8-78ab-49fb-93c0-70a13652a341", "name": "Stripe Code2", "type": "stripe" }, { "id": "81e6dfd0-4c88-4e81-a28b-422e89cc07c7", "name": "airtable", "type": "airtable" }, { "id": "8db17e23-29de-4dab-8886-af9717e0e742", "name": "airtable2", "type": "airtable" }, { "id": "22706960-023c-411e-a3ac-62d286fa6685", "name": "exampleAirtableConnection", "type": "airtable" } ] ``` -------------------------------- ### Peaka API Documentation Overview Source: https://docs.peaka.com/api-reference/api-reference/data-queries/list-queries Provides an introductory overview of the Peaka API documentation, including general information on servers and authentication methods. ```APIDOC API Documentation: Introduction Servers Authentication ``` -------------------------------- ### SQL VALUES Example: Creating a New Table Source: https://docs.peaka.com/api-reference/sql/reference/values Demonstrates how to use the `VALUES` statement in conjunction with `CREATE TABLE AS` to define and populate a new table with specified column names. ```SQL CREATE TABLE example AS SELECT * FROM ( VALUES (1, 'a'), (2, 'b'), (3, 'c') ) AS t (id, name) ``` -------------------------------- ### Retrieve SQL Alchemy Driver using cURL Source: https://docs.peaka.com/api-reference/api-reference/supported-drivers/get-sql-alchemy-driver Example cURL command to fetch the SQL Alchemy driver information from the Peaka API. This command demonstrates how to use a GET request with a Bearer token for authorization. ```cURL curl --request GET \ --url https://partner.peaka.studio/api/v1/supportedDrivers/sql_alchemy \ --header 'Authorization: Bearer ' ``` -------------------------------- ### Peaka Platform API Reference Source: https://docs.peaka.com/api-reference/api-reference/introduction This section outlines the complete API documentation for the Peaka platform, categorizing endpoints by resource type such as Organizations, Workspaces, Projects, API Keys, Connections, and Data Catalogs. It includes HTTP methods (GET, POST, PUT, DEL) and a brief description for each endpoint. ```APIDOC API Documentation: Introduction Servers Authentication Organization: Organizations: GET List Organizations GET Read Organization Workspaces: GET Read Workspace PUT Update Workspace DEL Delete Workspace GET List Workspaces POST Create Workspace Projects: GET Read Project PUT Update Project DEL Delete Project GET List Projects POST Create Project Projects (Deprecated): GET Read Project (deprecated) PUT Update Project (deprecated) DEL Delete Project (deprecated) GET List Projects (deprecated) POST Create Project (deprecated) Projects: Api Key: GET List API Keys POST Create API Key DEL Delete API Key Connections: GET Get Connection PUT Update Connection DEL Delete Connection GET List Connections POST Create Connection GET Get Connection Detail GET List Connection Config GET Get Connection Config POST Oauth2 Callback Data: Catalogs: GET List Catalogs POST Create Catalog GET Read Catalog DEL Delete Catalog GET List Schemas GET List Tables GET List Columns GET Table Statistics ``` -------------------------------- ### Peaka API General Information Source: https://docs.peaka.com/api-reference/api-reference/data-catalogs/create-catalog General introductory endpoints for the Peaka API, including information on servers and authentication. ```APIDOC API Documentation: Introduction: /api-reference/introduction Servers: /api-reference/servers Authentication: /api-reference/authentication ``` -------------------------------- ### Example: Successful Get Workspace JSON Response Source: https://docs.peaka.com/api-reference/api-reference/organization-workspaces/read-workspace Illustrates the structure of a successful JSON response returned by the 'Get Workspace' API endpoint, including fields such as ID, name, creation details, organization ID, description, and default workspace status. ```json { "id": "3c90c3cc-0d44-4b50-8888-8dd25736052a", "name": "", "createdBy": "3c90c3cc-0d44-4b50-8888-8dd25736052a", "organizationId": "3c90c3cc-0d44-4b50-8888-8dd25736052a", "description": "", "createdAt": "", "defaultWorkspace": true } ``` -------------------------------- ### Peaka API Reference Overview Source: https://docs.peaka.com/api-reference/api-reference/organization-workspaces/create-workspace This section provides a comprehensive overview of the Peaka API endpoints, categorized by resource, including operations for managing organizations, workspaces, projects, API keys, connections, and data catalogs. It outlines the available HTTP methods and their corresponding functionalities. ```APIDOC API Documentation: - Introduction - Servers - Authentication Organization -> Organizations: - GET List Organizations - GET Read Organization Organization -> Workspaces: - GET Read Workspace - PUT Update Workspace - DEL Delete Workspace - GET List Workspaces - POST Create Workspace Organization -> Projects: - GET Read Project - PUT Update Project - DEL Delete Project - GET List Projects - POST Create Project Projects (Deprecated): - GET Read Project deprecated - PUT Update Project deprecated - DEL Delete Project deprecated - GET List Projects deprecated - POST Create Project deprecated Projects -> Api Key: - GET List API Keys - POST Create API Key - DEL Delete API Key Connections: - GET Get Connection - PUT Update Connection - DEL Delete Connection - GET List Connections - POST Create Connection - GET Get Connection Detail - GET List Connection Config - GET Get Connection Config - POST Oauth2 Callback Data -> Catalogs: - GET List Catalogs - POST Create Catalog - GET Read Catalog - DEL Delete Catalog - GET List Schemas - GET List Tables - GET List Columns - GET Table Statistics ``` -------------------------------- ### cURL Example for Read Catalog API Source: https://docs.peaka.com/api-reference/api-reference/data-catalogs/read-catalog Demonstrates how to make a GET request to the Read Catalog endpoint using cURL, including the necessary Authorization header for authentication. This snippet provides a practical example for developers to quickly test the API. ```cURL curl --request GET \ --url https://partner.peaka.studio/api/v1/data/projects/{projectId}/catalogs/{catalogId} \ --header 'Authorization: Bearer ' ``` -------------------------------- ### SQL SHOW COLUMNS Basic Example Source: https://docs.peaka.com/api-reference/sql/reference/show-columns Demonstrates how to list all columns, their types, and attributes for a specific table, such as 'nation'. ```SQL SHOW COLUMNS FROM nation; ``` -------------------------------- ### Example cURL Request to List Columns Source: https://docs.peaka.com/api-reference/api-reference/data-catalogs/list-columns Provides a practical example of how to use the cURL command-line tool to send a GET request to the 'List Columns' API endpoint. This snippet demonstrates the correct URL structure and the inclusion of the Authorization Bearer token header. ```cURL curl --request GET \ --url https://partner.peaka.studio/api/v1/data/projects/{projectId}/catalogs/{catalogId}/schemas/{schemaName}/tables/{tableName}/columns \ --header 'Authorization: Bearer ' ``` -------------------------------- ### Example 200 OK Response for Get Connection Detail Source: https://docs.peaka.com/api-reference/api-reference/connections/get-connection-detail Sample JSON response body for a successful retrieval of connection details, showing typical fields like type, API token URL, swimlane, and corp token. ```json { "type": "bullhorn", "restApiTokenUrl": "http://a.b.c", "swimlane": "123", "corpToken": "123" } ``` -------------------------------- ### Peaka API General Information Source: https://docs.peaka.com/api-reference/api-reference/data-internal-tables/list-tables This section provides introductory information for the Peaka API, covering fundamental concepts such as API introduction, server configurations, and authentication methods required to interact with the API. ```APIDOC API General Information: Introduction (/api-reference/introduction) Servers (/api-reference/servers) Authentication (/api-reference/authentication) ``` -------------------------------- ### Peaka API General Information Source: https://docs.peaka.com/api-reference/api-reference/projects-deprecated/create-project Provides an overview of the Peaka API, including introductory concepts, server configurations, and authentication mechanisms. ```APIDOC API Documentation: - Introduction - Servers - Authentication ``` -------------------------------- ### Read Organization API Documentation and Examples Source: https://docs.peaka.com/api-reference/api-reference/organization-organizations/read-organization Comprehensive documentation for retrieving organization details by ID, including the HTTP method, base URLs, required authorization headers, path parameters, a cURL example for making the request, and an example JSON response structure. ```APIDOC GET /organizations/{organizationId} Base URLs: https://partner.peaka.studio/api/v1 https://partner.eu.peaka.studio/api/v1 Authorizations: Authorization: string (header, required) Bearer authentication header of the form `Bearer `, where `` is your auth token. Path Parameters: organizationId: string (required) ``` ```cURL curl --request GET \ --url https://partner.peaka.studio/api/v1/organizations/{organizationId} \ --header 'Authorization: Bearer ' ``` ```JSON { "id": "3c90c3cc-0d44-4b50-8888-8dd25736052a", "name": "", "owner": "3c90c3cc-0d44-4b50-8888-8dd25736052a", "createdAt": "", "iconFileId": "", "description": "" } ``` -------------------------------- ### Example JSON Response for Project Listing Source: https://docs.peaka.com/api-reference/api-reference/projects-deprecated/list-projects An example of the JSON array returned by the GET /api/v1/projects endpoint upon a successful operation. It illustrates the typical structure of project objects, including 'id', 'name', 'description', 'domain', 'webhookBaseUrl', and 'createdAt' fields. ```JSON [ { "id": "SksnYuxH", "name": "Anapp23334", "description": null, "domain": "anapp2-rfto", "webhookBaseUrl": "https://anapp2-rfto--test.api.peaka.host", "createdAt": "2023-08-21T11:09:04.699714310Z" }, { "id": "0IQ6f4QB", "name": "App Deneme", "description": null, "domain": "appdeneme-wmdp", "webhookBaseUrl": "https://appdeneme-wmdp--test.api.peaka.host", "createdAt": "2023-12-14T12:38:55.025274418Z" } ] ``` -------------------------------- ### Invoke Parameterized SQL Function Source: https://docs.peaka.com/api-reference/sql/routines/examples Shows an example of calling the `hello` function with a literal string argument, demonstrating how to pass values to a parameterized SQL routine. ```SQL SELECT hello('Jane Doe'); -- Hello, Jane Doe! ``` -------------------------------- ### Peaka API Documentation Overview Source: https://docs.peaka.com/api-reference/api-reference/organization-workspaces/update-workspace Provides an introduction and foundational information for the Peaka API, including details on server configurations and authentication methods required to access the API. ```APIDOC API Documentation: Introduction Servers Authentication ```