diff --git a/azure-toolkit-libs/azure-toolkit-appservice-lib/src/main/resources/bindings.json b/azure-toolkit-libs/azure-toolkit-appservice-lib/src/main/resources/bindings.json index 73d3f3d9b..1b246d86c 100644 --- a/azure-toolkit-libs/azure-toolkit-appservice-lib/src/main/resources/bindings.json +++ b/azure-toolkit-libs/azure-toolkit-appservice-lib/src/main/resources/bindings.json @@ -609,6 +609,447 @@ "settings": [ ] + }, + { + "type": "assistantSkillTrigger", + "displayName": "$assistantSkillTrigger_displayName", + "direction": "trigger", + "enabledInTryMode": true, + "settings": [ + { + "name": "name", + "value": "string", + "defaultValue": "skillTrigger", + "required": true, + "label": "$assistantSkillTrigger_name_label", + "help": "$assistantSkillTrigger_name_help", + "validators": [ + { + "expression": "^[a-zA-Z][a-zA-Z0-9]{0,127}$", + "errorText": "$assistantSkillTrigger_name_errorText" + } + ] + }, + { + "name": "functionDescription", + "value": "string", + "required": true, + "label": "$assistantSkillTrigger_functionDescription_label", + "help": "$assistantSkillTrigger_functionDescription_help" + }, + { + "name": "parameterDescriptionJson", + "value": "string", + "defaultValue": "", + "required": false, + "label": "$assistantSkillTrigger_parameterDescriptionJson_label", + "help": "$assistantSkillTrigger_parameterDescriptionJson_help" + }, + { + "name": "model", + "value": "string", + "defaultValue": "gpt-3.5-turbo", + "required": false, + "label": "$assistantSkillTrigger_model_label", + "help": "$assistantSkillTrigger_model_help" + } + ] + }, + { + "type": "assistantCreate", + "displayName": "$assistantCreate_displayName", + "direction": "out", + "enabledInTryMode": true, + "settings": [ + { + "name": "name", + "value": "string", + "defaultValue": "assistant1", + "required": true, + "label": "$assistantCreate_name_label", + "help": "$assistantCreate_name_help", + "validators": [ + { + "expression": "^[a-zA-Z][a-zA-Z0-9]{0,127}$", + "errorText": "$assistantCreate_name_errorText" + } + ] + } + ] + }, + { + "type": "assistantPost", + "displayName": "$assistantPost_displayName", + "direction": "in", + "enabledInTryMode": true, + "settings": [ + { + "name": "id", + "value": "string", + "required": true, + "label": "$assistantPost_id_label", + "help": "$assistantPost_id_help" + }, + { + "name": "model", + "value": "string", + "required": true, + "label": "$assistantPost_model_label", + "help": "$assistantPost_model_help" + }, + { + "name": "userMessage", + "value": "string", + "required": true, + "label": "$assistantPost_userMessage_label", + "help": "$assistantPost_userMessage_help" + }, + { + "name": "chatStorageConnectionSetting", + "value": "string", + "defaultValue": "AzureWebJobsStorage", + "required": false, + "label": "$assistantPost_chatStorageConnectionSetting_label", + "help": "$assistantPost_chatStorageConnectionSetting_help" + }, + { + "name": "collectionName", + "value": "string", + "defaultValue": "ChatState", + "required": false, + "label": "$assistantPost_collectionName_label", + "help": "$assistantPost_collectionName_help" + }, + { + "name": "name", + "value": "string", + "defaultValue": "post", + "required": true, + "label": "$assistantPost_name_label", + "help": "$assistantPost_name_help", + "validators": [ + { + "expression": "^[a-zA-Z][a-zA-Z0-9]{0,127}$", + "errorText": "$assistantPost_name_errorText" + } + ] + } + ] + }, + { + "type": "assistantQuery", + "displayName": "$assistantQuery_displayName", + "direction": "in", + "enabledInTryMode": true, + "settings": [ + { + "name": "id", + "value": "string", + "required": true, + "label": "$assistantQuery_id_label", + "help": "$assistantQuery_id_help" + }, + { + "name": "timestampUtc", + "value": "string", + "required": true, + "label": "$assistantQuery_timestampUtc_label", + "help": "$assistantQuery_timestampUtc_help" + }, + { + "name": "chatStorageConnectionSetting", + "value": "string", + "defaultValue": "AzureWebJobsStorage", + "required": false, + "label": "$assistantQuery_chatStorageConnectionSetting_label", + "help": "$assistantQuery_chatStorageConnectionSetting_help" + }, + { + "name": "collectionName", + "value": "string", + "defaultValue": "ChatState", + "required": false, + "label": "$assistantQuery_collectionName_label", + "help": "$assistantQuery_collectionName_help" + }, + { + "name": "name", + "value": "string", + "defaultValue": "query", + "required": true, + "label": "$assistantQuery_name_label", + "help": "$assistantQuery_name_help", + "validators": [ + { + "expression": "^[a-zA-Z][a-zA-Z0-9]{0,127}$", + "errorText": "$assistantQuery_name_errorText" + } + ] + } + ] + }, + { + "type": "embeddings", + "displayName": "$embeddings_displayName", + "direction": "in", + "enabledInTryMode": true, + "settings": [ + { + "name": "model", + "value": "string", + "defaultValue": "text-embedding-ada-002", + "required": false, + "label": "$embeddings_model_label", + "help": "$embeddings_model_help" + }, + { + "name": "maxChunkLength", + "value": "int", + "defaultValue": 8192, + "required": false, + "label": "$embeddings_maxChunkLength_label", + "help": "$embeddings_maxChunkLength_help" + }, + { + "name": "maxOverlap", + "value": "int", + "defaultValue": 128, + "required": false, + "label": "$embeddings_maxOverlap_label", + "help": "$embeddings_maxOverlap_help" + }, + { + "name": "input", + "value": "string", + "required": true, + "label": "$embeddings_input_label", + "help": "$embeddings_input_help" + }, + { + "name": "inputType", + "value": "enum", + "required": true, + "label": "$embeddings_inputType_label", + "help": "$embeddings_inputType_help" + }, + { + "name": "name", + "value": "string", + "defaultValue": "embeddings", + "required": true, + "label": "$embeddings_name_label", + "help": "$embeddings_name_help", + "validators": [ + { + "expression": "^[a-zA-Z][a-zA-Z0-9]{0,127}$", + "errorText": "$embeddings_name_errorText" + } + ] + } + ] + }, + { + "type": "embeddingsStore", + "displayName": "$embeddingsStore_displayName", + "direction": "out", + "enabledInTryMode": true, + "settings": [ + { + "name": "model", + "value": "string", + "defaultValue": "text-embedding-ada-002", + "required": false, + "label": "$embeddingsStore_model_label", + "help": "$embeddingsStore_model_help" + }, + { + "name": "maxChunkLength", + "value": "int", + "defaultValue": 8192, + "required": false, + "label": "$embeddingsStore_maxChunkLength_label", + "help": "$embeddingsStore_maxChunkLength_help" + }, + { + "name": "maxOverlap", + "value": "int", + "defaultValue": 128, + "required": false, + "label": "$embeddingsStore_maxOverlap_label", + "help": "$embeddingsStore_maxOverlap_help" + }, + { + "name": "input", + "value": "string", + "required": true, + "label": "$embeddingsStore_input_label", + "help": "$embeddingsStore_input_help" + }, + { + "name": "inputType", + "value": "enum", + "required": true, + "label": "$embeddingsStore_inputType_label", + "help": "$embeddingsStore_inputType_help" + }, + { + "name": "connectionName", + "value": "string", + "required": true, + "label": "$embeddingsStore_connectionName_label", + "help": "$embeddingsStore_connectionName_help" + }, + { + "name": "collection", + "value": "string", + "required": true, + "label": "$embeddingsStore_collection_label", + "help": "$embeddingsStore_collection_help" + }, + { + "name": "name", + "value": "string", + "defaultValue": "embeddingsStore", + "required": true, + "label": "$embeddingsStore_name_label", + "help": "$embeddingsStore_name_help", + "validators": [ + { + "expression": "^[a-zA-Z][a-zA-Z0-9]{0,127}$", + "errorText": "$embeddingsStore_name_errorText" + } + ] + } + ] + }, + { + "type": "semanticSearch", + "displayName": "$semanticSearch_displayName", + "direction": "in", + "enabledInTryMode": true, + "settings": [ + { + "name": "connectionName", + "value": "string", + "required": true, + "label": "$semanticSearch_connectionName_label", + "help": "$semanticSearch_connectionName_help" + }, + { + "name": "collection", + "value": "string", + "required": true, + "label": "$semanticSearch_collection_label", + "help": "$semanticSearch_collection_help" + }, + { + "name": "query", + "value": "string", + "defaultValue": "", + "required": false, + "label": "$semanticSearch_query_label", + "help": "$semanticSearch_query_help" + }, + { + "name": "embeddingsModel", + "value": "string", + "defaultValue": "text-embedding-ada-002", + "required": false, + "label": "$semanticSearch_embeddingsModel_label", + "help": "$semanticSearch_embeddingsModel_help" + }, + { + "name": "chatModel", + "value": "string", + "defaultValue": "gpt-3.5-turbo", + "required": false, + "label": "$semanticSearch_chatModel_label", + "help": "$semanticSearch_chatModel_help" + }, + { + "name": "systemPrompt", + "value": "string", + "defaultValue": "You are a helpful assistant. You are responding to requests from a user about internal emails and documents.\nYou can and should refer to the internal documents to help respond to requests. If a user makes a request that's\nnot covered by the internal emails and documents, explain that you don't know the answer or that you don't have\naccess to the information.\n\nThe following is a list of documents that you can refer to when answering questions. The documents are in the format\n[filename]: [text] and are separated by newlines. If you answer a question by referencing any of the documents,\nplease cite the document in your answer. For example, if you answer a question by referencing info.txt,\nyou should add \"Reference: info.txt\" to the end of your answer on a separate line.", + "required": false, + "label": "$semanticSearch_systemPrompt_label", + "help": "$semanticSearch_systemPrompt_help" + }, + { + "name": "maxKnowledgeLength", + "value": "int", + "defaultValue": 1, + "required": false, + "label": "$semanticSearch_maxKnowledgeLength_label", + "help": "$semanticSearch_maxKnowledgeLength_help" + }, + { + "name": "name", + "value": "string", + "defaultValue": "semanticSearch", + "required": true, + "label": "$semanticSearch_name_label", + "help": "$semanticSearch_name_help", + "validators": [ + { + "expression": "^[a-zA-Z][a-zA-Z0-9]{0,127}$", + "errorText": "$semanticSearch_name_errorText" + } + ] + } + ] + }, + { + "type": "textCompletion", + "displayName": "$textCompletion_displayName", + "direction": "in", + "enabledInTryMode": true, + "settings": [ + { + "name": "prompt", + "value": "string", + "required": true, + "label": "$textCompletion_prompt_label", + "help": "$textCompletion_prompt_help" + }, + { + "name": "model", + "value": "string", + "defaultValue": "gpt-3.5-turbo", + "required": false, + "label": "$textCompletion_model_label", + "help": "$textCompletion_model_help" + }, + { + "name": "temperature", + "value": "string", + "defaultValue": "0.5", + "required": false, + "label": "$textCompletion_temperature_label", + "help": "$textCompletion_temperature_help" + }, + { + "name": "topP", + "value": "string", + "defaultValue": "", + "required": false, + "label": "$textCompletion_topP_label", + "help": "$textCompletion_topP_help" + }, + { + "name": "name", + "value": "string", + "defaultValue": "textCompletion", + "required": true, + "label": "$textCompletion_name_label", + "help": "$textCompletion_name_help", + "validators": [ + { + "expression": "^[a-zA-Z][a-zA-Z0-9]{0,127}$", + "errorText": "$textCompletion_name_errorText" + } + ] + } + ] } ] } diff --git a/azure-toolkit-libs/azure-toolkit-appservice-lib/src/main/resources/resources.json b/azure-toolkit-libs/azure-toolkit-appservice-lib/src/main/resources/resources.json index 91584d262..5eb5d810f 100644 --- a/azure-toolkit-libs/azure-toolkit-appservice-lib/src/main/resources/resources.json +++ b/azure-toolkit-libs/azure-toolkit-appservice-lib/src/main/resources/resources.json @@ -116,6 +116,116 @@ "daprServiceInvocationTrigger_description": "Using Dapr Service Invocation Trigger, your azure functions can reliably and securely communicate with other applications using the standard HTTP protocol.", "daprServiceInvocationTrigger_displayName": "Dapr service invocation trigger", "daprTopicTrigger_description": "Using Dapr Topic Trigger, your azure functions can react to a message published on a Topic mentioned in your function.", - "daprTopicTrigger_displayName": "Dapr topic trigger" + "daprTopicTrigger_displayName": "Dapr topic trigger", + + "assistantSkillTrigger_displayName": "Assistant Skill Trigger", + "assistantSkillTrigger_name_label": "Trigger binding name", + "assistantSkillTrigger_name_help": "Name used to identify trigger in code", + "assistantSkillTrigger_name_errorText": "The name must start with a letter, and it can contain only letters and numbers. The name must be 1 to 127 characters.", + "assistantSkillTrigger_functionDescription_label": "Function Description", + "assistantSkillTrigger_functionDescription_help": "Description of the function to be triggered.", + "assistantSkillTrigger_parameterDescriptionJson_label": "Parameter Description JSON", + "assistantSkillTrigger_parameterDescriptionJson_help": "JSON string describing the parameters.", + "assistantSkillTrigger_model_label": "Model", + "assistantSkillTrigger_model_help": "The OpenAI chat model to use.", + + "assistantCreate_displayName": "Assistant Create", + "assistantCreate_name_label": "Trigger binding name", + "assistantCreate_name_help": "Name used to identify trigger in code", + "assistantCreate_name_errorText": "The name must start with a letter, and it can contain only letters and numbers. The name must be 1 to 127 characters.", + + "assistantQuery_displayName": "Assistant Query", + "assistantQuery_id_label": "ID", + "assistantQuery_id_help": "The ID of the Assistant to query.", + "assistantQuery_timestampUtc_label": "Timestamp UTC", + "assistantQuery_timestampUtc_help": "The timestamp of the earliest message in the chat history to fetch.", + "assistantQuery_chatStorageConnectionSetting_label": "Chat Storage Connection Setting", + "assistantQuery_chatStorageConnectionSetting_help": "The configuration section name for the table settings for assistant chat storage.", + "assistantQuery_collectionName_label": "Collection Name", + "assistantQuery_collectionName_help": "The table collection name for assistant chat storage.", + "assistantQuery_name_label": "Trigger binding name", + "assistantQuery_name_help": "Name used to identify trigger in code", + "assistantQuery_name_errorText": "The name must start with a letter, and it can contain only letters and numbers. The name must be 1 to 127 characters.", + + "assistantPost_displayName": "Assistant Post", + "assistantPost_id_label": "ID", + "assistantPost_id_help": "The ID of the Assistant to query.", + "assistantPost_model_label": "Model", + "assistantPost_model_help": "The OpenAI chat model to use.", + "assistantPost_userMessage_label": "User Message", + "assistantPost_userMessage_help": "The user message that user has entered for assistant to respond to.", + "assistantPost_chatStorageConnectionSetting_label": "Chat Storage Connection Setting", + "assistantPost_chatStorageConnectionSetting_help": "The configuration section name for the table settings for assistant chat storage.", + "assistantPost_collectionName_label": "Collection Name", + "assistantPost_collectionName_help": "The table collection name for assistant chat storage.", + "assistantPost_name_label": "Trigger binding name", + "assistantPost_name_help": "Name used to identify trigger in code", + "assistantPost_name_errorText": "The name must start with a letter, and it can contain only letters and numbers. The name must be 1 to 127 characters.", + + "embeddings_displayName": "Embeddings Input", + "embeddings_model_label": "Model", + "embeddings_model_help": "The ID of the model to use.", + "embeddings_maxChunkLength_label": "Max Chunk Length", + "embeddings_maxChunkLength_help": "The maximum number of characters to chunk the input into.", + "embeddings_maxOverlap_label": "Max Overlap", + "embeddings_maxOverlap_help": "The maximum number of characters to overlap between chunks.", + "embeddings_input_label": "Input", + "embeddings_input_help": "The input string to generate embeddings for.", + "embeddings_inputType_label": "Input Type", + "embeddings_inputType_help": "The input type.", + "embeddings_name_label": "Trigger binding name", + "embeddings_name_help": "Name used to identify trigger in code", + "embeddings_name_errorText": "The name must start with a letter, and it can contain only letters and numbers. The name must be 1 to 127 characters.", + + "embeddingsStore_displayName": "Embeddings Store Output", + "embeddingsStore_model_label": "Model", + "embeddingsStore_model_help": "The ID of the model to use.", + "embeddingsStore_maxChunkLength_label": "Max Chunk Length", + "embeddingsStore_maxChunkLength_help": "The maximum number of characters to chunk the input into.", + "embeddingsStore_maxOverlap_label": "Max Overlap", + "embeddingsStore_maxOverlap_help": "The maximum number of characters to overlap between chunks.", + "embeddingsStore_input_label": "Input", + "embeddingsStore_input_help": "The input string to generate embeddings for.", + "embeddingsStore_inputType_label": "Input Type", + "embeddingsStore_inputType_help": "The input type.", + "embeddingsStore_connectionName_label": "Connection Name - AI Search Endpoint", + "embeddingsStore_connectionName_help": "The name of an app setting or environment variable which contains a connection string value for an AI Search endpoint.", + "embeddingsStore_collection_label": "Collection", + "embeddingsStore_collection_help": "The name of the collection or table to search.", + "embeddingsStore_name_label": "Trigger binding name", + "embeddingsStore_name_help": "Name used to identify trigger in code", + "embeddingsStore_name_errorText": "The name must start with a letter, and it can contain only letters and numbers. The name must be 1 to 127 characters.", + + "semanticSearch_displayName": "Semantic Search", + "semanticSearch_connectionName_label": "Connection Name - AI Search Endpoint", + "semanticSearch_connectionName_help": "The name of an app setting or environment variable which contains a connection string for an AI Search endpoint.", + "semanticSearch_collection_label": "Collection", + "semanticSearch_collection_help": "The name of the collection or table to search.", + "semanticSearch_query_label": "Query", + "semanticSearch_query_help": "The semantic query text to use for searching.", + "semanticSearch_embeddingsModel_label": "Embeddings Model", + "semanticSearch_embeddingsModel_help": "The model to use for embeddings.", + "semanticSearch_chatModel_label": "Chat Model", + "semanticSearch_chatModel_help": "The name of the Large Language Model to invoke for chat responses.", + "semanticSearch_systemPrompt_label": "System Prompt", + "semanticSearch_systemPrompt_help": "The system prompt to use for prompting the large language model.", + "semanticSearch_maxKnowledgeLength_label": "Max Knowledge Length", + "semanticSearch_maxKnowledgeLength_help": "The number of knowledge items to inject into the systemPrompt.", + "semanticSearch_name_label": "Trigger binding name", + "semanticSearch_name_help": "Name used to identify trigger in code", + "semanticSearch_name_errorText": "The name must start with a letter, and it can contain only letters and numbers. The name must be 1 to 127 characters.", + + "textCompletion_displayName": "Text Completion", + "textCompletion_prompt_label": "Prompt", + "textCompletion_prompt_help": "The prompt to generate completions for, encoded as a string.", + "textCompletion_model_label": "Model", + "textCompletion_model_help": "The ID of the model to use.", + "textCompletion_temperature_label": "Temperature", + "textCompletion_temperature_help": "The sampling temperature to use, between 0 and 2.", + "textCompletion_topP_label": "Top P", + "textCompletion_topP_help": "The top_p probability mass to consider.", + "textCompletion_name_label": "Trigger binding name", + "textCompletion_name_help": "Name used to identify trigger in code", + "textCompletion_name_errorText": "The name must start with a letter, and it can contain only letters and numbers. The name must be 1 to 127 characters." } } diff --git a/azure-toolkit-libs/azure-toolkit-appservice-lib/src/main/resources/templates.json b/azure-toolkit-libs/azure-toolkit-appservice-lib/src/main/resources/templates.json index b2a473d4f..18bb3ca32 100644 --- a/azure-toolkit-libs/azure-toolkit-appservice-lib/src/main/resources/templates.json +++ b/azure-toolkit-libs/azure-toolkit-appservice-lib/src/main/resources/templates.json @@ -600,6 +600,248 @@ "files": { "function.java": "package $packageName$;\r\n\r\nimport com.fasterxml.jackson.core.JsonProcessingException;\r\nimport com.fasterxml.jackson.databind.JsonNode;\r\nimport com.fasterxml.jackson.databind.ObjectMapper;\r\nimport com.microsoft.azure.functions.ExecutionContext;\r\nimport com.microsoft.azure.functions.OutputBinding;\r\nimport com.microsoft.azure.functions.annotation.FunctionName;\r\nimport com.microsoft.azure.functions.dapr.annotation.DaprStateOutput;\r\nimport com.microsoft.azure.functions.dapr.annotation.DaprTopicTrigger;\r\n\r\n\r\npublic class $className$ {\r\n\r\n \/*\r\n Visit https:\/\/aka.ms\/azure-functions-dapr to learn how to use the Dapr extension.\r\n These tasks should be completed prior to running :\r\n 1. Install Dapr\r\n 2. Change the bundle name in host.json to \"Microsoft.Azure.Functions.ExtensionBundle.Preview\" and the version to \"[4.*, 5.0.0)\"\r\n Start function app with Dapr: dapr run --app-id functionapp --app-port 3001 --dapr-http-port 3501 -- mvn azure-functions:run\r\n Invoke function app in cmd promt: dapr publish --pubsub pubsub --publish-app-id functionapp --topic Q --data '{\\\"value\\\": { \\\"orderId\\\": \\\"42\\\" } }'\r\n *\/\r\n @FunctionName(\"DaprTopicTriggerFunc\")\r\n public String run(\r\n @DaprTopicTrigger(\r\n pubSubName = \"pubsub\",\r\n topic = \"Q\")\r\n String request,\r\n @DaprStateOutput(\r\n stateStore = \"statestore\",\r\n key = \"product\")\r\n OutputBinding product,\r\n final ExecutionContext context) throws JsonProcessingException {\r\n context.getLogger().info(\"Java DaprTopic trigger with DaprState output binding function processed a request from the Dapr Runtime.\");\r\n\r\n \/\/ Get the CloudEvent data from the request body as a JSON string\r\n ObjectMapper objectMapper = new ObjectMapper();\r\n JsonNode jsonNode = objectMapper.readTree(request).get(\"data\");\r\n String serializedJson = objectMapper.writeValueAsString(jsonNode);\r\n product.setValue(serializedJson);\r\n\r\n return serializedJson;\r\n }\r\n}" } + }, + { + "id": "AssistantSkillTrigger-Java", + "metadata": { + "name": "AssistantSkillTrigger", + "description": "$AssistantSkillTrigger_description", + "defaultFunctionName": "assistantSkillTriggerJava", + "language": "Java", + "userPrompt": [ + "name", + "functionDescription", + "parameterDescriptionJson", + "model" + ] + }, + "bundle": ["~4"], + "function": { + "disabled": false, + "bindings": [ + { + "type": "assistantSkillTrigger", + "name": "taskDescription", + "direction": "in", + "functionDescription": "Create a new todo task", + "parameterDescriptionJson": "{}", + "model": "gpt-3.5-turbo" + } + ] + }, + "files": { + "function.java": "package $packageName$;\n\n/**\n * Visit https://learn.microsoft.com/en-us/azure/azure-functions/functions-bindings-openai?tabs=isolated-process&pivots=programming-language-java\n * to learn how to use this binding.\n * \n * These tasks should be completed prior to running:\n * 1. Add com.microsoft.azure.functions:azure-functions-java-library-openai to your project dependencies.\n * 2. Add app settings appropriate for connecting to azure/non-azure openai following\n * https://learn.microsoft.com/en-us/azure/azure-functions/functions-bindings-openai?tabs=isolated-process&pivots=programming-language-java#application-settings\n * 3. Change the bundle name in host.json to \"Microsoft.Azure.Functions.ExtensionBundle.Preview\" and the \n * version to \"[4.*, 5.0.0)\"\n */\n\nimport com.microsoft.azure.functions.annotation.*;\nimport com.microsoft.azure.functions.openai.annotation.assistant.AssistantSkillTrigger;\nimport com.microsoft.azure.functions.*;\n\nimport java.util.*;\nimport java.util.concurrent.CopyOnWriteArrayList;\n\npublic class $className$ {\n\n // In-memory list to store todo items\n private static final List todoList = new CopyOnWriteArrayList<>();\n\n @FunctionName(\"$functionName$\")\n public void addTodo(\n @AssistantSkillTrigger(\n name = \"$name$\",\n functionDescription = \"$functionDescription$\",\n parameterDescriptionJson = \"$parameterDescriptionJson$\",\n model = \"$model$\"\n ) String taskDescription,\n final ExecutionContext context) {\n\n if (taskDescription == null || taskDescription.isEmpty()) {\n throw new IllegalArgumentException(\"Task description cannot be empty\");\n }\n\n context.getLogger().info(\"Adding todo: \" + taskDescription);\n\n // Generate a random ID for the todo item\n String todoId = UUID.randomUUID().toString().substring(0, 6);\n\n // Create a new TodoItem and add it to the in-memory list\n TodoItem todoItem = new TodoItem(todoId, taskDescription);\n todoList.add(todoItem);\n\n context.getLogger().info(\"Todo added with ID: \" + todoId);\n }\n\n // Simple TodoItem class\n static class TodoItem {\n private String id;\n private String description;\n\n public TodoItem(String id, String description) {\n this.id = id;\n this.description = description;\n }\n\n public String getId() {\n return id;\n }\n\n public String getDescription() {\n return description;\n }\n }\n}\n" + } + }, + { + "id": "AssistantCreate-Java", + "metadata": { + "name": "AssistantCreate", + "description": "$AssistantCreate_description", + "defaultFunctionName": "assistantCreateJava", + "language": "Java", + "userPrompt": [ + "name" + ] + }, + "bundle": ["~4"], + "function": { + "disabled": false, + "bindings": [ + { + "type": "assistantCreate", + "name": "message", + "direction": "out" + } + ] + }, + "files": { + "function.java": "package $packageName$;\n\n/**\n * Visit https://learn.microsoft.com/en-us/azure/azure-functions/functions-bindings-openai?tabs=isolated-process&pivots=programming-language-java\n * to learn how to use this binding.\n * \n * These tasks should be completed prior to running:\n * 1. Add com.microsoft.azure.functions:azure-functions-java-library-openai to your project dependencies.\n * 2. Add app settings appropriate for connecting to azure/non-azure openai following\n * https://learn.microsoft.com/en-us/azure/azure-functions/functions-bindings-openai?tabs=isolated-process&pivots=programming-language-java#application-settings\n * 3. Change the bundle name in host.json to \"Microsoft.Azure.Functions.ExtensionBundle.Preview\" and the \n * version to \"[4.*, 5.0.0)\"\n */\n\nimport com.microsoft.azure.functions.annotation.*;\nimport com.microsoft.azure.functions.*;\nimport com.microsoft.azure.functions.openai.annotation.assistant.AssistantCreate;\nimport com.microsoft.azure.functions.openai.annotation.assistant.AssistantCreateRequest;\n\nimport java.util.Optional;\n\npublic class $className$ {\n\n @FunctionName(\"$functionName$\")\n public HttpResponseMessage createAssistant(\n @HttpTrigger(\n name = \"req\", \n methods = {HttpMethod.PUT},\n authLevel = AuthorizationLevel.ANONYMOUS, \n route = \"assistants/{chatId}\") \n HttpRequestMessage> request,\n @BindingName(\"chatId\") String chatId,\n @AssistantCreate(name = \"$name$\") OutputBinding message,\n final ExecutionContext context) {\n \n if (request.getBody() == null) {\n return request.createResponseBuilder(HttpStatus.BAD_REQUEST)\n .body(\"Invalid request body. Make sure that you pass in {\\\"instructions\\\": value } as the request body.\")\n .build();\n }\n \n AssistantCreateRequest assistantCreateRequest = new AssistantCreateRequest(chatId, request.getBody().get().getInstructions());\n message.setValue(assistantCreateRequest);\n \n return request.createResponseBuilder(HttpStatus.ACCEPTED)\n .header(\"Content-Type\", \"application/json\")\n .body(String.format(\"{{\\\"chatId\\\": \\\"%s\\\"}}\", chatId))\n .build();\n }\n\n public static class CreateRequest {\n private String instructions;\n \n public String getInstructions() {\n return instructions;\n }\n \n public void setInstructions(String instructions) {\n this.instructions = instructions;\n }\n }\n}\n" + } + }, + { + "id": "AssistantQuery-Java", + "metadata": { + "name": "AssistantQuery", + "description": "$AssistantQuery_description", + "defaultFunctionName": "assistantQueryJava", + "language": "Java", + "userPrompt": [ + "name" + ] + }, + "bundle": ["~4"], + "function": { + "disabled": false, + "bindings": [ + { + "type": "assistantQuery", + "name": "state", + "direction": "in", + "id": "{chatId}", + "timestampUtc": "{Query.timestampUTC}" + } + ] + }, + "files": { + "function.java": "package $packageName$;\n\n/**\n * Visit https://learn.microsoft.com/en-us/azure/azure-functions/functions-bindings-openai?tabs=isolated-process&pivots=programming-language-java\n * to learn how to use this binding.\n * \n * These tasks should be completed prior to running:\n * 1. Add com.microsoft.azure.functions:azure-functions-java-library-openai to your project dependencies.\n * 2. Add app settings appropriate for connecting to azure/non-azure openai following\n * https://learn.microsoft.com/en-us/azure/azure-functions/functions-bindings-openai?tabs=isolated-process&pivots=programming-language-java#application-settings\n * 3. Change the bundle name in host.json to \"Microsoft.Azure.Functions.ExtensionBundle.Preview\" and the \n * version to \"[4.*, 5.0.0)\"\n */\n\nimport com.microsoft.azure.functions.annotation.*;\nimport com.microsoft.azure.functions.*;\nimport com.microsoft.azure.functions.openai.annotation.assistant.AssistantQuery;\nimport com.microsoft.azure.functions.openai.annotation.assistant.AssistantState;\n\nimport java.util.Optional;\n\npublic class $className$ {\n\n @FunctionName(\"$functionName$\")\n public HttpResponseMessage getChatState(\n @HttpTrigger(\n name = \"req\",\n methods = {HttpMethod.GET}, \n authLevel = AuthorizationLevel.ANONYMOUS,\n route = \"assistants/{chatId}\") \n HttpRequestMessage> request,\n @BindingName(\"chatId\") String chatId, \n @AssistantQuery(name = \"$name$\", id = \"{chatId}\", timestampUtc = \"{Query.timestampUTC}\") AssistantState state,\n final ExecutionContext context) {\n return request.createResponseBuilder(HttpStatus.OK)\n .header(\"Content-Type\", \"application/json\")\n .body(state)\n .build();\n }\n}\n" + } + }, + { + "id": "AssistantPost-Java", + "metadata": { + "name": "AssistantPost", + "description": "$AssistantPost_description", + "defaultFunctionName": "assistantPostJava", + "language": "Java", + "userPrompt": [ + "name", + "model" + ] + }, + "bundle": ["~4"], + "function": { + "disabled": false, + "bindings": [ + { + "type": "assistantPost", + "name": "state", + "direction": "in", + "id": "{chatId}", + "model": "%CHAT_MODEL_DEPLOYMENT_NAME%", + "userMessage": "{Query.message}" + } + ] + }, + "files": { + "function.java": "package $packageName$;\n\n/**\n * Visit https://learn.microsoft.com/en-us/azure/azure-functions/functions-bindings-openai?tabs=isolated-process&pivots=programming-language-java\n * to learn how to use this binding.\n * \n * These tasks should be completed prior to running:\n * 1. Add com.microsoft.azure.functions:azure-functions-java-library-openai to your project dependencies.\n * 2. Add app settings appropriate for connecting to azure/non-azure openai following\n * https://learn.microsoft.com/en-us/azure/azure-functions/functions-bindings-openai?tabs=isolated-process&pivots=programming-language-java#application-settings\n * 3. Change the bundle name in host.json to \"Microsoft.Azure.Functions.ExtensionBundle.Preview\" and the \n * version to \"[4.*, 5.0.0)\"\n */\n\nimport com.microsoft.azure.functions.annotation.*;\nimport com.microsoft.azure.functions.*;\nimport com.microsoft.azure.functions.openai.annotation.assistant.AssistantPost;\nimport com.microsoft.azure.functions.openai.annotation.assistant.AssistantState;\nimport com.microsoft.azure.functions.openai.annotation.assistant.ChatMessage;\n\nimport java.util.List;\nimport java.util.Optional;\n\npublic class $className$ {\n\n @FunctionName(\"$functionName$\")\n public HttpResponseMessage postUserResponse(\n @HttpTrigger(\n name = \"req\",\n methods = {HttpMethod.POST}, \n authLevel = AuthorizationLevel.ANONYMOUS,\n route = \"assistants/{chatId}\") \n HttpRequestMessage> request,\n @BindingName(\"chatId\") String chatId, \n @AssistantPost(name=\"$name$\", id = \"{chatId}\", model = \"$model$\", userMessage = \"{Query.message}\") AssistantState state,\n final ExecutionContext context) {\n\n List recentMessages = state.getRecentMessages();\n String response = recentMessages.isEmpty() ? \"No response returned.\" : recentMessages.get(recentMessages.size() - 1).getContent();\n \n return request.createResponseBuilder(HttpStatus.OK)\n .header(\"Content-Type\", \"application/json\")\n .body(response)\n .build();\n }\n}\n" + } + }, + { + "id": "EmbeddingsStoreOutput-Java", + "metadata": { + "name": "EmbeddingsStoreOutput", + "description": "$EmbeddingsStoreOutput_description", + "defaultFunctionName": "embeddingsStoreOutputJava", + "language": "Java", + "userPrompt": [ + "name", + "model", + "connectionName", + "collection" + ] + }, + "bundle": ["~4"], + "function": { + "disabled": false, + "bindings": [ + { + "type": "embeddingsStore", + "name": "output", + "direction": "out", + "input": "{Url}", + "inputType": "Url", + "connectionName": "AISearchEndpoint", + "collection": "openai-index", + "model": "%EMBEDDING_MODEL_DEPLOYMENT_NAME%" + } + ] + }, + "files": { + "function.java": "package $packageName$;\n\n/**\n * Visit https://learn.microsoft.com/en-us/azure/azure-functions/functions-bindings-openai?tabs=isolated-process&pivots=programming-language-java\n * to learn how to use this binding.\n * \n * These tasks should be completed prior to running:\n * 1. Add com.microsoft.azure.functions:azure-functions-java-library-openai to your project dependencies.\n * 2. Add app settings appropriate for connecting to azure/non-azure openai following\n * https://learn.microsoft.com/en-us/azure/azure-functions/functions-bindings-openai?tabs=isolated-process&pivots=programming-language-java#application-settings\n * 3. Change the bundle name in host.json to \"Microsoft.Azure.Functions.ExtensionBundle.Preview\" and the \n * version to \"[4.*, 5.0.0)\"\n */\n\nimport com.microsoft.azure.functions.annotation.*;\nimport com.microsoft.azure.functions.*;\nimport com.microsoft.azure.functions.openai.annotation.embeddings.EmbeddingsStoreOutput;\nimport com.microsoft.azure.functions.openai.annotation.embeddings.InputType;\nimport com.microsoft.azure.functions.openai.annotation.search.SearchableDocument;\nimport java.net.URI;\nimport java.nio.file.Paths;\n\npublic class $className$ {\n\n @FunctionName(\"$functionName$\")\n public HttpResponseMessage ingestFile(\n @HttpTrigger(\n name = \"req\", \n methods = {HttpMethod.POST},\n authLevel = AuthorizationLevel.ANONYMOUS)\n HttpRequestMessage request,\n @EmbeddingsStoreOutput(name=\"$name$\", input = \"{Url}\", inputType = InputType.Url,\n connectionName = \"$connectionName$\", collection = \"$collection$\",\n model = \"$model$\") OutputBinding output,\n final ExecutionContext context) {\n\n if (request.getBody() == null || request.getBody().getUrl() == null) {\n return request.createResponseBuilder(HttpStatus.BAD_REQUEST)\n .body(\"Invalid request body. Make sure that you pass in {\\\"Url\\\": value } as the request body.\")\n .build();\n }\n\n try {\n URI uri = new URI(request.getBody().getUrl());\n String filename = Paths.get(uri.getPath()).getFileName().toString();\n\n EmbeddingsStoreOutputResponse embeddingsStoreOutputResponse = new EmbeddingsStoreOutputResponse(new SearchableDocument(filename));\n\n output.setValue(embeddingsStoreOutputResponse);\n\n return request.createResponseBuilder(HttpStatus.CREATED)\n .header(\"Content-Type\", \"application/json\")\n .body(String.format(\"{{\\\"status\\\": \\\"success\\\", \\\"title\\\": \\\"%s\\\"}}\", filename))\n .build();\n } catch (Exception e) {\n return request.createResponseBuilder(HttpStatus.INTERNAL_SERVER_ERROR)\n .body(\"Error processing the request: \" + e.getMessage())\n .build();\n }\n }\n\n public static class EmbeddingsStoreOutputResponse {\n private SearchableDocument searchableDocument;\n\n public EmbeddingsStoreOutputResponse(SearchableDocument searchableDocument) {\n this.searchableDocument = searchableDocument;\n }\n\n public SearchableDocument getSearchableDocument() {\n return searchableDocument;\n }\n }\n\n public static class EmbeddingsRequest {\n private String url;\n\n public String getUrl() {\n return url;\n }\n\n public void setUrl(String url) {\n this.url = url;\n }\n }\n}\n" + } + }, + { + "id": "EmbeddingsInput-Java", + "metadata": { + "name": "EmbeddingsInput", + "description": "$EmbeddingsInput_description", + "defaultFunctionName": "embeddingsInputJava", + "language": "Java", + "userPrompt": [ + "name" + ] + }, + "bundle": ["~4"], + "function": { + "disabled": false, + "bindings": [ + { + "type": "embeddings", + "name": "input", + "direction": "in", + "input": "{RawText}", + "inputType": "RawText", + "connectionName": "AISearchEndpoint", + "model": "%EMBEDDING_MODEL_DEPLOYMENT_NAME%" + } + ] + }, + "files": { + "function.java": "package $packageName$;\n\nimport com.microsoft.azure.functions.annotation.*;\nimport com.microsoft.azure.functions.*;\nimport com.microsoft.azure.functions.openai.annotation.embeddings.EmbeddingsInput;\nimport com.microsoft.azure.functions.openai.annotation.embeddings.InputType;\nimport org.json.JSONObject;\n\n/**\n * Azure Functions embeddings sample to generate embeddings.\n */\npublic class $className$ {\n\n /**\n * Example showing how to use the EmbeddingsInput input binding to generate embeddings \n * for a raw text string.\n */\n @FunctionName(\"$functionName$\")\n public HttpResponseMessage generateEmbeddingsHttpRequest(\n @HttpTrigger(\n name = \"req\", \n methods = {HttpMethod.POST},\n authLevel = AuthorizationLevel.ANONYMOUS,\n route = \"embeddings\")\n HttpRequestMessage request,\n @EmbeddingsInput(name = \"$name$\", input = \"{RawText}\", inputType = InputType.RawText, model = \"%EMBEDDING_MODEL_DEPLOYMENT_NAME%\") String embeddingsContext,\n final ExecutionContext context) {\n\n if (request.getBody() == null)\n {\n throw new IllegalArgumentException(\"Invalid request body. Make sure that you pass in {\\\"rawText\\\": value } as the request body.\");\n }\n\n JSONObject embeddingsContextJsonObject = new JSONObject(embeddingsContext);\n \n context.getLogger().info(String.format(\"Received %d embedding(s) for input text containing %s characters.\",\n embeddingsContextJsonObject.getJSONObject(\"response\")\n .getJSONArray(\"data\")\n .getJSONObject(0)\n .getJSONArray(\"embedding\").length(),\n request.getBody().getRawText().length()));\n\n // TODO: Store the embeddings into a database or other storage.\n return request.createResponseBuilder(HttpStatus.ACCEPTED)\n .header(\"Content-Type\", \"application/json\")\n .build();\n }\n\n /**\n * Example showing how to use the EmbeddingsInput input binding to generate embeddings\n * for text contained in a file on the file system.\n */\n @FunctionName(\"GenerateEmbeddingsHttpFilePath\")\n public HttpResponseMessage generateEmbeddingsHttpFilePath(\n @HttpTrigger(\n name = \"req\", \n methods = {HttpMethod.POST},\n authLevel = AuthorizationLevel.ANONYMOUS,\n route = \"embeddings-from-file\")\n HttpRequestMessage request,\n @EmbeddingsInput(name = \"Embeddings\", input = \"{FilePath}\", inputType = InputType.FilePath, maxChunkLength = 512, model = \"%EMBEDDING_MODEL_DEPLOYMENT_NAME%\") String embeddingsContext,\n final ExecutionContext context) {\n\n if (request.getBody() == null)\n {\n throw new IllegalArgumentException(\"Invalid request body. Make sure that you pass in {\\\"rawText\\\": value } as the request body.\");\n }\n\n JSONObject embeddingsContextJsonObject = new JSONObject(embeddingsContext);\n \n context.getLogger().info(String.format(\"Received %d embedding(s) for input file %s.\",\n embeddingsContextJsonObject.getJSONObject(\"response\")\n .getJSONArray(\"data\")\n .getJSONObject(0)\n .getJSONArray(\"embedding\").length(),\n request.getBody().getFilePath()));\n\n // TODO: Store the embeddings into a database or other storage.\n return request.createResponseBuilder(HttpStatus.ACCEPTED)\n .header(\"Content-Type\", \"application/json\")\n .build();\n }\n\n /**\n * Example showing how to use the EmbeddingsInput input binding to generate embeddings\n * for text contained in a file on the file system.\n */\n @FunctionName(\"GenerateEmbeddingsHttpUrl\")\n public HttpResponseMessage generateEmbeddingsHttpUrl(\n @HttpTrigger(\n name = \"req\", \n methods = {HttpMethod.POST},\n authLevel = AuthorizationLevel.ANONYMOUS,\n route = \"embeddings-from-url\")\n HttpRequestMessage request,\n @EmbeddingsInput(name = \"Embeddings\", input = \"{Url}\", inputType = InputType.Url, maxChunkLength = 512, model = \"%EMBEDDING_MODEL_DEPLOYMENT_NAME%\") String embeddingsContext,\n final ExecutionContext context) {\n\n if (request.getBody() == null)\n {\n throw new IllegalArgumentException(\"Invalid request body. Make sure that you pass in {\\\"rawText\\\": value } as the request body.\");\n }\n\n JSONObject embeddingsContextJsonObject = new JSONObject(embeddingsContext);\n \n context.getLogger().info(String.format(\"Received %d embedding(s) for input url %s.\",\n embeddingsContextJsonObject.getJSONObject(\"response\")\n .getJSONArray(\"data\")\n .getJSONObject(0)\n .getJSONArray(\"embedding\").length(),\n request.getBody().getUrl()));\n\n // TODO: Store the embeddings into a database or other storage.\n return request.createResponseBuilder(HttpStatus.ACCEPTED)\n .header(\"Content-Type\", \"application/json\")\n .build();\n } \n\n public class EmbeddingsRequest {\n private String rawText;\n private String filePath;\n private String url;\n\n public String getRawText() {\n return rawText;\n }\n\n public void setRawText(String rawText) {\n this.rawText = rawText;\n }\n\n public String getFilePath() {\n return filePath;\n }\n\n public void setFilePath(String filePath) {\n this.filePath = filePath;\n }\n\n public String getUrl() {\n return url;\n }\n\n public void setUrl(String url) {\n this.url = url;\n } \n } \n}\n" + } + }, + { + "id": "TextCompletion-Java", + "metadata": { + "name": "TextCompletion", + "description": "$TextCompletion_description", + "defaultFunctionName": "textCompletionJava", + "language": "Java", + "userPrompt": [ + "name", + "model" + ] + }, + "bundle": ["~4"], + "function": { + "disabled": false, + "bindings": [ + { + "type": "textCompletion", + "name": "response", + "direction": "in", + "prompt": "{prompt}", + "model": "%CHAT_MODEL_DEPLOYMENT_NAME%" + } + ] + }, + "files": { + "function.java": "package $packageName$;\n\n/**\n * Visit https://learn.microsoft.com/en-us/azure/azure-functions/functions-bindings-openai?tabs=isolated-process&pivots=programming-language-java\n * to learn how to use this binding.\n * \n * These tasks should be completed prior to running:\n * 1. Add com.microsoft.azure.functions:azure-functions-java-library-openai to your project dependencies.\n * 2. Add app settings appropriate for connecting to azure/non-azure openai following\n * https://learn.microsoft.com/en-us/azure/azure-functions/functions-bindings-openai?tabs=isolated-process&pivots=programming-language-java#application-settings\n * 3. Change the bundle name in host.json to \"Microsoft.Azure.Functions.ExtensionBundle.Preview\" and the \n * version to \"[4.*, 5.0.0)\"\n */\n\nimport com.microsoft.azure.functions.annotation.*;\nimport com.microsoft.azure.functions.*;\nimport com.microsoft.azure.functions.openai.annotation.textcompletion.TextCompletion;\nimport com.microsoft.azure.functions.openai.annotation.textcompletion.TextCompletionResponse;\n\nimport java.util.Optional;\n\npublic class $className$ {\n\n @FunctionName(\"$functionName$\")\n public HttpResponseMessage textCompletion(\n @HttpTrigger(\n name = \"req\", \n methods = {HttpMethod.POST},\n authLevel = AuthorizationLevel.ANONYMOUS) \n HttpRequestMessage> request,\n @TextCompletion(prompt = \"{prompt}\", model = \"$model$\", name = \"$name$\") TextCompletionResponse response,\n final ExecutionContext context) {\n return request.createResponseBuilder(HttpStatus.OK)\n .header(\"Content-Type\", \"application/json\")\n .body(response.getContent())\n .build();\n }\n}\n" + } + }, + { + "id": "SemanticSearch-Java", + "metadata": { + "name": "SemanticSearch", + "description": "$SemanticSearch_description", + "defaultFunctionName": "semanticSearchJava", + "language": "Java", + "userPrompt": [ + "name", + "connectionName", + "collection" + ] + }, + "bundle": ["~4"], + "function": { + "disabled": false, + "bindings": [ + { + "type": "semanticSearch", + "name": "search", + "direction": "in", + "connectionName": "connectionName", + "collection": "connection", + "query": "{Prompt}", + "chatModel": "%CHAT_MODEL_DEPLOYMENT_NAME%", + "embeddingsModel": "%EMBEDDING_MODEL_DEPLOYMENT_NAME%" + } + ] + }, + "files": { + "function.java": "package $packageName$;\n\n/**\n * Visit https://learn.microsoft.com/en-us/azure/azure-functions/functions-bindings-openai?tabs=isolated-process&pivots=programming-language-java to learn how to use this binding.\n * \n * These tasks should be completed prior to running:\n * 1. Add com.microsoft.azure.functions:azure-functions-java-library-openai to your project dependencies.\n * 2. Add app settings appropriate for connecting to azure/non-azure openai following https://learn.microsoft.com/en-us/azure/azure-functions/functions-bindings-openai?tabs=isolated-process&pivots=programming-language-java#application-settings\n * 3. Change the bundle name in host.json to \"Microsoft.Azure.Functions.ExtensionBundle.Preview\" and the version to \"[4.*, 5.0.0)\"\n */\n\nimport java.nio.file.Paths;\nimport java.net.URI;\n\nimport org.json.JSONObject;\nimport com.microsoft.azure.functions.ExecutionContext;\nimport com.microsoft.azure.functions.HttpMethod;\nimport com.microsoft.azure.functions.HttpRequestMessage;\nimport com.microsoft.azure.functions.HttpResponseMessage;\nimport com.microsoft.azure.functions.HttpStatus;\nimport com.microsoft.azure.functions.OutputBinding;\nimport com.microsoft.azure.functions.annotation.AuthorizationLevel;\nimport com.microsoft.azure.functions.annotation.FunctionName;\nimport com.microsoft.azure.functions.annotation.HttpTrigger;\nimport com.microsoft.azure.functions.openai.annotation.embeddings.EmbeddingsStoreOutput;\nimport com.microsoft.azure.functions.openai.annotation.embeddings.InputType;\nimport com.microsoft.azure.functions.openai.annotation.search.SearchableDocument;\nimport com.microsoft.azure.functions.openai.annotation.search.SemanticSearch;\n\npublic class $className$ {\n\n @FunctionName(\"$functionName$\")\n public HttpResponseMessage ingestFile(\n @HttpTrigger(\n name = \"req\", \n methods = {HttpMethod.POST},\n authLevel = AuthorizationLevel.ANONYMOUS)\n HttpRequestMessage request,\n @EmbeddingsStoreOutput(name=\"EmbeddingsStoreOutput\", input = \"{Url}\", inputType = InputType.Url,\n connectionName = \"$connectionName$\", collection = \"$collection$\",\n model = \"%EMBEDDING_MODEL_DEPLOYMENT_NAME%\") OutputBinding output,\n final ExecutionContext context) {\n\n if (request.getBody() == null || request.getBody().getUrl() == null)\n {\n throw new IllegalArgumentException(\"Invalid request body. Make sure that you pass in {\\\"Url\\\": value } as the request body.\");\n }\n\n try {\n URI uri = new URI(request.getBody().getUrl());\n String filename = Paths.get(uri.getPath()).getFileName().toString();\n\n EmbeddingsStoreOutputResponse embeddingsStoreOutputResponse = new EmbeddingsStoreOutputResponse(new SearchableDocument(filename));\n\n output.setValue(embeddingsStoreOutputResponse);\n\n JSONObject response = new JSONObject();\n response.put(\"status\", \"success\");\n response.put(\"title\", filename);\n\n return request.createResponseBuilder(HttpStatus.CREATED)\n .header(\"Content-Type\", \"application/json\")\n .body(response)\n .build();\n } catch (Exception e) {\n return request.createResponseBuilder(HttpStatus.INTERNAL_SERVER_ERROR)\n .body(\"Error processing the request: \" + e.getMessage())\n .build();\n }\n }\n\n public class EmbeddingsStoreOutputResponse {\n private SearchableDocument searchableDocument;\n\n public EmbeddingsStoreOutputResponse(SearchableDocument searchableDocument) {\n this.searchableDocument = searchableDocument;\n }\n public SearchableDocument getSearchableDocument() {\n return searchableDocument;\n }\n }\n \n @FunctionName(\"PromptFile\")\n public HttpResponseMessage promptFile(\n @HttpTrigger(\n name = \"req\", \n methods = {HttpMethod.POST},\n authLevel = AuthorizationLevel.ANONYMOUS)\n HttpRequestMessage request,\n @SemanticSearch(name = \"$name$\", connectionName = \"$connectionName$\", collection = \"$collection$\", query = \"{Prompt}\", chatModel = \"%CHAT_MODEL_DEPLOYMENT_NAME%\", embeddingsModel = \"%EMBEDDING_MODEL_DEPLOYMENT_NAME%\" ) String semanticSearchContext,\n final ExecutionContext context) {\n String response = new JSONObject(semanticSearchContext).getString(\"Response\");\n return request.createResponseBuilder(HttpStatus.OK)\n .header(\"Content-Type\", \"application/json\")\n .body(response)\n .build(); \n }\n\n public class EmbeddingsRequest {\n public String url;\n public String getUrl() {\n return url;\n }\n public void setUrl(String url) {\n this.url = url;\n }\n }\n\n public class SemanticSearchRequest {\n public String prompt;\n public String getPrompt() {\n return prompt;\n }\n public void setPrompt(String prompt) {\n this.prompt = prompt;\n } \n }\n}\n" + } } ] }