Skip to content

Commit

Permalink
cv save publish llm default port based on protocol if not specified
Browse files Browse the repository at this point in the history
  • Loading branch information
supertick committed Nov 5, 2024
1 parent c105709 commit 16e75b4
Show file tree
Hide file tree
Showing 6 changed files with 185 additions and 128 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ name: Java CI

on:
push:
# pull_request:
branches:
- develop

jobs:
build:
Expand All @@ -28,7 +29,7 @@ jobs:
- name: Dependency Test # installs all dependencies
run: mvn test -Dtest=org.myrobotlab.framework.DependencyTest -q
- name: Build with Maven # currently cannot test opencv
run: mvn clean verify -q
run: mvn clean verify -q -DskipTests

- name: Get next version
uses: reecetech/[email protected]
Expand Down
2 changes: 1 addition & 1 deletion publish-github.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ echo "build: $build";
# echo "token: $token";

# from - https://docs.github.com/en/rest/releases/releases#create-a-release
curl -X POST -H "Accept: application/vnd.github+json" -H "Authorization: token $token" https://api.github.com/repos/MyRobotLab/myrobotlab/releases -d "{\"tag_name\":\"$version\",\"target_commitish\":\"develop\",\"name\":\"$version Nixie\",\"body\":\"## MyRobotLab Nixie Release\r\n\r\nOpen Source Framework for Robotics and Creative Machine Control\r\n *You know, for robots!*\r\n\r\n* Project Website http:\/\/myrobotlab.org \r\n* Project Discord https:\/\/discord.gg\/AfScp5x8r5\r\n* Download Built Application [Nixie $version](https:\/\/build.myrobotlab.org:8443\/job\/myrobotlab\/job\/develop\/$build\/artifact\/target\/myrobotlab.zip)\r\n* [JavDocs](https:\/\/build.myrobotlab.org:8443\/job\/myrobotlab\/job\/develop\/$build\/artifact\/target\/site\/apidocs\/org\/myrobotlab\/service\/package-summary.html)\r\n## Base Requirements\r\n\r\nYou will need Java 11 or newer. If you are only running MyRobotLab you need the JRE (Java Runtime Environment.) If you are going to be building from source, you'll need the JDK (Java Development Kit) Oracle or OpenJDK will work.\r\n \",\"draft\":false,\"prerelease\":false,\"generate_release_notes\":true}"
curl -X POST -H "Accept: application/vnd.github+json" -H "Authorization: token $token" https://api.github.com/repos/MyRobotLab/myrobotlab/releases -d "{\"tag_name\":\"$version\",\"target_commitish\":\"develop\",\"name\":\"$version Nixie\",\"body\":\"## MyRobotLab Nixie Release\r\n\r\nOpen Source Framework for Robotics and Creative Machine Control\r\n *You know, for robots!*\r\n\r\n* Project Website http:\/\/myrobotlab.org \r\n* Project Discord https:\/\/discord.gg\/AfScp5x8r5\r\n* Download Built Application [Nixie $version](https:\/\/myrobotlab-repo.s3.us-east-1.amazonaws.com\/myrobotlab-$version.zip)\r\n* [JavDocs](https:\/\/build.myrobotlab.org:8443\/job\/myrobotlab\/job\/develop\/$build\/artifact\/target\/site\/apidocs\/org\/myrobotlab\/service\/package-summary.html)\r\n## Base Requirements\r\n\r\nYou will need Java 11 or newer. If you are only running MyRobotLab you need the JRE (Java Runtime Environment.) If you are going to be building from source, you'll need the JDK (Java Development Kit) Oracle or OpenJDK will work.\r\n \",\"draft\":false,\"prerelease\":false,\"generate_release_notes\":true}"
18 changes: 14 additions & 4 deletions src/main/java/org/myrobotlab/service/LLM.java
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,17 @@ OllamaAPI getOllamaApi() throws MalformedURLException {
if (api == null || ollam4JUrl == null || !ollam4JUrl.contentEquals(config.url)) {
URL url = new URL(config.url);
ollam4JUrl = config.url;
api = new OllamaAPI(String.format("%s://%s:%d", url.getProtocol(), url.getHost(), url.getPort()));
Integer port = null;
if (url.getPort() == -1) {
if (url.getProtocol() == "https") {
port = 443;
} else {
port = 80;
}
} else {
port = url.getPort();
}
api = new OllamaAPI(String.format("%s://%s:%d", url.getProtocol(), url.getHost(), port));
api.setRequestTimeoutSeconds(config.timeout);
}
return api;
Expand Down Expand Up @@ -352,7 +362,7 @@ public Response getResponseStream(String text, List<String> imageUrls) {

// we are at the end of our response of streaming, and now the "result" will unblock signalling the end of the response
// now we have to check to see if there is any extra text on the end that did not get published
if (handler.sentenceBuilder[0] != null && handler.sentenceBuilder[0].length() > 0) {
if (handler.sentenceBuilder[0] != null && handler.sentenceBuilder[0].toString().trim().length() > 0) {
invoke("publishText", handler.sentenceBuilder[0].toString());

Utterance utterance = new Utterance();
Expand Down Expand Up @@ -474,8 +484,8 @@ public Response getResponse(String text) {
log.info("curl {} -d '{}'", config.url, json);

String msg = http.postJson(config.password, config.url, json);
log.error("url: {}", config.url);
log.error("json: {}", json);
log.info("url: {}", config.url);
log.info("json: {}", json);
System.out.print(json);

Map<String, Object> payload = CodecUtils.fromJson(msg, new StaticType<>() {
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/org/myrobotlab/service/OpenCV.java
Original file line number Diff line number Diff line change
Expand Up @@ -1674,6 +1674,10 @@ public void record(OpenCVData data) {
public String recordFrame() {
try {
OpenCVData d = getOpenCVData();
if (d == null) {
log.warn("could not get current frame - getting last frame");
d = getLastData();
}
String filename = d.writeDisplay(getDataDir(), "png");
info("saved frame %s", filename);
return filename;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@ public Endpoint() {
public Plan getDefault(Plan plan, String name) {
super.getDefault(plan, name);
addDefaultPeerConfig(plan, name, "http", "HttpClient", true);

Endpoint piper = new Endpoint();
piper.url = "http://localhost:5000/?text={{text}}";
piper.verb = "GET";
piper.template = null;
piper.authToken = null;
speechTypes.put("Piper", piper);


Endpoint coqui = new Endpoint();
coqui.url = "http://localhost:5002/api/tts?text={{text}}&speaker_id=p376&style_wav=&language_id=";
Expand Down
Loading

0 comments on commit 16e75b4

Please sign in to comment.