-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
44 changed files
with
2,117 additions
and
103 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
22 changes: 22 additions & 0 deletions
22
langstream-admin-client/src/main/java/ai/langstream/admin/client/model/Archetypes.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,22 @@ | ||
/* | ||
* Copyright DataStax, Inc. | ||
* | ||
* 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 | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* 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 ai.langstream.admin.client.model; | ||
|
||
public interface Archetypes { | ||
String list(); | ||
|
||
String get(String archetypeId); | ||
} |
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
42 changes: 42 additions & 0 deletions
42
langstream-api/src/main/java/ai/langstream/api/archetype/ArchetypeDefinition.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,42 @@ | ||
/* | ||
* Copyright DataStax, Inc. | ||
* | ||
* 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 | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* 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 ai.langstream.api.archetype; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import java.util.List; | ||
|
||
public record ArchetypeDefinition(Archetype archetype) { | ||
|
||
public record Archetype( | ||
String id, | ||
String title, | ||
List<String> labels, | ||
String description, | ||
String icon, | ||
List<Section> sections) {} | ||
|
||
public record Section(String title, String description, List<Parameter> parameters) {} | ||
|
||
public record Parameter( | ||
String name, | ||
String label, | ||
String description, | ||
String type, | ||
String subtype, | ||
String binding, | ||
boolean required, | ||
@JsonProperty("default") Object defaultVal) {} | ||
} |
29 changes: 29 additions & 0 deletions
29
langstream-cli/src/main/java/ai/langstream/cli/commands/RootArchetypeCmd.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,29 @@ | ||
/* | ||
* Copyright DataStax, Inc. | ||
* | ||
* 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 | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* 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 ai.langstream.cli.commands; | ||
|
||
import ai.langstream.cli.commands.archetypes.ListArchetypesCmd; | ||
import lombok.Getter; | ||
import picocli.CommandLine; | ||
|
||
@CommandLine.Command( | ||
name = "archetypes", | ||
header = "Use LangStream Archetypes", | ||
subcommands = {ListArchetypesCmd.class}) | ||
@Getter | ||
public class RootArchetypeCmd { | ||
@CommandLine.ParentCommand private RootCmd rootCmd; | ||
} |
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
31 changes: 31 additions & 0 deletions
31
langstream-cli/src/main/java/ai/langstream/cli/commands/archetypes/BaseArchetypeCmd.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,31 @@ | ||
/* | ||
* Copyright DataStax, Inc. | ||
* | ||
* 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 | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* 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 ai.langstream.cli.commands.archetypes; | ||
|
||
import ai.langstream.cli.commands.BaseCmd; | ||
import ai.langstream.cli.commands.RootArchetypeCmd; | ||
import ai.langstream.cli.commands.RootCmd; | ||
import picocli.CommandLine; | ||
|
||
public abstract class BaseArchetypeCmd extends BaseCmd { | ||
|
||
@CommandLine.ParentCommand private RootArchetypeCmd rootAppCmd; | ||
|
||
@Override | ||
protected RootCmd getRootCmd() { | ||
return rootAppCmd.getRootCmd(); | ||
} | ||
} |
53 changes: 53 additions & 0 deletions
53
langstream-cli/src/main/java/ai/langstream/cli/commands/archetypes/ListArchetypesCmd.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,53 @@ | ||
/* | ||
* Copyright DataStax, Inc. | ||
* | ||
* 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 | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* 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 ai.langstream.cli.commands.archetypes; | ||
|
||
import com.fasterxml.jackson.databind.JsonNode; | ||
import java.util.function.BiFunction; | ||
import lombok.SneakyThrows; | ||
import picocli.CommandLine; | ||
|
||
@CommandLine.Command(name = "list", header = "List all LangStream archetypes") | ||
public class ListArchetypesCmd extends BaseArchetypeCmd { | ||
|
||
protected static final String[] COLUMNS_FOR_RAW = {"id", "labels"}; | ||
|
||
@CommandLine.Option( | ||
names = {"-o"}, | ||
description = "Output format. Formats are: yaml, json, raw. Default value is raw.") | ||
private Formats format = Formats.raw; | ||
|
||
@Override | ||
@SneakyThrows | ||
public void run() { | ||
ensureFormatIn(format, Formats.raw, Formats.json, Formats.yaml); | ||
final String body = getClient().archetypes().list(); | ||
print(format, body, COLUMNS_FOR_RAW, getRawFormatValuesSupplier()); | ||
} | ||
|
||
public static BiFunction<JsonNode, String, Object> getRawFormatValuesSupplier() { | ||
return (jsonNode, s) -> { | ||
switch (s) { | ||
case "id": | ||
return searchValueInJson(jsonNode, "archetype.id"); | ||
case "labels": | ||
return searchValueInJson(jsonNode, "archetype.labels"); | ||
default: | ||
return jsonNode.get(s); | ||
} | ||
}; | ||
} | ||
} |
Oops, something went wrong.