### Configure ReactAgent with Model and Tools (Python) Source: https://docs.superwise.ai/docs/advanced-agent-app This snippet demonstrates how to configure a ReactAgent using the SUPERWISE SDK. It requires an LLM model, a list of tools, and an optional prompt to guide the agent's behavior. Ensure the SUPERWISE SDK is installed and configured prior to use. ```python from superwise_api.models.agent.agent import ReactAgentConfig #List of defined tools tools = [tool for tool in tools] agent_config = ReactAgentConfig(llm_model=model, tools=tools, prompt=prompt) ``` -------------------------------- ### Install SUPERWISE Python SDK Source: https://docs.superwise.ai/docs/sdk Installs the SUPERWISE® Python SDK using pip. This package is required to interact with the SUPERWISE® platform programmatically. ```python pip install superwise-api ``` -------------------------------- ### Model Configuration and Context Source: https://docs.superwise.ai/reference/create_version This section details the available model configurations (OpenAI, OpenAICompatible, Superwise, VertexAIModelGarden) and how to manage context, including prompt and knowledge-based context. ```APIDOC ## Model Configuration and Context Handling ### Description This API allows for the configuration of various AI models and the management of contextual information to be used with these models. It supports different model providers like OpenAI and Vertex AI, as well as Superwise's prebuilt models. Context can be provided as a simple string prompt or through more structured knowledge bases, including URLs and file uploads. ### Method POST (Assumed for configuration and request submission) ### Endpoint /websites/superwise_ai/api/models/configure (Assumed) ### Parameters #### Request Body - **model_config** (object) - Configuration object for the selected model. Supports: - **OpenAI** (string) - Reference to OpenAIModel schema. - **OpenAICompatible** (string) - Reference to OpenAICompatibleModel schema. - **Superwise** (string) - Reference to PrebuiltModel-Output schema. - **VertexAIModelGarden** (string) - Reference to VertexAIModelGardenModel schema. - **prompt** (string | null) - A string containing the user's prompt. - **context** (object | null) - Contextual information for the model. - **name** (string) - The name of the context. Max length 50, min length 1. - **config** (object) - Configuration for the context type. - **type** (string) - Must be 'Knowledge'. - **knowledge_id** (string) - The ID of the knowledge source. - **knowledge_metadata** (object) - Metadata for the knowledge source. Supports: - **type** (string) - Must be 'url'. - **url** (string) - The URL of the knowledge source. - **max_depth** (integer) - Maximum crawling depth for the URL. Min 1, Max 5. - **type** (string) - Must be 'file'. - **file_ids** (array of strings) - An array of file IDs. Must contain at least one ID. ### Request Example ```json { "model_config": { "OpenAI": "#/components/schemas/OpenAIModel" }, "prompt": "What is the capital of France?", "context": { "name": "Website Context", "config": { "type": "Knowledge", "knowledge_id": "knowledge-source-123", "knowledge_metadata": { "type": "url", "url": "https://example.com/knowledge", "max_depth": 3 } } } } ``` ### Response #### Success Response (200) - **response_text** (string) - The AI model's generated response. - **context_used** (object) - Information about the context utilized. #### Response Example ```json { "response_text": "The capital of France is Paris.", "context_used": { "name": "Website Context", "source": "https://example.com/knowledge" } } ``` ``` -------------------------------- ### Get Policies using Python Source: https://docs.superwise.ai/reference/policies This code snippet shows how to fetch policies using the Python `requests` library. It makes a GET request to the Superwise AI API and handles potential JSON responses. Ensure you have the `requests` library installed (`pip install requests`). ```python import requests url = "https://api.superwise.ai/v1/policies" headers = { "accept": "application/json" } response = requests.get(url, headers=headers) if response.status_code == 200: print(response.json()) elif response.status_code == 404: print("Error: Resource not found.") elif response.status_code == 422: print("Validation Error:", response.json()) elif response.status_code == 500: print("Server Error.") else: print(f"Unexpected status code: {response.status_code}") ``` -------------------------------- ### Get Models via Ruby Source: https://docs.superwise.ai/reference/model This Ruby example shows how to get models using the 'httparty' gem. It makes a GET request to the Superwise AI API and prints the response body. The code includes basic error handling. ```ruby require 'httparty' url = 'https://api.superwise.ai/v1/models' response = HTTParty.get(url, headers: { 'accept' => 'application/json' }) puts response.body ``` -------------------------------- ### Google AI Model Configuration Source: https://docs.superwise.ai/reference/create_version Sets up a Google AI model, specifying the API token and a version from a predefined list, with optional parameters like temperature and top_p. ```APIDOC ## POST /websites/superwise_ai/models/google_ai ### Description Configures a Google AI model for use with Superwise AI. ### Method POST ### Endpoint /websites/superwise_ai/models/google_ai ### Parameters #### Request Body - **api_token** (string) - Required - The API token for accessing Google AI services. - **version** (string) - Required - The version of the Google AI model (e.g., "models/gemini-2.5-flash"). Must be one of the supported versions. - **parameters** (object) - Optional - Additional parameters for the model. - **temperature** (number) - Optional - Defaults to 0. Controls randomness. Value between 0 and 1. - **top_p** (number) - Optional - Controls nucleus sampling. Value between 0 and 1. ### Request Example ```json { "api_token": "your_google_ai_api_token", "version": "models/gemini-2.5-flash", "parameters": { "temperature": 0.7, "top_p": 0.9 } } ``` ### Response #### Success Response (200) - **message** (string) - Confirmation message indicating successful configuration. ``` -------------------------------- ### Get Sources API Request (PHP) Source: https://docs.superwise.ai/reference/sources Example of how to make a GET request to the /v1/sources endpoint using PHP. This code uses cURL to perform the request and output the JSON response. ```php ``` -------------------------------- ### Prebuilt Model Usage Source: https://docs.superwise.ai/reference/create_version Details on how to utilize prebuilt models provided by Superwise, requiring only an API token. ```APIDOC ## POST /websites/superwise_ai/models/prebuilt ### Description Utilize a prebuilt model offered by Superwise AI. ### Method POST ### Endpoint /websites/superwise_ai/models/prebuilt ### Parameters #### Request Body - **api_token** (string) - Required - The API token for accessing Superwise AI services. ### Request Example ```json { "api_token": "superwise_api_token_xxxxxxxxxxxx" } ``` ### Response #### Success Response (200) - **message** (string) - A confirmation message indicating successful usage of the prebuilt model. #### Response Example ```json { "message": "Prebuilt model utilized successfully." } ``` ``` -------------------------------- ### Initialize SUPERWISE Python Client Source: https://docs.superwise.ai/docs/sdk Initializes the SuperwiseClient by setting environment variables for authentication (SUPERWISE_CLIENT_ID and SUPERWISE_CLIENT_SECRET) and then creating an instance of the client. Ensure you replace placeholder values with your actual credentials. ```python import os from superwise_api.superwise_client import SuperwiseClient os.environ['SUPERWISE_CLIENT_ID'] = 'REPLACE_WITH_YOUR_CLIENT' os.environ['SUPERWISE_CLIENT_SECRET'] = 'REPLACE_WITH_YOUR_SECRET' sw = SuperwiseClient() ``` -------------------------------- ### Get Sources API Request (cURL) Source: https://docs.superwise.ai/reference/sources Example of how to make a GET request to the /v1/sources endpoint using cURL. This demonstrates the basic structure for retrieving source data, including the URL and required headers. ```shell curl --request GET \ --url https://api.superwise.ai/v1/sources \ --header 'accept: application/json' ``` -------------------------------- ### Get Sources API Request (Ruby) Source: https://docs.superwise.ai/reference/sources Example of how to make a GET request to the /v1/sources endpoint using Ruby. This snippet uses the 'httparty' gem to retrieve source data, showing how to set the URL and headers. ```ruby require 'httparty' response = HTTParty.get('https://api.superwise.ai/v1/sources', headers: { 'accept' => 'application/json' }) if response.success? puts response.parsed_response else puts "Error: #{response.code} - #{response.message}" end ``` -------------------------------- ### Superwise Prebuilt Model Configuration Source: https://docs.superwise.ai/reference/ask_application_playground Configure Superwise's prebuilt models. This typically only requires specifying the provider. ```APIDOC ## POST /websites/superwise_ai/models/prebuilt ### Description Configure Superwise's prebuilt models. This endpoint allows you to select and enable Superwise's optimized models. ### Method POST ### Endpoint /websites/superwise_ai/models/prebuilt ### Parameters #### Request Body - **provider** (string) - Optional - Defaults to "Superwise". Specifies the use of a prebuilt Superwise model. ### Request Example ```json { "provider": "Superwise" } ``` ### Response #### Success Response (200) - **message** (string) - Confirmation message indicating successful configuration. #### Response Example ```json { "message": "Superwise prebuilt model configured successfully." } ``` ``` -------------------------------- ### Get Sources API Request (Node.js) Source: https://docs.superwise.ai/reference/sources Example of how to make a GET request to the /v1/sources endpoint using Node.js. This snippet utilizes the 'axios' library to fetch source data and includes basic error handling. ```javascript const axios = require('axios'); const getSources = async () => { try { const response = await axios.get('https://api.superwise.ai/v1/sources', { headers: { 'accept': 'application/json' } }); console.log(response.data); } catch (error) { console.error('Error fetching sources:', error); } }; getSources(); ``` -------------------------------- ### Create and Deploy a Basic LLM Agent using SUPERWISE® SDK Source: https://docs.superwise.ai/docs/build-a-new-gen-ai-app This Python snippet demonstrates how to create a Basic LLM agent using the SUPERWISE® SDK. It involves defining the agent, configuring an OpenAI model, assigning the configuration, and publishing it as a new version. Prerequisites include installing and configuring the SUPERWISE® SDK. ```python from superwise_api.models.agent.agent import BasicLLMConfig from superwise_api.models.agent.agent import OpenAIModel, OpenAIModelVersion # Create an agent agent = sw.agent.create(f"my agent name", description="Description for my agent", authentication_enabled=False, observability_enabled=True) # Create a model model = OpenAIModel(version=OpenAIModelVersion.GPT_4, api_token="Add your API token") # Assign agent configuration agent_config = BasicLLMConfig(llm_model=model, prompt=prompt) # Publish the configuration as a new version version = sw.agent.create_version(agent_id=agent.id,name="My Version name", description="My Version description", agent_config=agent_config) ``` -------------------------------- ### Prebuilt Model Configuration Source: https://docs.superwise.ai/reference/ask_application_playground Configuration for utilizing prebuilt models provided by Superwise AI. ```APIDOC ## Prebuilt Model Configuration ### Description This section covers the configuration for using prebuilt models offered directly by Superwise AI. ### Parameters #### Request Body - **provider** (string) - Optional - Defaults to `Superwise`. Specifies the provider. ### Request Example ```json { "provider": "Superwise" } ``` ### Response #### Success Response (200) - **message** (string) - A success message indicating the prebuilt model is ready. #### Response Example ```json { "message": "Prebuilt Superwise model is ready to use." } ``` ``` -------------------------------- ### Get Sources API Request (Python) Source: https://docs.superwise.ai/reference/sources Example of how to make a GET request to the /v1/sources endpoint using Python. This snippet uses the 'requests' library to fetch source data, demonstrating how to include headers and handle responses. ```python import requests url = "https://api.superwise.ai/v1/sources" headers = { "accept": "application/json" } try: response = requests.get(url, headers=headers) response.raise_for_status() # Raise an exception for bad status codes print(response.json()) except requests.exceptions.RequestException as e: print(f"Error fetching sources: {e}") ``` -------------------------------- ### Configure Basic LLM Agent using Python SDK Source: https://docs.superwise.ai/docs/create-basic-llm-assistant-application This snippet demonstrates how to create a configuration object for a basic LLM agent using the Superwise AI Python SDK. It requires a pre-configured LLM model and an optional prompt to guide the agent's behavior. This configuration is essential for initializing the agent for direct LLM interaction. ```python from superwise_api.models.agent.agent import BasicLLMConfig agent_config = BasicLLMConfig(llm_model=model, prompt=prompt) ``` -------------------------------- ### Get Models via Node.js Source: https://docs.superwise.ai/reference/model This code example shows how to fetch models using Node.js. It utilizes the 'axios' library to make an HTTP GET request to the Superwise AI API endpoint. The response is logged to the console, and error handling is included. ```javascript const axios = require('axios'); const options = { method: 'GET', url: 'https://api.superwise.ai/v1/models', headers: { 'accept': 'application/json' } }; axios.request(options).then(function (response) { console.log(response.data); }).catch(function (error) { console.error(error); }); ``` -------------------------------- ### Get Guardrails List (PHP) Source: https://docs.superwise.ai/reference/guardrails Provides a PHP example for retrieving guardrails from the Superwise AI API. It utilizes cURL to make the GET request and sets the 'accept' header for a JSON response. ```php ``` -------------------------------- ### Create Website Source: https://docs.superwise.ai/reference/get_dataset_sources Creates a new website entry within the Superwise platform. This requires a name and URL for the new website. ```APIDOC ## POST /websites ### Description Creates a new website. ### Method POST ### Endpoint /websites ### Parameters #### Request Body - **name** (string) - Required - The name of the website. - **url** (string) - Required - The URL of the website. ### Request Example ```json { "example": "{\n \"name\": \"My New Website\",\n \"url\": \"https://example.com\"\n}" } ``` ### Response #### Success Response (200) - **id** (string) - The unique identifier for the newly created website. - **name** (string) - The name of the website. - **url** (string) - The URL of the website. #### Response Example ```json { "example": "{\n \"id\": \"new-website-id\",\n \"name\": \"My New Website\",\n \"url\": \"https://example.com\"\n}" } ``` ``` -------------------------------- ### Get Policies using Node.js Source: https://docs.superwise.ai/reference/policies This example uses the built-in Node.js `https` module to make a GET request to the Superwise AI Policies API. It demonstrates setting headers and handling the response data. For simpler usage, consider libraries like `axios`. ```javascript const https = require('https'); const options = { hostname: 'api.superwise.ai', port: 443, path: '/v1/policies', method: 'GET', headers: { 'accept': 'application/json' } }; const req = https.request(options, (res) => { let data = ''; res.on('data', (chunk) => { data += chunk; }); res.on('end', () => { if (res.statusCode === 200) { console.log(JSON.parse(data)); } else { console.error(`Error: ${res.statusCode} - ${res.statusMessage}`); console.error(data); } }); }); req.on('error', (error) => { console.error(error); }); req.end(); ``` -------------------------------- ### POST /websites/superwise_ai/versions Source: https://docs.superwise.ai/reference/create_version Creates a new version for a website, defining its agent configuration and other settings. ```APIDOC ## POST /websites/superwise_ai/versions ### Description Creates a new version for a website, defining its agent configuration and other settings. This endpoint is used to set up the AI agent behavior and associated parameters for a given website. ### Method POST ### Endpoint /websites/superwise_ai/versions ### Parameters #### Request Body - **name** (string) - Required - The name of the version. - **agent_config** (object) - Required - Configuration for the AI agent. This object can take different forms depending on the agent type. - **type** (string) - Required - The type of the agent (e.g., "Flowise", "AIAssistant", "BasicLLM", "ReactAgent"). - **flow_id** (string) - Required (if type is "Flowise") - The ID of the Flowise flow. - **url** (string) - Required (if type is "Flowise") - The URL of the Flowise instance. - **api_key** (string) - Required (if type is "Flowise") - The API key for the Flowise instance. - **flowise_credentials** (object) - Optional (if type is "Flowise") - Credentials for Flowise authentication. - **name** (string) - Required - The name of the credential. - **credentialName** (string) - Required - The name of the credential. - **plainDataObj** (object) - Required - Plain data object for the credential. - (additional properties) (string) - Description of the credential's data fields. - **guardrails** (array) - Optional - A list of guardrail IDs to associate with this version. Defaults to an empty array. ### Request Example ```json { "name": "v1.0", "agent_config": { "type": "Flowise", "flow_id": "some-flow-id", "url": "https://flowise.example.com", "api_key": "your-flowise-api-key", "flowise_credentials": { "name": "my-flowise-cred", "credentialName": "flowise-default", "plainDataObj": { "username": "user", "password": "pass" } } }, "guardrails": ["uuid-guardrail-1"] } ``` ### Response #### Success Response (201) - **id** (string) - The unique identifier for the created version. - **agent_id** (string) - The unique identifier for the associated agent. - **created_by** (string) - The user who created the version. - **created_at** (string) - The timestamp when the version was created. #### Response Example ```json { "id": "a1b2c3d4-e5f6-7890-1234-567890abcdef", "agent_id": "f0e9d8c7-b6a5-4321-fedc-ba9876543210", "created_by": "user@example.com", "created_at": "2023-10-27T10:00:00Z" } ``` ``` -------------------------------- ### Get Policies using PHP Source: https://docs.superwise.ai/reference/policies This PHP example demonstrates fetching policies from the Superwise AI API using cURL. It sets the request method to GET, specifies the URL, and includes the `accept` header. Error handling for different HTTP status codes is included. ```php ``` -------------------------------- ### Create an Agent using Python SDK Source: https://docs.superwise.ai/docs/deploying-superwise-apps This Python code snippet demonstrates how to create a new agent using the SUPERWISE® SDK. It requires a name, an optional description, and can configure authentication and observability. The `sw.agent.create` function is used for this purpose. ```python agent = sw.agent.create(f"my agent name", description="Description for my agent", authentication_enabled=False, observability_enabled=True) ``` -------------------------------- ### Get Guardrails List (Node.js) Source: https://docs.superwise.ai/reference/guardrails Retrieves a list of guardrails using Node.js. This example demonstrates making a GET request to the Superwise AI API endpoint for guardrails. It includes setting the 'accept' header. ```javascript const url = 'https://api.superwise.ai/v1/guardrails'; fetch(url, { method: 'GET', headers: { 'accept': 'application/json' } }) .then(response => response.json()) .then(data => console.log(data)) .catch(error => console.error('Error:', error)); ``` -------------------------------- ### Configure Google Model Source: https://docs.superwise.ai/reference/create_version Sets up the configuration for using Google's AI models, including model version and generation parameters. ```APIDOC ## POST /websites/superwise_ai/models/google ### Description Configures the AI model to use Google's models. Requires an API token and a specific model version. Optional parameters like temperature, top_p, top_k, and max_tokens can be set to fine-tune generation. ### Method POST ### Endpoint /websites/superwise_ai/models/google ### Parameters #### Request Body - **api_token** (string) - Required - Your API token for accessing Google models. - **version** (string) - Required - The specific version of the Google model to use. Examples: "models/gemini-2.0-flash-thinking-exp", "models/gemini-2.5-flash", "models/gemini-2.5-pro", "models/gemini-2.5-flash-lite". - **parameters** (object) - Optional - Generation parameters. - **temperature** (number) - Optional - Controls randomness. Range: [0, 1]. Default: 0. - **top_p** (number) - Optional - Controls diversity via nucleus sampling. Range: [0, 1]. Default: 1. - **top_k** (integer) - Optional - Controls diversity via top-k sampling. Minimum: 1. Default: 40. - **max_tokens** (integer or null) - Optional - The maximum number of tokens to generate. ### Request Example ```json { "api_token": "YOUR_GOOGLE_API_TOKEN", "version": "models/gemini-2.5-pro", "parameters": { "temperature": 0.7, "top_k": 50, "max_tokens": 1024 } } ``` ### Response #### Success Response (200) - **message** (string) - A confirmation message indicating successful configuration. #### Response Example ```json { "message": "Google model configuration updated successfully." } ``` ``` -------------------------------- ### Python SDK: Querying the Agent Playground Source: https://docs.superwise.ai/docs/using-the-chat-1 This Python code snippet demonstrates how to use the Superwise SDK to query the agent playground. It allows testing different agent configurations by sending user input and specifying parameters such as the LLM model, prompt, tools, and chat history. The playground provides an ad-hoc environment for running these queries without affecting production settings. ```python agent_response = sw.agent.ask_playground(input=user_input, llm_model=model, prompt=prompt, tools =tools, chat_history=chat_history, guards=[] ) ``` -------------------------------- ### Get Tags API Request (Node.js) Source: https://docs.superwise.ai/reference/tags Provides an example of how to fetch tags from the Superwise AI API using Node.js. This snippet utilizes the 'node-fetch' library to make the HTTP GET request and handle the JSON response. ```javascript import fetch from 'node-fetch'; const url = "https://api.superwise.ai/v1/tags/"; fetch(url, { method: 'GET', headers: { 'accept': 'application/json' } }) .then(response => response.json()) .then(data => console.log(data)) .catch(error => console.error('Error:', error)); ``` -------------------------------- ### Run Guardrail Version with Python SDK Source: https://docs.superwise.ai/docs/publishing-a-guardrail This example demonstrates how to execute a published guardrail version using the Superwise AI Python SDK. It takes an input query and uses the `run_versions` function to process it against the specified guardrail version ID. The results indicate how the guardrail processed the input. ```python input = "How long does it take to walk across the Manhattan bridge?" guardrail_results = sw.guardrails.run_versions(tag="input", ids={guardrail_version.id}, query=input) ``` -------------------------------- ### Get Tags API Request (Shell) Source: https://docs.superwise.ai/reference/tags Demonstrates how to make a GET request to the Superwise AI API to retrieve tags using cURL. This example shows the basic structure of the request including the URL and accept header. ```shell curl --request GET \ --url https://api.superwise.ai/v1/tags/ \ --header 'accept: application/json' ``` -------------------------------- ### Get Integrations API Request (Python) Source: https://docs.superwise.ai/reference/integrations This Python example illustrates how to retrieve integration information from the Superwise AI API using the 'requests' library. It sends a GET request to the integrations endpoint with the appropriate 'accept' header. ```python import requests headers = { 'accept': 'application/json' } response = requests.get('https://api.superwise.ai/v1/integrations', headers=headers) print(response.json()) ``` -------------------------------- ### OpenAI-Compatible Model Configuration Source: https://docs.superwise.ai/reference/ask_application_playground Configure settings for OpenAI-compatible services, requiring API token, version, and base URL. ```APIDOC ## POST /websites/superwise_ai/models/openai-compatible ### Description Configure settings for OpenAI-compatible services. This requires an API token, the model version, and the base URL of the compatible service. ### Method POST ### Endpoint /websites/superwise_ai/models/openai-compatible ### Parameters #### Request Body - **api_token** (string) - Required - The API token for the OpenAI-compatible service. - **version** (string) - Required - The specific version of the model to use. - **base_url** (string) - Required - The base URL of the OpenAI-compatible service endpoint. - **provider** (string) - Optional - Defaults to "OpenAICompatible". ### Request Example ```json { "api_token": "your_compatible_api_token", "version": "v1", "base_url": "https://api.example-openai-compatible.com/v1" } ``` ### Response #### Success Response (200) - **message** (string) - Confirmation message indicating successful configuration. #### Response Example ```json { "message": "OpenAI-compatible model configured successfully." } ``` ``` -------------------------------- ### POST /websites/superwise_ai/tools/sql/postgres Source: https://docs.superwise.ai/reference/create_version Configure a PostgreSQL SQL database tool for a website. This endpoint allows you to specify the connection string and optional metadata for table inclusion or exclusion. ```APIDOC ## POST /websites/superwise_ai/tools/sql/postgres ### Description Configures a PostgreSQL SQL database tool for a website. This endpoint allows you to specify the connection string and optional metadata for table inclusion or exclusion. ### Method POST ### Endpoint `/websites/superwise_ai/tools/sql/postgres` ### Parameters #### Request Body - **connection_string** (string) - Required - The PostgreSQL connection string. - **config_metadata** (object | null) - Optional - Metadata for the SQL tool configuration. - **include_tables** (array[string] | null) - Optional - A list of tables to include. - **exclude_tables** (array[string] | null) - Optional - A list of tables to exclude. ### Request Example ```json { "connection_string": "postgresql://user:password@host:port/database", "config_metadata": { "include_tables": ["users", "orders"], "exclude_tables": null } } ``` ### Response #### Success Response (200) - **message** (string) - A confirmation message indicating successful configuration. #### Response Example ```json { "message": "PostgreSQL tool configuration updated successfully." } ``` ``` -------------------------------- ### Get Tags API Request (PHP) Source: https://docs.superwise.ai/reference/tags Demonstrates how to fetch tags using PHP's cURL extension. This example shows setting up the cURL request, specifying the URL and headers, and processing the JSON response. ```php ``` -------------------------------- ### Tool Configuration - BigQuery Source: https://docs.superwise.ai/reference/create_version Configure BigQuery as a data source for Superwise AI websites. Requires project ID, dataset ID, and service account credentials. ```APIDOC ## POST /websites/superwise_ai/toolconfig/bigquery ### Description Configure BigQuery as a data source for Superwise AI websites. ### Method POST ### Endpoint /websites/superwise_ai/toolconfig/bigquery ### Parameters #### Request Body - **project_id** (string) - Required - The Google Cloud project ID. - **dataset_id** (string) - Required - The BigQuery dataset ID. - **service_account** (object) - Required - Service account credentials for BigQuery access. - **type** (string) - The type of the service account credential (e.g., "private_key"). - **project_id** (string) - The project ID associated with the service account. - **private_key_id** (string) - The private key ID of the service account. - **private_key** (string) - The private key of the service account. - **client_email** (string) - The email address of the service account. - **client_id** (string) - The client ID of the service account. - **auth_uri** (string) - The authorization URI for the service account. - **token_uri** (string) - The token URI for the service account. - **auth_provider_x509_cert_url** (string) - The x509 certificate URL for the authentication provider. - **client_x509_cert_url** (string) - The x509 certificate URL for the client. ### Request Example ```json { "project_id": "your-gcp-project-id", "dataset_id": "your-bigquery-dataset-id", "service_account": { "type": "service_account", "project_id": "your-gcp-project-id", "private_key_id": "your-private-key-id", "private_key": "-----BEGIN PRIVATE KEY-----\n...\n-----END PRIVATE KEY-----", "client_email": "your-service-account-email@your-gcp-project-id.iam.gserviceaccount.com", "client_id": "your-client-id", "auth_uri": "https://accounts.google.com/o/oauth2/auth", "token_uri": "https://oauth2.googleapis.com/token", "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs", "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/your-service-account-email%40your-gcp-project-id.iam.gserviceaccount.com" } } ``` ### Response #### Success Response (200) - **message** (string) - A confirmation message indicating successful configuration. #### Response Example ```json { "message": "BigQuery configuration updated successfully." } ``` ``` -------------------------------- ### Create Knowledge Context using Python SDK Source: https://docs.superwise.ai/docs/ai-assistent-retrieval-app This Python code snippet shows how to set up a Knowledge context within SUPERWISE using the SDK. It involves providing a name for the context, a knowledge ID, metadata about the knowledge source (like URL and max depth), and the embedding model configuration. Ensure the embedding model matches the one used for indexing the knowledge base. ```python from superwise_api.models.tool.tool import ToolConfigKnowledge, OpenAIEmbeddingModel, OpenAIEmbeddingModelVersion, UrlKnowledgeMetadata from superwise_api.models.context.context import ContextDef knowledge_context = ContextDef( name='Context name', config=ToolConfigKnowledge( knowledge_id='Knowledge ID', knowledge_metadata=UrlKnowledgeMetadata(url='URL', max_depth='MAX_DEPTH'), embedding_model=OpenAIEmbeddingModel(version=OpenAIEmbeddingModelVersion.TEXT_EMBEDDING_ADA_002, api_key="Open AI key") ) ) ``` -------------------------------- ### Get Policies using cURL Source: https://docs.superwise.ai/reference/policies This snippet demonstrates how to retrieve policies using a cURL command. It specifies the GET request method, the API endpoint URL, and the 'accept' header for JSON responses. ```bash curl --request GET \ --url https://api.superwise.ai/v1/policies \ --header 'accept: application/json' ```