Skip to content

Commit

Permalink
print configs on the frontend
Browse files Browse the repository at this point in the history
  • Loading branch information
ecostanzi committed May 21, 2024
1 parent 2195012 commit 3c54685
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/main/kotlin/Main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ fun main() {
}
.start(config.getIntegerProperty("SERVER_PORT"))

app.get("/configs") { ctx ->
ctx.json(mapOf("ai" to config.getProperty("CHAT_CLIENT")))
}

app.post("/chat") { ctx ->
val prompt = JsonPath.read<String>(ctx.body(), "$.prompt")
logger.info("Querying chat proxy with promt '$prompt'")
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/application.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
SERVER_PORT=8080
CUSTOM_MESSAGE="Hello World From Configs"

CHAT_CLIENT=DUMMY
CHAT_CLIENT=DUMMY_CHAT
MODEL=gpt-3.5-turbo
CHATGPT_API_KEY=NOT HERE!

Expand Down
16 changes: 16 additions & 0 deletions src/main/resources/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
<div class="row center-align">
<h1>&nbsp;</h1>
<h4>Enter your prompt!</h4>
<h5 id="configs"></h5>
</div>
<div class="row">
<form class="col s12" id="proxyForm">
Expand Down Expand Up @@ -83,6 +84,21 @@ <h4>Enter your prompt!</h4>
responseArea.innerText = 'Error: ' + error.toString();
});
});

const configArea = document.getElementById('configs');
fetch('/configs', {
method: 'GET'
})
.then(response => response.json())
.then(data => {
configArea.innerText = 'Now querying ' + data['ai'];
})
.catch(error => {
console.error('Error:', error);
configArea.innerText = 'Error: ' + error.toString();
});


</script>
</body>
</html>

0 comments on commit 3c54685

Please sign in to comment.