-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #159 from orkes-io/ai_integration
Add Integration clients and fix grpc vulnerabilities
- Loading branch information
Showing
49 changed files
with
5,244 additions
and
399 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
src/main/java/io/orkes/conductor/client/IntegrationClient.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
src/main/java/io/orkes/conductor/client/OrkesPromptClient.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.