Skip to content

Commit

Permalink
W-16295319: Added java doc for remaining operations (#40)
Browse files Browse the repository at this point in the history
  • Loading branch information
arpitg-1 authored Aug 27, 2024
1 parent 2ca521c commit 34db615
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import org.mule.runtime.extension.api.runtime.operation.Result;

import java.io.InputStream;
import java.io.Serializable;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.HashMap;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import static org.mapdb.Serializer.STRING;

import java.io.InputStream;
import java.io.Serializable;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
Expand Down Expand Up @@ -88,7 +87,7 @@
import org.slf4j.LoggerFactory;

/**
* This class is a container for operations, every public method in this class will be taken as an extension operation.
* This class is a container for embedding related operations, every public method in this class will be taken as an extension operation.
*/
public class LangchainEmbeddingStoresOperations {

Expand Down Expand Up @@ -213,9 +212,14 @@ interface AssistantMemory {
}



/**
* Implements a chat memory for a defined LLM as an AI Agent. The memoryName is allows the multi-channel / profile design.
* Implements a chat memory for a defined LLM as an AI Agent. The memoryName allows the multichannel / profile design.
* @param configuration Refers to the configuration object
* @param data Refers to the user prompt
* @param memoryName Name of the memory to be fetched for further processing by the LLMs
* @param dbFilePath Location of the file containing the memory
* @param maxMessages Max messages to be analyzed for that memory.
* @return Returns the response as sent by the LLM
*/
@MediaType(value = APPLICATION_JSON, strict = false)
@Alias("CHAT-answer-prompt-with-memory")
Expand Down Expand Up @@ -290,9 +294,13 @@ public void deleteMessages(Object memoryId) {
}
}


/**
* (Legacy) Usage of tools by a defined AI Agent. Provide a list of tools (APIs) with all required informations (endpoint, headers, body, method, etc.) to the AI Agent to use it on purpose.
* (Legacy) Usage of tools by a defined AI Agent.<br>
* Provide a list of tools (APIs) with all required information (endpoint, headers, body, method, etc.) to the AI Agent to use it on purpose.
* @param configuration Refers to the configuration object
* @param data Refers to the user prompt or query
* @param toolConfig Contains the configuration required by the LLM to enable calling tools
* @return Returns the response while considering tools configuration
*/
@MediaType(value = APPLICATION_JSON, strict = false)
@Alias("TOOLS-use-ai-service-legacy")
Expand Down Expand Up @@ -400,9 +408,10 @@ private static List<String> extractUrls(String input) {
////////////////////////////////////////////



/**
* Create a new embedding store (in-memory), which is exported to the defined storeName (full path)
* @param storeName Name of the embedding store
* @return Returns the status of creation of the store.
*/
@MediaType(value = APPLICATION_JSON, strict = false)
@Alias("EMBEDDING-new-store")
Expand All @@ -428,9 +437,14 @@ public org.mule.runtime.extension.api.runtime.operation.Result<InputStream, Map<
}



/**
* Add document of type text, pdf and url to embedding store (in-memory), which is exported to the defined storeName (full path)
* Add document of type text, any and url to embedding store (in-memory), which is exported to the defined storeName (full path)
* @param storeName Name of the embedding store
* @param contextPath Refers to the location of the file to be processed
* @param maxSegmentSizeInChars Max allowed size of continuous sequence of characters while embedding
* @param maxOverlapSizeInChars Max size of overlapping characters allowed while embedding
* @param fileType Refers to the type of the file (any, text, url)
* @return Returns the status of the embedding operation
*/
@MediaType(value = APPLICATION_JSON, strict = false)
@Alias("EMBEDDING-add-document-to-store")
Expand Down Expand Up @@ -478,6 +492,12 @@ public org.mule.runtime.extension.api.runtime.operation.Result<InputStream, Map<

/**
* Query information from embedding store (in-Memory), which is imported from the storeName (full path)
* @param storeName Name of the embedding store
* @param question Refers to the user prompt or query
* @param maxResults Max results to be retrieved from the store
* @param minScore Filters the response with this minScore
* @param getLatest Determines whether the store needs to be newly created or not
* @return Returns the relevant embeddings with the attached sources
*/
@MediaType(value = APPLICATION_JSON, strict = false)
@Alias("EMBEDDING-query-from-store")
Expand Down Expand Up @@ -548,6 +568,11 @@ public org.mule.runtime.extension.api.runtime.operation.Result<InputStream, Map<

/**
* Reads information via prompt from embedding store (in-Memory), which is imported from the storeName (full path)
* @param configuration Refers to the configuration object
* @param data Refers to the user prompt or query
* @param storeName Name of the store to be queried
* @param getLatest Determines whether the store needs to be newly created or not
* @return Returns the embeddings output by the LLM along with the sources
*/
@MediaType(value = APPLICATION_JSON, strict = false)
@Alias("EMBEDDING-get-info-from-store")
Expand Down Expand Up @@ -618,6 +643,11 @@ interface AssistantSources {

/**
* Reads information via prompt from embedding store (in-Memory), which is imported from the storeName (full path)
* @param configuration Refers to the configuration object
* @param data Refers to the user prompt or query
* @param storeName Name of the store to be queried
* @param getLatest Determines whether the store needs to be newly created or not
* @return Returns the embeddings output by the LLM along with the sources
*/
@MediaType(value = APPLICATION_JSON, strict = false)
@Alias("EMBEDDING-get-info-from-store-legacy")
Expand Down Expand Up @@ -662,8 +692,13 @@ interface AssistantEmbedding {


/**
* (AI Services) Usage of tools by a defined AI Agent. Provide a list of tools (APIs) with all required informations (endpoint, headers, body, method, etc.) to the AI Agent to use it on purpose.
*/
* (AI Services) Usage of tools by a defined AI Agent.<br>
* Provide a list of tools (APIs) with all required information (endpoint, headers, body, method, etc.) to the AI Agent to use it on purpose.
* @param configuration Refers to the configuration object
* @param data Refers to the user prompt or query
* @param toolConfig Contains the configuration required by the LLM to enable calling tools
* @return Returns the response while considering tools configuration
*/
@MediaType(value = APPLICATION_JSON, strict = false)
@Alias("TOOLS-use-ai-service")
@Throws(EmbeddingErrorTypeProvider.class)
Expand Down Expand Up @@ -728,8 +763,14 @@ public org.mule.runtime.extension.api.runtime.operation.Result<InputStream, Map<


/**
* Add document of type text, pdf and url to embedding store (in-memory), which is exported to the defined storeName (full path)
*/
* Add document of type text, any and url to embedding store (in-memory), which is exported to the defined storeName (full path)
* @param storeName Name of the embedding store
* @param contextPath Refers to the location of the folder to be processed
* @param maxSegmentSizeInChars Max allowed size of continuous sequence of characters while embedding
* @param maxOverlapSizeInChars Max size of overlapping characters allowed while embedding
* @param fileType Refers to the type of the file (any, text) - url is not supported
* @return Returns the status of the embedding operation
*/
@MediaType(value = APPLICATION_JSON, strict = false)
@Alias("EMBEDDING-add-folder-to-store")
@Throws(EmbeddingErrorTypeProvider.class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,19 @@


/**
* This class is a container for operations, every public method in this class will be taken as an extension operation.
* This class is a container for Image related operations.Every public method in this class will be taken as an extension operation.
*/
public class LangchainImageModelsOperations {

private static final Logger LOGGER = LoggerFactory.getLogger(LangchainImageModelsOperations.class);

/**
* Reads an image from a URL.
* Reads an image from a URL and provides the responses for the user prompts.
*
* @param configuration Refers to the configuration object
* @param data Refers to the user prompt
* @param contextURL Refers to the image URL to be analyzed
* @return Refers to the response returned by the LLM
*/
@MediaType(value = APPLICATION_JSON, strict = false)
@Alias("IMAGE-read")
Expand Down Expand Up @@ -98,6 +103,9 @@ public org.mule.runtime.extension.api.runtime.operation.Result<InputStream, LLMR

/**
* Generates an image based on the prompt in data
* @param configuration Refers to the configuration object
* @param data Refers to the user prompt
* @return Returns the image URL link in the response
*/
@MediaType(value = APPLICATION_JSON, strict = false)
@Alias("IMAGE-generate")
Expand Down Expand Up @@ -130,7 +138,11 @@ public org.mule.runtime.extension.api.runtime.operation.Result<InputStream, Void
}

/**
* Reads a scanned document.
* Reads scanned documents and converts to response as prompted by the user.
* @param configuration Refers to the configuration object
* @param data Refers to the user prompt
* @param filePath Path to the file to be analyzed
* @return Returns the list of analyzed pages of the document
*/
@MediaType(value = APPLICATION_JSON, strict = false)
@Alias("IMAGE-read-scanned-documents")
Expand Down

0 comments on commit 34db615

Please sign in to comment.