### Getting Started Example Source: https://docs.goodmem.ai/docs/reference/sdk/dotnet A basic example demonstrating how to initialize the client, set the BasePath, create an API instance, and make a call to create an API key. Includes error handling for API exceptions. ```csharp using System.Collections.Generic; using System.Diagnostics; using System.Net.Http; using Pairsystems.Goodmem.Client.Api; using Pairsystems.Goodmem.Client.Client; using Pairsystems.Goodmem.Client.Model; namespace Example { public class Example { public static void Main() { Configuration config = new Configuration(); config.BasePath = "http://localhost:8080"; // create instances of HttpClient, HttpClientHandler to be reused later with different Api classes var apiInstance = new APIKeysApi(config); var createApiKeyRequest = new CreateApiKeyRequest(); // CreateApiKeyRequest | API key configuration try { // Create a new API key CreateApiKeyResponse result = apiInstance.CreateApiKey(createApiKeyRequest); Debug.WriteLine(result); } catch (ApiException e) { Debug.Print("Exception when calling APIKeysApi.CreateApiKey: " + e.Message ); Debug.Print("Status Code: "+ e.ErrorCode); Debug.Print(e.StackTrace); } } } } ``` -------------------------------- ### Getting Started with Java SDK Source: https://docs.goodmem.ai/docs/reference/sdk/java Example of initializing the client and calling the drainServer API. Ensure the base path is correctly set. ```java // Import classes: import ai.pairsys.goodmem.client.ApiClient; import ai.pairsys.goodmem.client.ApiException; import ai.pairsys.goodmem.client.Configuration; import ai.pairsys.goodmem.client.model.*; import ai.pairsys.goodmem.client.api.AdministrationApi; public class Example { public static void main(String[] args) { ApiClient defaultClient = Configuration.getDefaultApiClient(); defaultClient.setBasePath("http://localhost"); AdministrationApi apiInstance = new AdministrationApi(defaultClient); AdminDrainRequest adminDrainRequest = new AdminDrainRequest(); // AdminDrainRequest | try { AdminDrainResponse result = apiInstance.drainServer(adminDrainRequest); System.out.println(result); } catch (ApiException e) { System.err.println("Exception when calling AdministrationApi#drainServer"); System.err.println("Status code: " + e.getCode()); System.err.println("Reason: " + e.getResponseBody()); System.err.println("Response headers: " + e.getResponseHeaders()); e.printStackTrace(); } } } ``` -------------------------------- ### Getting Started Source: https://docs.goodmem.ai/docs/reference/api-reference/grpc Steps to get started with the GoodMem gRPC API, including generating client code, creating an API key, setting up authentication, and making requests. ```APIDOC ## Getting Started 1. **Generate client code** from the protocol buffer definitions 2. **Create an API key** using CreateApiKey 3. **Set up authentication** with the generated key 4. **Start making requests** to the services you need ``` -------------------------------- ### Getting Started with Java SDK Source: https://docs.goodmem.ai/docs/reference/sdk/java Example of how to initialize the Java SDK client and call the drainServer method. ```APIDOC ## AdministrationApi#drainServer ### Description This method is used to drain the server. It requires an AdminDrainRequest object and returns an AdminDrainResponse. ### Method POST ### Endpoint /drain ### Parameters #### Request Body - **adminDrainRequest** (AdminDrainRequest) - Required - An object containing parameters for draining the server. ### Request Example ```java // Import classes: import ai.pairsys.goodmem.client.ApiClient; import ai.pairsys.goodmem.client.ApiException; import ai.pairsys.goodmem.client.Configuration; import ai.pairsys.goodmem.client.model.*; import ai.pairsys.goodmem.client.api.AdministrationApi; public class Example { public static void main(String[] args) { ApiClient defaultClient = Configuration.getDefaultApiClient(); defaultClient.setBasePath("http://localhost"); AdministrationApi apiInstance = new AdministrationApi(defaultClient); AdminDrainRequest adminDrainRequest = new AdminDrainRequest(); // AdminDrainRequest | try { AdminDrainResponse result = apiInstance.drainServer(adminDrainRequest); System.out.println(result); } catch (ApiException e) { System.err.println("Exception when calling AdministrationApi#drainServer"); System.err.println("Status code: " + e.getCode()); System.err.println("Reason: " + e.getResponseBody()); System.err.println("Response headers: " + e.getResponseHeaders()); e.printStackTrace(); } } } ``` ### Response #### Success Response (200) - **result** (AdminDrainResponse) - The response object after draining the server. ``` -------------------------------- ### Install GoodMem Go Client Source: https://docs.goodmem.ai/docs/how-to/basic-rag Install the GoodMem Go client using the provided go get command. Configure GOPROXY and GOSUMDB as shown. ```bash GOPROXY="https://go-proxy.fury.io/pairsys/" \ GOSUMDB=off \ go get github.com/PAIR-Systems-Inc/goodmem/clients/go ``` -------------------------------- ### DI Setup in Asp.Net Core Source: https://docs.goodmem.ai/docs/reference/sdk/dotnet Example of setting up the API client for dependency injection in an Asp.Net Core project using IHttpClientFactory. ```csharp services.`AddHttpClient`(httpClient => new PetApi(httpClient)); ``` -------------------------------- ### Server Initialization Log Example Source: https://docs.goodmem.ai/docs/reference/security/fips-compliance Upon successful initialization, the server logs a message confirming the installation of BCFIPS providers and their positions, along with the approved_only mode status. ```text BCFIPS providers installed (approved_only=true): BCFIPS at position 1, BCJSSE at position 2 ``` -------------------------------- ### Install Go SDK via Gemfury Source: https://docs.goodmem.ai/docs/reference/sdk/go Configure your Go environment to use Gemfury as a proxy for private GitHub access and install the GoodMem Go client package. This is the recommended installation method. ```bash ## Set Gemfury proxy for private GitHub access export GOPROXY="https://go-proxy.fury.io/pairsys/" export GOPRIVATE="github.com/PAIR-Systems-Inc/goodmem" export GOSUMDB=off ## Install the package go get github.com/PAIR-Systems-Inc/goodmem/clients/go@latest ``` -------------------------------- ### API Key Creation Example Source: https://docs.goodmem.ai/docs/reference/sdk/javascript Example of how to configure the API client and create an API key using the `APIKeysApi`. ```APIDOC ## API Key Creation ### Description This example demonstrates how to initialize the GoodMem client, configure authentication with an API key, and create a new API key. ### Method `api.createApiKey(createApiKeyRequest)` ### Parameters #### Request Body - **createApiKeyRequest** (object) - Required - API key configuration. Example: `{"labels":{"environment":"development","service":"chat-ui"},"expiresAt":1735689600000}` ### Request Example ```javascript var GoodMemClient = require('@pairsystems/goodmem-client'); // Configure the API client var defaultClient = GoodMemClient.ApiClient.instance; defaultClient.basePath = "http://localhost:8080"; // Use your server URL // Configure API key authentication: X-API-Key header defaultClient.defaultHeaders = { "X-API-Key": "your-api-key-here", "Content-Type": "application/json", "Accept": "application/json" }; var api = new GoodMemClient.APIKeysApi() var createApiKeyRequest = {"labels":{"environment":"development","service":"chat-ui"},"expiresAt":1735689600000}; // {CreateApiKeyRequest} API key configuration api.createApiKey(createApiKeyRequest).then(function(data) { console.log('API called successfully. Returned data: ' + data); }, function(error) { console.error(error); }); ``` ### Response #### Success Response (200) - **data** (object) - Details of the created API key. ``` -------------------------------- ### Installation Source: https://docs.goodmem.ai/docs/reference/sdk/python Install the GoodMem Python SDK using pip. ```APIDOC ## Installation ``` pip install goodmem ``` ``` -------------------------------- ### Start Current Profile's Server Source: https://docs.goodmem.ai/docs/reference/cli/system/goodmem_system_start Use this command to start the GoodMem server instance for the currently active profile. ```bash goodmem system start ``` -------------------------------- ### Install Java SDK with Maven Source: https://docs.goodmem.ai/docs/reference/sdk/java Use this command to install the API client library to your local Maven repository. ```bash mvn clean install ``` -------------------------------- ### Install GoodMem Node.js Client Source: https://docs.goodmem.ai/docs/how-to/basic-rag Install the GoodMem client library for Node.js using npm. This is the first step before configuring the client in your script. ```bash npm install @pairsystems/goodmem-client ``` -------------------------------- ### Install NuGet Packages Source: https://docs.goodmem.ai/docs/reference/sdk/dotnet Use these commands to install the necessary NuGet packages for the GoodMem .NET client. ```powershell Install-Package Newtonsoft.Json Install-Package JsonSubTypes Install-Package System.ComponentModel.Annotations ``` -------------------------------- ### SDK Output Example Source: https://docs.goodmem.ai/docs/how-to/basic-rag Example output from SDK commands for creating a memory from a PDF, showing the memory ID. ```text Memory ID: [MEMORY_UUID] ``` -------------------------------- ### Create Sample Directory and Navigate Source: https://docs.goodmem.ai/docs/how-to/metadata-filters Prepare a clean working directory for GoodMem filter examples by creating a new directory and changing into it. ```bash mkdir -p ~/goodmem-filters cd ~/goodmem-filters ``` -------------------------------- ### Working Example with Streaming Client Source: https://docs.goodmem.ai/docs/reference/sdk/go/MemoriesAPI Demonstrates how to configure and use the streaming client to retrieve memories with advanced options. Requires setting up the client, defining request parameters, and processing the stream of events. ```go package main import ( "context" "fmt" "log" goodmem_client "github.com/PAIR-Systems-Inc/goodmem/clients/go" ) func main() { // Configure client configuration := goodmem_client.NewConfiguration() configuration.Host = "http://localhost:8080" configuration.DefaultHeader["X-API-Key"] = "your-api-key" apiClient := goodmem_client.NewAPIClient(configuration) streamingClient := goodmem_client.NewStreamingClient(apiClient) // Helper values requestedSize := int32(10) fetchMemory := true fetchMemoryContent := false // Create advanced request with custom post-processor request := &goodmem_client.AdvancedMemoryStreamRequest{ Message: "your search query", SpaceIDs: []string{"space-uuid"}, RequestedSize: &requestedSize, FetchMemory: &fetchMemory, FetchMemoryContent: &fetchMemoryContent, Format: goodmem_client.FormatNDJSON, // or FormatSSE PostProcessorName: "com.goodmem.retrieval.postprocess.ChatPostProcessorFactory", PostProcessorConfig: map[string]interface{}{ "llm_id": "550e8400-e29b-41d4-a716-446655440001", "reranker_id": "550e8400-e29b-41d4-a716-446655440000", "relevance_threshold": 0.5, "llm_temp": 0.3, "max_results": 10, "chronological_resort": true, }, } // Execute advanced streaming ctx := context.Background() stream, err := streamingClient.RetrieveMemoryStreamAdvanced(ctx, request) if err != nil { log.Fatalf("Error: %v", err) } // Process events for event := range stream { if event.AbstractReply != nil { fmt.Printf("Abstract: %s\n", event.AbstractReply.Text) } else if event.RetrievedItem != nil { fmt.Printf("Retrieved item: %v\n", event.RetrievedItem) } } } ``` -------------------------------- ### InitializeSystem Go SDK Example Source: https://docs.goodmem.ai/docs/reference/sdk/go/SystemAPI Initialize the system using the InitializeSystem method. This method accepts an empty request body. Ensure the Go SDK client is configured and initialized. ```go package main import ( "context" "fmt" "os" goodmem_client "github.com/PAIR-Systems-Inc/goodmem/clients/go" ) func main() { body := map[string]interface{}{ ... } // map[string]interface{} | Empty request body - no parameters required (optional) configuration := goodmem_client.NewConfiguration() apiClient := goodmem_client.NewAPIClient(configuration) resp, r, err := apiClient.SystemAPI.InitializeSystem(context.Background()).Body(body).Execute() if err != nil { fmt.Fprintf(os.Stderr, "Error when calling `SystemAPI.InitializeSystem``: %v\n", err) fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) } // response from `InitializeSystem`: SystemInitResponse fmt.Fprintf(os.Stdout, "Response from `SystemAPI.InitializeSystem`: %v\n", resp) } ``` -------------------------------- ### Get Space by ID using .NET SDK Source: https://docs.goodmem.ai/docs/reference/sdk/dotnet/SpacesApi Provides an example of retrieving a specific space by its ID using the GetSpace method. It includes API client setup, calling the method, and handling potential ApiException. ```csharp using System.Collections.Generic; using System.Diagnostics; using System.Net.Http; using Pairsystems.Goodmem.Client.Api; using Pairsystems.Goodmem.Client.Client; using Pairsystems.Goodmem.Client.Model; namespace Example { public class GetSpaceExample { public static void Main() { Configuration config = new Configuration(); config.BasePath = "http://localhost"; // create instances of HttpClient, HttpClientHandler to be reused later with different Api classes HttpClient httpClient = new HttpClient(); HttpClientHandler httpClientHandler = new HttpClientHandler(); var apiInstance = new SpacesApi(httpClient, config, httpClientHandler); var id = 550e8400-e29b-41d4-a716-446655440000; // string | The unique identifier of the space to retrieve try { // Get a space by ID Space result = apiInstance.GetSpace(id); Debug.WriteLine(result); } catch (ApiException e) { Debug.Print("Exception when calling SpacesApi.GetSpace: " + e.Message); Debug.Print("Status Code: " + e.ErrorCode); Debug.Print(e.StackTrace); } } } } ``` -------------------------------- ### Get Space by ID Response Body Example Source: https://docs.goodmem.ai/docs/reference/api-reference/rest/spaces/getSpace This is an example of the JSON response body when successfully retrieving a space. It includes details such as space ID, name, labels, embedder configuration, and timestamps. ```json { "spaceId": "550e8400-e29b-41d4-a716-446655440000", "name": "Research Project Space", "labels": { "project": "AI Research", "team": "NLP Group" }, "spaceEmbedders": [ { "spaceId": "550e8400-e29b-41d4-a716-446655440000", "embedderId": "550e8400-e29b-41d4-a716-446655440000", "defaultRetrievalWeight": 1, "createdAt": 1651483320000, "updatedAt": 1651483320000, "createdById": "550e8400-e29b-41d4-a716-446655440000", "updatedById": "550e8400-e29b-41d4-a716-446655440000" } ], "createdAt": 1651483320000, "updatedAt": 1651483320000, "ownerId": "550e8400-e29b-41d4-a716-446655440000", "createdById": "550e8400-e29b-41d4-a716-446655440000", "updatedById": "550e8400-e29b-41d4-a716-446655440000", "publicRead": false, "defaultChunkingConfig": { "recursive": { "chunkSize": 1000, "chunkOverlap": 200, "separators": [ "\n\n", "\n", ".", " " ], "keepStrategy": "KEEP_END", "separatorIsRegex": false, "lengthMeasurement": "CHARACTER_COUNT" }, "sentence": { "maxChunkSize": 1000, "minChunkSize": 100, "enableLanguageDetection": true, "lengthMeasurement": "CHARACTER_COUNT" } } } ``` -------------------------------- ### initializeSystem Source: https://docs.goodmem.ai/docs/reference/sdk/java/SystemApi Initialize the system by creating a root user and API key. This should only be called once during first-time setup. ```APIDOC ## POST /v1/system/init ### Description Initialize the system by creating a root user and API key. This endpoint should only be called once during first-time setup. If the system is already initialized, the endpoint will return a success response without creating new credentials. ### Method POST ### Endpoint /v1/system/init ### Parameters #### Request Body - **body** (Object) - Empty request body - no parameters required ### Return type SystemInitResponse ### Authorization No authorization required ### HTTP request headers * **Content-Type** : application/json * **Accept** : application/json ### HTTP response details Status code| Description ---|--- **200**| System initialization successful **500**| Internal server error during initialization ### Request Example ```java // Import classes: import ai.pairsys.goodmem.client.ApiClient; import ai.pairsys.goodmem.client.ApiException; import ai.pairsys.goodmem.client.Configuration; import ai.pairsys.goodmem.client.models.*; import ai.pairsys.goodmem.client.api.SystemApi; public class Example { public static void main(String[] args) { ApiClient defaultClient = Configuration.getDefaultApiClient(); defaultClient.setBasePath("http://localhost"); SystemApi apiInstance = new SystemApi(defaultClient); Object body = null; // Object | Empty request body - no parameters required try { SystemInitResponse result = apiInstance.initializeSystem(body); System.out.println(result); } catch (ApiException e) { System.err.println("Exception when calling SystemApi#initializeSystem"); System.err.println("Status code: " + e.getCode()); System.err.println("Reason: " + e.getResponseBody()); System.err.println("Response headers: " + e.getResponseHeaders()); e.printStackTrace(); } } } ``` ``` -------------------------------- ### GET Endpoint Query Parameters for Chat Post Processor Source: https://docs.goodmem.ai/docs/reference/post-processors/chat-post-processor Example of simplified query parameters used with the GET endpoint, which is hardwired to use the Chat Post Processor. Note the 'pp_' prefix for parameters. ```url ?pp_llm_id=&pp_relevance_threshold=0.7 ``` -------------------------------- ### Complete Workflow Example Source: https://docs.goodmem.ai/docs/reference/cli A comprehensive example demonstrating the typical workflow for setting up a local GoodMem environment, creating an embedder and space, adding memories, and retrieving them. ```bash # 1) Install a local server, or create/select a profile for an existing one goodmem system install # 2) Confirm which profile is active goodmem profile current # 3) Create an embedder (skip if already set in the current shell) if [[ -z "${EMBEDDER_ID:-}" ]]; then EMBEDDER_ID=$(goodmem embedder create \ --display-name "My Embedder" \ --provider-type OPENAI \ --endpoint-url "https://api.openai.com/v1" \ --model-identifier "text-embedding-3-small" \ --dimensionality 1536 \ --cred-api-key "$OPENAI_API_KEY" \ | awk -F': *' '/^ID:/{print $2}') fi # 4) Create a space (skip if already set) if [[ -z "${SPACE_ID:-}" ]]; then SPACE_ID=$(goodmem space create \ --name "My Knowledge Base" \ --embedder-id "$EMBEDDER_ID" \ --embedder-weight 1.0 \ | awk -F': *' '/^ID:/{print $2}') fi # 5) Add memories goodmem memory create \ --space-id "$SPACE_ID" \ --content "Machine learning is a subset of artificial intelligence" \ --metadata "topic=AI" \ --metadata "source=definition" goodmem memory create \ --space-id "$SPACE_ID" \ --content "Neural networks are inspired by biological neurons" \ --metadata "topic=AI" \ --metadata "source=definition" sleep 2 # 6) Retrieve (search memories) goodmem memory retrieve --space-id "$SPACE_ID" "What is machine learning?" ``` -------------------------------- ### Batch Get Memories Java Example Source: https://docs.goodmem.ai/docs/reference/sdk/java/MemoriesApi This example demonstrates how to retrieve multiple memories in a single request using the Java SDK. Configure the ApiClient's base path before use. It includes error handling for API exceptions. ```java import ai.pairsys.goodmem.client.ApiClient; import ai.pairsys.goodmem.client.ApiException; import ai.pairsys.goodmem.client.Configuration; import ai.pairsys.goodmem.client.models.*; import ai.pairsys.goodmem.client.api.MemoriesApi; public class Example { public static void main(String[] args) { ApiClient defaultClient = Configuration.getDefaultApiClient(); defaultClient.setBasePath("http://localhost"); MemoriesApi apiInstance = new MemoriesApi(defaultClient); BatchMemoryRetrievalRequest batchMemoryRetrievalRequest = new BatchMemoryRetrievalRequest(); // BatchMemoryRetrievalRequest | Batch memory retrieval details try { BatchMemoryResponse result = apiInstance.batchGetMemory(batchMemoryRetrievalRequest); System.out.println(result); } catch (ApiException e) { System.err.println("Exception when calling MemoriesApi#batchGetMemory"); System.err.println("Status code: " + e.getCode()); System.err.println("Reason: " + e.getResponseBody()); System.err.println("Response headers: " + e.getResponseHeaders()); e.printStackTrace(); } } } ``` -------------------------------- ### Initialize System - JavaScript Source: https://docs.goodmem.ai/docs/reference/sdk/javascript/SystemApi Initialize the system by creating a root user and API key. This endpoint should only be called once during first-time setup. If the system is already initialized, it returns a success response without creating new credentials. ```javascript import GoodMemClient from '@pairsystems/goodmem-client'; let apiInstance = new GoodMemClient.SystemApi(); let opts = { 'body': {key: null} // Object | Empty request body - no parameters required }; apiInstance.initializeSystem(opts).then((data) => { console.log('API called successfully. Returned data: ' + data); }, (error) => { console.error(error); }); ``` -------------------------------- ### Batch Get Memories Source: https://docs.goodmem.ai/docs/reference/api-reference/rest/memories/batchGetMemory This example demonstrates how to retrieve multiple memories using their IDs. You can control the level of detail returned by setting `includeContent` and `includeProcessingHistory`. ```APIDOC ## POST /v1/memories:batchGet ### Description Retrieves a batch of memories based on provided IDs. ### Method POST ### Endpoint /v1/memories:batchGet ### Parameters #### Request Body - **memoryIds** (array[string]) - Required - A list of memory IDs to retrieve. - **includeContent** (boolean) - Optional - Whether to include the full content of the memories. - **includeProcessingHistory** (boolean) - Optional - Whether to include the processing history of the memories. ### Request Example ```json { "memoryIds": [ "550e8400-e29b-41d4-a716-446655440000", "550e8400-e29b-41d4-a716-446655440001" ], "includeContent": false, "includeProcessingHistory": false } ``` ### Response #### Success Response (200) - **results** (array[object]) - A list of results for each requested memory. - **success** (boolean) - Indicates if the memory was retrieved successfully. - **memoryId** (string) - The ID of the memory. - **memory** (object) - The memory object (if `success` is true). - **memoryId** (string) - **spaceId** (string) - **originalContent** (string) - **originalContentSha256** (string) - **originalContentRef** (string) - **contentType** (string) - **processingStatus** (string) - **pageImageStatus** (string) - **pageImageCount** (integer) - **createdAt** (integer) - **updatedAt** (integer) - **createdById** (string) - **updatedById** (string) - **chunkingConfig** (object) - **processingHistory** (object) - **error** (object) - The error object (if `success` is false). - **code** (integer) - **message** (string) #### Response Example ```json { "results": [ { "success": true, "memoryId": "550e8400-e29b-41d4-a716-446655440000", "memory": { "memoryId": "550e8400-e29b-41d4-a716-446655440000", "spaceId": "550e8400-e29b-41d4-a716-446655440001", "originalContent": "VGhpcyBpcyBiYXNlNjQgYmluYXJ5Lg==", "originalContentSha256": "9f2c8c5a9d740eb56d...", "originalContentRef": "s3://my-bucket/document.pdf", "contentType": "text/plain", "processingStatus": "COMPLETED", "pageImageStatus": "COMPLETED", "pageImageCount": 12, "createdAt": 1672531200000, "updatedAt": 1672531200000, "createdById": "550e8400-e29b-41d4-a716-446655440002", "updatedById": "550e8400-e29b-41d4-a716-446655440002", "chunkingConfig": { "recursive": { "chunkSize": 1000, "chunkOverlap": 200, "separators": [ "\n\n", "\n", ".", " " ], "keepStrategy": "KEEP_END", "separatorIsRegex": false, "lengthMeasurement": "CHARACTER_COUNT" }, "sentence": { "maxChunkSize": 1000, "minChunkSize": 100, "enableLanguageDetection": true, "lengthMeasurement": "CHARACTER_COUNT" } }, "processingHistory": { "latestJob": { "jobId": 42, "jobType": "document_processor", "status": "BACKGROUND_JOB_RUNNING", "attempts": 1, "maxAttempts": 5, "runAt": 1714713600000, "leaseUntil": 1714713660000, "lockedBy": "worker-1", "lastError": "Transient network failure", "updatedAt": 1714713615000 } } }, "error": { "code": 403, "message": "Forbidden - insufficient permissions" } } ] } ``` ``` -------------------------------- ### Get a Space by ID using Go SDK Source: https://docs.goodmem.ai/docs/reference/sdk/go/SpacesAPI Retrieve a specific space by its ID using this Go SDK example. It prints the response or any errors encountered. ```go package main import ( "context" "fmt" "os" goodmem_client "github.com/PAIR-Systems-Inc/goodmem/clients/go" ) func main() { id := "550e8400-e29b-41d4-a716-446655440000" // string | The unique identifier of the space to retrieve configuration := goodmem_client.NewConfiguration() apiClient := goodmem_client.NewAPIClient(configuration) resp, r, err := apiClient.SpacesAPI.GetSpace(context.Background(), id).Execute() if err != nil { fmt.Fprintf(os.Stderr, "Error when calling `SpacesAPI.GetSpace``: %v\n", err) fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) } // response from `GetSpace`: Space fmt.Fprintf(os.Stdout, "Response from `SpacesAPI.GetSpace`: %v\n", resp) } ``` -------------------------------- ### Initialize the system Source: https://docs.goodmem.ai/docs/reference/sdk/python/system Initializes the system by creating a root user and API key. This endpoint should only be called once during first-time setup. If the system is already initialized, it returns a success response without creating new credentials. ```APIDOC ## Initialize the system ### Description Initializes the system by creating a root user and API key. This endpoint should only be called once during first-time setup. If the system is already initialized, the endpoint will return a success response without creating new credentials. ### Method Signature system.init() -> SystemInitResponse ### Returns `SystemInitResponse` — Returns the initial admin API key. ### Example ```python result = client.system.init() print(f"Already initialized: {result.already_initialized}") ``` ``` -------------------------------- ### InitializeSystem Source: https://docs.goodmem.ai/docs/reference/sdk/go/SystemAPI Initialize the system. This method is used to perform initial setup for the system. ```APIDOC ## InitializeSystem ### Description Initialize the system. ### Method POST ### Endpoint /v1/system/init ### Parameters #### Path Parameters This endpoint does not need any parameter. #### Other Parameters Other parameters are passed through a pointer to a apiInitializeSystemRequest struct via the builder pattern Name| Type| Description| Notes ---|---|---|--- **body**| **map[string]interface**| Empty request body - no parameters required| ### Return type **SystemInitResponse** ### Authorization No authorization required ### HTTP request headers * **Content-Type** : application/json * **Accept** : application/json ``` -------------------------------- ### Initialize System Source: https://docs.goodmem.ai/docs/reference/sdk/python/system Call `client.system.init()` to create a root user and API key during first-time setup. If already initialized, it returns success without creating new credentials. ```python result = client.system.init() print(f"Already initialized: {result.already_initialized}") ``` -------------------------------- ### Batch Get Memories Go SDK Example Source: https://docs.goodmem.ai/docs/reference/sdk/go/MemoriesAPI Retrieves multiple memories by their IDs using the BatchGetMemory method. Ensure you have the correct memory IDs to pass in the request. ```go package main import ( "context" "fmt" "os" goodmem_client "github.com/PAIR-Systems-Inc/goodmem/clients/go" ) func main() { batchMemoryRetrievalRequest := *goodmem_client.NewBatchMemoryRetrievalRequest([]string{"MemoryIds_example"}) // BatchMemoryRetrievalRequest | Batch memory retrieval details configuration := goodmem_client.NewConfiguration() apiClient := goodmem_client.NewAPIClient(configuration) resp, r, err := apiClient.MemoriesAPI.BatchGetMemory(context.Background()).BatchMemoryRetrievalRequest(batchMemoryRetrievalRequest).Execute() if err != nil { fmt.Fprintf(os.Stderr, "Error when calling `MemoriesAPI.BatchGetMemory``: %v\n", err) fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) } // response from `BatchGetMemory`: BatchMemoryResponse fmt.Fprintf(os.Stdout, "Response from `MemoriesAPI.BatchGetMemory`: %v\n", resp) } ``` -------------------------------- ### Download Sample PDF Source: https://docs.goodmem.ai/docs/how-to/basic-rag Use wget to download the sample employee handbook PDF to your current directory. ```bash wget https://raw.githubusercontent.com/PAIR-Systems-Inc/goodmem-samples/main/cookbook/1_Building_a_basic_RAG_Agent_with_GoodMem/sample_documents/employee_handbook.pdf ``` -------------------------------- ### Get Embedder Go Source: https://docs.goodmem.ai/docs/reference/sdk/go/EmbeddersAPI Retrieve a specific embedder by its ID using this Go example. It includes error handling and prints the embedder details upon successful retrieval. ```go package main import ( "context" "fmt" "os" goodmem_client "github.com/PAIR-Systems-Inc/goodmem/clients/go" ) func main() { id := "550e8400-e29b-41d4-a716-446655440000" // string | The unique identifier of the embedder to retrieve configuration := goodmem_client.NewConfiguration() apiClient := goodmem_client.NewAPIClient(configuration) resp, r, err := apiClient.EmbeddersAPI.GetEmbedder(context.Background(), id).Execute() if err != nil { fmt.Fprintf(os.Stderr, "Error when calling `EmbeddersAPI.GetEmbedder``: %v\n", err) fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) } // response from `GetEmbedder`: EmbedderResponse fmt.Fprintf(os.Stdout, "Response from `EmbeddersAPI.GetEmbedder`: %v\n", resp) } ``` -------------------------------- ### BatchCreateMemory Go SDK Example Source: https://docs.goodmem.ai/docs/reference/sdk/go/MemoriesAPI Demonstrates how to create multiple memories in a batch using the Go SDK. Ensure you have the `goodmem-client` library imported. ```go package main import ( "context" "fmt" "os" goodmem_client "github.com/PAIR-Systems-Inc/goodmem/clients/go" ) func main() { jsonBatchMemoryCreationRequest := *goodmem_client.NewJsonBatchMemoryCreationRequest([]goodmem_client.JsonMemoryCreationRequest{*goodmem_client.NewJsonMemoryCreationRequest("550e8400-e29b-41d4-a716-446655440000", interface{}(123), interface{}(123), "text/plain")}) // JsonBatchMemoryCreationRequest | Batch memory creation details. For application/json requests, each item must provide exactly one of originalContent or originalContentB64. For multipart/form-data, provide a requests part and one file part per request. configuration := goodmem_client.NewConfiguration() apiClient := goodmem_client.NewAPIClient(configuration) resp, r, err := apiClient.MemoriesAPI.BatchCreateMemory(context.Background()).JsonBatchMemoryCreationRequest(jsonBatchMemoryCreationRequest).Execute() if err != nil { fmt.Fprintf(os.Stderr, "Error when calling `MemoriesAPI.BatchCreateMemory``: %v\n", err) fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) } // response from `BatchCreateMemory`: BatchMemoryResponse fmt.Fprintf(os.Stdout, "Response from `MemoriesAPI.BatchCreateMemory`: %v\n", resp) } ``` -------------------------------- ### Filter Spaces by Name Pattern Source: https://docs.goodmem.ai/docs/reference/cli/space/goodmem_space_list Filter spaces by providing a name pattern using glob-style matching. For example, to list all spaces starting with "Project". ```bash goodmem space list --name "Project*" ``` -------------------------------- ### Permanent Gemfury Configuration for Go Source: https://docs.goodmem.ai/docs/reference/sdk/go Add these environment variables to your shell configuration file for a permanent Gemfury proxy setup. This allows for simpler installation commands later. ```bash export GOPROXY="https://go-proxy.fury.io/pairsys/" export GOPRIVATE="github.com/PAIR-Systems-Inc/goodmem" export GOSUMDB=off ``` -------------------------------- ### Initialize System using SystemApi .NET Source: https://docs.goodmem.ai/docs/reference/sdk/dotnet/SystemApi Initialize the system by creating a root user and API key. This endpoint should only be called once during first-time setup. If the system is already initialized, it returns a success response without creating new credentials. An empty object or null can be passed for the body. ```csharp using System.Collections.Generic; using System.Diagnostics; using System.Net.Http; using Pairsystems.Goodmem.Client.Api; using Pairsystems.Goodmem.Client.Client; using Pairsystems.Goodmem.Client.Model; namespace Example { public class InitializeSystemExample { public static void Main() { Configuration config = new Configuration(); config.BasePath = "http://localhost"; // create instances of HttpClient, HttpClientHandler to be reused later with different Api classes HttpClient httpClient = new HttpClient(); HttpClientHandler httpClientHandler = new HttpClientHandler(); var apiInstance = new SystemApi(httpClient, config, httpClientHandler); var body = null; // Object? | Empty request body - no parameters required (optional) try { // Initialize the system SystemInitResponse result = apiInstance.InitializeSystem(body); Debug.WriteLine(result); } catch (ApiException e) { Debug.Print("Exception when calling SystemApi.InitializeSystem: " + e.Message); Debug.Print("Status Code: " + e.ErrorCode); Debug.Print(e.StackTrace); } } } } ``` -------------------------------- ### Get Reranker by ID - Go Source: https://docs.goodmem.ai/docs/reference/sdk/go/RerankersAPI Retrieve a specific reranker by its ID using this Go example. It shows how to initialize the client, make the API request, and handle the response or any errors encountered. ```go package main import ( "context" "fmt" "os" goodmem_client "github.com/PAIR-Systems-Inc/goodmem/clients/go" ) func main() { id := "550e8400-e29b-41d4-a716-446655440000" // string | The unique identifier of the reranker to retrieve configuration := goodmem_client.NewConfiguration() apiClient := goodmem_client.NewAPIClient(configuration) resp, r, err := apiClient.RerankersAPI.GetReranker(context.Background(), id).Execute() if err != nil { fmt.Fprintf(os.Stderr, "Error when calling `RerankersAPI.GetReranker``: %v\n", err) fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) } // response from `GetReranker`: RerankerResponse fmt.Fprintf(os.Stdout, "Response from `RerankersAPI.GetReranker`: %v\n", resp) } ``` -------------------------------- ### Initialize System - Java Source: https://docs.goodmem.ai/docs/reference/sdk/java/SystemApi Call this method to initialize the system by creating a root user and API key. It should only be invoked during the initial setup. If the system is already initialized, it returns a success response without creating new credentials. An empty request body is expected. ```java // Import classes: import ai.pairsys.goodmem.client.ApiClient; import ai.pairsys.goodmem.client.ApiException; import ai.pairsys.goodmem.client.Configuration; import ai.pairsys.goodmem.client.models.*; import ai.pairsys.goodmem.client.api.SystemApi; public class Example { public static void main(String[] args) { ApiClient defaultClient = Configuration.getDefaultApiClient(); defaultClient.setBasePath("http://localhost"); SystemApi apiInstance = new SystemApi(defaultClient); Object body = null; // Object | Empty request body - no parameters required try { SystemInitResponse result = apiInstance.initializeSystem(body); System.out.println(result); } catch (ApiException e) { System.err.println("Exception when calling SystemApi#initializeSystem"); System.err.println("Status code: " + e.getCode()); System.err.println("Reason: " + e.getResponseBody()); System.err.println("Response headers: " + e.getResponseHeaders()); e.printStackTrace(); } } } ``` -------------------------------- ### Retrieve Embedder by ID (cURL) Source: https://docs.goodmem.ai/docs/reference/api-reference/rest/embedders/getEmbedder Use this cURL command to make a GET request to retrieve a specific embedder configuration. Replace the example ID with your target embedder's ID. ```curl curl -X GET "http://localhost:8080/v1/embedders/550e8400-e29b-41d4-a716-446655440000" ``` -------------------------------- ### Validate mkcert TLS Setup Source: https://docs.goodmem.ai/docs/reference/security/use-mkcert Use curl to verify that your GoodMem installation is correctly using the mkcert-generated certificates. This command checks the '/readyz' endpoint using the mkcert root CA. ```bash curl -v --cacert "$(mkcert -CAROOT)/rootCA.pem" https://127.0.0.1:8080/readyz # OR curl -v --cacert "$(mkcert -CAROOT)/rootCA.pem" https://localhost:8080/readyz ``` -------------------------------- ### Get Reranker Java Example Source: https://docs.goodmem.ai/docs/reference/sdk/java/RerankersApi Retrieves details of a specific reranker using its unique identifier. The API client must be initialized with the correct base path. Includes error handling for API exceptions. ```java // Import classes: import ai.pairsys.goodmem.client.ApiClient; import ai.pairsys.goodmem.client.ApiException; import ai.pairsys.goodmem.client.Configuration; import ai.pairsys.goodmem.client.models.*; import ai.pairsys.goodmem.client.api.RerankersApi; public class Example { public static void main(String[] args) { ApiClient defaultClient = Configuration.getDefaultApiClient(); defaultClient.setBasePath("http://localhost"); RerankersApi apiInstance = new RerankersApi(defaultClient); String id = "550e8400-e29b-41d4-a716-446655440000"; // String | The unique identifier of the reranker to retrieve try { RerankerResponse result = apiInstance.getReranker(id); System.out.println(result); } catch (ApiException e) { System.err.println("Exception when calling RerankersApi#getReranker"); System.err.println("Status code: " + e.getCode()); System.err.println("Reason: " + e.getResponseBody()); System.err.println("Response headers: " + e.getResponseHeaders()); e.printStackTrace(); } } } ``` -------------------------------- ### Configure GoodMem Go Client Source: https://docs.goodmem.ai/docs/how-to/basic-rag Create a main.go file and set up the GoodMem client configuration in Go. This includes setting environment variables, parsing the base URL, and configuring the API client and streaming client. ```go package main import ( "context" "encoding/base64" "encoding/json" "fmt" "log" "net/url" "os" "regexp" "strconv" "strings" "unicode/utf8" goodmem "github.com/PAIR-Systems-Inc/goodmem/clients/go" ) // jsonUnescapeUnicode replaces JSON \uXXXX escapes with UTF-8 so printouts show real characters. func jsonUnescapeUnicode(b []byte) []byte { re := regexp.MustCompile(`\\u([0-9a-fA-F]{4})`) return re.ReplaceAllFunc(b, func(m []byte) []byte { code, _ := strconv.ParseInt(string(m[2:]), 16, 32) var buf [utf8.UTFMax]byte n := utf8.EncodeRune(buf[:], rune(code)) return buf[:n] }) } func main() { // Set up variables goodmemBaseURL := os.Getenv("GOODMEM_BASE_URL") goodmemAPIKey := os.Getenv("GOODMEM_API_KEY") openAIAPIKey := os.Getenv("OPENAI_API_KEY") // Create client baseURL := strings.TrimRight(goodmemBaseURL, "/") cfg := goodmem.NewConfiguration() cfg.Servers = goodmem.ServerConfigurations{ {URL: baseURL}, } // Streaming client (e.g. RetrieveMemoryStreamAdvanced) requires Scheme and Host u, err := url.Parse(baseURL) if err != nil { log.Fatal("Invalid GOODMEM_BASE_URL: ", err) } cfg.Scheme = u.Scheme cfg.Host = u.Host cfg.AddDefaultHeader("x-api-key", goodmemAPIKey) client := goodmem.NewAPIClient(cfg) streamClient := goodmem.NewStreamingClient(client) ctx := context.Background() ``` -------------------------------- ### Get User by Email - .NET Source: https://docs.goodmem.ai/docs/reference/sdk/dotnet/UsersApi Retrieve a user's information using their email address. Ensure the email is URL-encoded if it contains special characters. This example demonstrates basic usage and error handling. ```csharp using System.Collections.Generic; using System.Diagnostics; using System.Net.Http; using Pairsystems.Goodmem.Client.Api; using Pairsystems.Goodmem.Client.Client; using Pairsystems.Goodmem.Client.Model; namespace Example { public class GetUserByEmailExample { public static void Main() { Configuration config = new Configuration(); config.BasePath = "http://localhost"; // create instances of HttpClient, HttpClientHandler to be reused later with different Api classes HttpClient httpClient = new HttpClient(); HttpClientHandler httpClientHandler = new HttpClientHandler(); var apiInstance = new UsersApi(httpClient, config, httpClientHandler); var email = user@example.com; // string | The email address of the user to retrieve try { // Get user by email address UserResponse result = apiInstance.GetUserByEmail(email); Debug.WriteLine(result); } catch (ApiException e) { Debug.Print("Exception when calling UsersApi.GetUserByEmail: " + e.Message); Debug.Print("Status Code: " + e.ErrorCode); Debug.Print(e.StackTrace); } } } } ``` -------------------------------- ### Example Retrieved Chunk Metadata Source: https://docs.goodmem.ai/docs/how-to/work-with-pdf-page-images This JSON object shows how page attribution is exposed in chunk metadata when available. It indicates the start and end page indices, and the total count of pages spanned by the chunk. ```json { "metadata": { "source_page_start_index": 4, "source_page_end_index": 5, "source_page_count": 2 } } ``` -------------------------------- ### Get Single Page with Page Size Source: https://docs.goodmem.ai/docs/reference/sdk/python/spaces Retrieves a single page of spaces, controlling the number of items fetched per API call using `page_size`. This example fetches up to 5 items in the first API call. ```python # Get one page. page_size controls how many items the server returns # per API call. Fetches 1 page of up to 5 items. page = client.spaces.list(page_size=5) page.data # [Space, ...] (up to 5) page.next_token # "abc123" or None ``` -------------------------------- ### GetSystemInfo Go SDK Example Source: https://docs.goodmem.ai/docs/reference/sdk/go/SystemAPI Retrieve server build metadata using the GetSystemInfo method. Ensure the Go SDK client is configured and initialized. ```go package main import ( "context" "fmt" "os" goodmem_client "github.com/PAIR-Systems-Inc/goodmem/clients/go" ) func main() { configuration := goodmem_client.NewConfiguration() apiClient := goodmem_client.NewAPIClient(configuration) resp, r, err := apiClient.SystemAPI.GetSystemInfo(context.Background()).Execute() if err != nil { fmt.Fprintf(os.Stderr, "Error when calling `SystemAPI.GetSystemInfo``: %v\n", err) fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) } // response from `GetSystemInfo`: SystemInfoResponse fmt.Fprintf(os.Stdout, "Response from `SystemAPI.GetSystemInfo`: %v\n", resp) } ```