Skip to content

Commit

Permalink
Merge pull request #159 from orkes-io/ai_integration
Browse files Browse the repository at this point in the history
Add Integration clients and fix grpc vulnerabilities
  • Loading branch information
v1r3n authored Jun 20, 2024
2 parents 2249572 + 02b2682 commit 6bec67f
Show file tree
Hide file tree
Showing 49 changed files with 5,244 additions and 399 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/intgtest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,21 @@ jobs:
name: Integration Tests
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Zulu JDK 11
uses: actions/checkout@v4
- name: Set up Zulu JDK 17
uses: actions/setup-java@v3
with:
distribution: "zulu"
java-version: "11"
java-version: "17"
- name: Build and run tests
run: |
hostname
echo "host is $HOSTNAME"
./gradlew clean test
env:
SDK_INTEGRATION_TESTS_SERVER_API_URL: ${{ secrets.SDK_INTEGRATION_TESTS_SERVER_API_URL }}
SDK_INTEGRATION_TESTS_SERVER_KEY_ID: ${{ secrets.SDK_INTEGRATION_TESTS_SERVER_KEY_ID }}
SDK_INTEGRATION_TESTS_SERVER_KEY_SECRET: ${{ secrets.SDK_INTEGRATION_TESTS_SERVER_KEY_SECRET }}
CONDUCTOR_SERVER_URL: ${{ secrets.CONDUCTOR_SERVER_URL }}
CONDUCTOR_SERVER_AUTH_KEY: ${{ secrets.CONDUCTOR_SERVER_AUTH_KEY }}
CONDUCTOR_SERVER_AUTH_SECRET: ${{ secrets.CONDUCTOR_SERVER_AUTH_SECRET }}
USER1_APPLICATION_ID: ${{ secrets.USER1_APPLICATION_ID }}
USER1_KEY_ID: ${{ secrets.USER1_KEY_ID }}
USER1_SECRET: ${{ secrets.USER1_SECRET }}
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/oss.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ jobs:
steps:
- name: Checkout repo
uses: actions/checkout@v3
- name: Set up Zulu JDK 11
uses: actions/setup-java@v3
- name: Set up Zulu JDK 17
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: '11'
java-version: '17'
- name: Publish
run: |
export CONDUCTOR_VERSION=${{ github.event.inputs.version }}
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ jobs:
steps:
- name: Checkout repo
uses: actions/checkout@v3
- name: Set up Zulu JDK 11
uses: actions/setup-java@v3
- name: Set up Zulu JDK 17
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: '11'
java-version: '17'
- name: Publish
run: |
export VERSION="${{github.ref_name}}"
Expand Down
16 changes: 10 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,9 @@ ext {
azureIdentity : '1.3.7',
eureka : '1.10.17',
wiremock : '2.33.2',
ioGRPC : '1.49.0',
ioGRPC : '1.49.0',
protoBuf : '3.19.4',
lombok : '1.18.24',
ioGRPC : '1.63.1',
protoBuf : '3.25.3',
lombok : '1.18.30',
revJAXRS : '2.1.1',
log4j : '2.17.1',
netty : '4.1.77.Final'
Expand Down Expand Up @@ -203,9 +202,14 @@ jacocoTestReport {
dependsOn test // tests are required to run before generating the report
}

allprojects {
tasks.withType(Javadoc) {
options.addStringOption('Xdoclint:none', '-quiet')
}
}
compileJava {
sourceCompatibility = 11
targetCompatibility = 11
sourceCompatibility = 17
targetCompatibility = 17
}

configurations.implementation {
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import com.netflix.conductor.common.metadata.tasks.TaskResult;
import com.netflix.conductor.common.run.SearchResult;
import com.netflix.conductor.common.utils.ExternalPayloadStorage;

import io.orkes.conductor.client.model.TaskSummary;

/** Client for conductor task management including polling for task, updating task status etc. */
Expand Down
77 changes: 77 additions & 0 deletions src/main/java/io/orkes/conductor/client/IntegrationClient.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/*
* Copyright 2024 Orkes, Inc.
* <p>
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*/
package io.orkes.conductor.client;

import java.util.List;
import java.util.Map;

import io.orkes.conductor.client.model.TagObject;
import io.orkes.conductor.client.model.integration.Integration;
import io.orkes.conductor.client.model.integration.IntegrationApi;
import io.orkes.conductor.client.model.integration.IntegrationApiUpdate;
import io.orkes.conductor.client.model.integration.IntegrationUpdate;
import io.orkes.conductor.client.model.integration.ai.PromptTemplate;

public interface IntegrationClient {
/**
* Client for managing integrations with external systems. Some examples of integrations are:
* 1. AI/LLM providers (e.g. OpenAI, HuggingFace)
* 2. Vector DBs (Pinecone, Weaviate etc.)
* 3. Kafka
* 4. Relational databases
*
* Integrations are configured as integration -> api with 1->N cardinality.
* APIs are the underlying resources for an integration and depending on the type of integration they represent underlying resources.
* Examples:
* LLM integrations
* The integration specifies the name of the integration unique to your environment, api keys and endpoint used.
* APIs are the models (e.g. text-davinci-003, or text-embedding-ada-002)
*
* Vector DB integrations,
* The integration represents the cluster, specifies the name of the integration unique to your environment, api keys and endpoint used.
* APIs are the indexes (e.g. pinecone) or class (e.g. for weaviate)
*
* Kafka
* The integration represents the cluster, specifies the name of the integration unique to your environment, api keys and endpoint used.
* APIs are the topics that are configured for use within this kafka cluster
*/

void associatePromptWithIntegration(String aiIntegration, String modelName, String promptName);

void deleteIntegrationApi(String apiName, String integrationName);

void deleteIntegration(String integrationName);

IntegrationApi getIntegrationApi(String apiName, String integrationName);

List<IntegrationApi> getIntegrationApis(String integrationName);

Integration getIntegration(String integrationName);

List<Integration> getIntegrations(String category, Boolean activeOnly);

List<PromptTemplate> getPromptsWithIntegration(String aiIntegration, String modelName);

int getTokenUsageForIntegration(String name, String integrationName);

Map<String, Integer> getTokenUsageForIntegrationProvider(String name);

void saveIntegrationApi(String integrationName, String apiName, IntegrationApiUpdate apiDetails);

void saveIntegration(String integrationName, IntegrationUpdate integrationDetails);

// Tags
void deleteTagForIntegrationProvider(List<TagObject> tags, String name);
void saveTagForIntegrationProvider(List<TagObject> tags, String name);
List<TagObject> getTagsForIntegrationProvider(String name);
}
14 changes: 14 additions & 0 deletions src/main/java/io/orkes/conductor/client/OrkesClients.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
*/
package io.orkes.conductor.client;

import com.netflix.conductor.sdk.workflow.executor.WorkflowExecutor;

import io.orkes.conductor.client.http.*;

public class OrkesClients {
Expand Down Expand Up @@ -49,4 +51,16 @@ public SecretClient getSecretClient() {
public TaskClient getTaskClient() {
return new OrkesTaskClient(apiClient);
}

public IntegrationClient getIntegrationClient() {
return new OrkesIntegrationClient(apiClient);
}

public PromptClient getPromptClient() {
return new OrkesPromptClient(apiClient);
}

public WorkflowExecutor getWorkflowExecutor() {
return new WorkflowExecutor(getTaskClient(), getWorkflowClient(), getMetadataClient(), 100);
}
}
79 changes: 79 additions & 0 deletions src/main/java/io/orkes/conductor/client/OrkesPromptClient.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
/*
* Copyright 2024 Orkes, Inc.
* <p>
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*/
package io.orkes.conductor.client;

import java.util.List;
import java.util.Map;

import io.orkes.conductor.client.http.api.PromptResourceApi;
import io.orkes.conductor.client.model.TagObject;
import io.orkes.conductor.client.model.integration.PromptTemplateTestRequest;
import io.orkes.conductor.client.model.integration.ai.PromptTemplate;

public class OrkesPromptClient implements PromptClient {

private final PromptResourceApi promptResourceApi;

public OrkesPromptClient(ApiClient apiClient) {
this.promptResourceApi = new PromptResourceApi(apiClient);
}

@Override
public void savePrompt(String promptName, String description, String promptTemplate) {
promptResourceApi.savePromptTemplate(promptTemplate, description, promptName, List.of());
}

@Override
public PromptTemplate getPrompt(String promptName) {
return promptResourceApi.getPromptTemplate(promptName);
}

@Override
public List<PromptTemplate> getPrompts() {
return promptResourceApi.getPromptTemplates();
}

@Override
public void deletePrompt(String promptName) {
promptResourceApi.deletePromptTemplate(promptName);
}

@Override
public List<TagObject> getTagsForPromptTemplate(String promptName) {
return promptResourceApi.getTagsForPromptTemplate(promptName);
}

@Override
public void updateTagForPromptTemplate(String promptName, List<TagObject> tags) {
promptResourceApi.putTagForPromptTemplate(tags, promptName);
}

@Override
public void deleteTagForPromptTemplate(String promptName, List<TagObject> tags) {
promptResourceApi.deleteTagForPromptTemplate(tags, promptName);
}

@Override
public String testPrompt(String promptText, Map<String, Object> variables, String aiIntegration, String textCompleteModel, float temperature, float topP,
List<String> stopWords) {
PromptTemplateTestRequest request = new PromptTemplateTestRequest();
request.setPrompt(promptText);
request.setLlmProvider(aiIntegration);
request.setModel(textCompleteModel);
request.setTemperature((double) temperature);
request.setTopP((double) topP);
request.setStopWords(stopWords == null ? List.of() : stopWords);
request.setPromptVariables(variables);
return promptResourceApi.testMessageTemplate(request);
}
}
51 changes: 51 additions & 0 deletions src/main/java/io/orkes/conductor/client/PromptClient.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
* Copyright 2024 Orkes, Inc.
* <p>
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*/
package io.orkes.conductor.client;

import java.util.List;
import java.util.Map;

import io.orkes.conductor.client.model.TagObject;
import io.orkes.conductor.client.model.integration.ai.PromptTemplate;

public interface PromptClient {

void savePrompt(String promptName, String description, String promptTemplate);

PromptTemplate getPrompt(String promptName);

List<PromptTemplate> getPrompts();

void deletePrompt(String promptName);

List<TagObject> getTagsForPromptTemplate(String promptName);

void updateTagForPromptTemplate(String promptName, List<TagObject> tags);

void deleteTagForPromptTemplate(String promptName, List<TagObject> tags);

/**
* Tests a prompt template by substituting variables and processing through the specified AI model.
*
* @param promptText the text of the prompt template
* @param variables a map containing variables to be replaced in the template
* @param aiIntegration the AI integration context
* @param textCompleteModel the AI model used for completing text
* @param temperature the randomness of the output (optional, default is 0.1)
* @param topP the probability mass to consider from the output distribution (optional, default is 0.9)
* @param stopWords a list of words to stop generating further (can be null)
* @return the processed prompt text
*/
String testPrompt(String promptText, Map<String, Object> variables, String aiIntegration,
String textCompleteModel, float temperature, float topP, List<String> stopWords);
}
6 changes: 4 additions & 2 deletions src/main/java/io/orkes/conductor/client/SchedulerClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import java.util.List;

import io.orkes.conductor.client.model.SaveScheduleRequest;
import io.orkes.conductor.client.model.SearchResultWorkflowScheduleExecution;
import io.orkes.conductor.client.model.SearchResultWorkflowScheduleExecutionModel;
import io.orkes.conductor.client.model.TagObject;
import io.orkes.conductor.client.model.WorkflowSchedule;
Expand All @@ -41,8 +42,9 @@ List<Long> getNextFewSchedules(

void saveSchedule(SaveScheduleRequest saveScheduleRequest);

SearchResultWorkflowScheduleExecutionModel searchV22(
Integer start, Integer size, String sort, String freeText, String query);
@Deprecated
SearchResultWorkflowScheduleExecutionModel searchV22(Integer start, Integer size, String sort, String freeText, String query);
SearchResultWorkflowScheduleExecution search(Integer start, Integer size, String sort, String freeText, String query);

void setSchedulerTags(List<TagObject> body, String name);

Expand Down
Loading

0 comments on commit 6bec67f

Please sign in to comment.