-
Notifications
You must be signed in to change notification settings - Fork 0
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
33 changed files
with
1,313 additions
and
114 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,83 @@ | ||
// Download a codebase | ||
export async function downloadCodebase() { | ||
const ec2 = "http://18.226.98.245:80"; | ||
const local = "http://localhost:3000"; | ||
const apiURL = "https://syntaxsorcerer-backend.fly.dev"; | ||
const url = document.getElementById("codebase-url").value; | ||
if (url.trim() === "") return; | ||
|
||
const response = await fetch(`${apiURL}/api/download`, { | ||
method: "POST", | ||
headers: { | ||
"Content-Type": "application/json", | ||
}, | ||
body: JSON.stringify({ url }), | ||
}); | ||
|
||
const result = await response.json(); | ||
if (result.error) { | ||
alert(result.error); | ||
} else { | ||
alert("Codebase downloaded and cached"); | ||
} | ||
} | ||
|
||
// Send a message to the ChatGPT API | ||
export async function sendMessage() { | ||
const userInput = document.getElementById("user-input").value; | ||
if (userInput.trim() === "") return; | ||
|
||
appendMessage("You", userInput); | ||
document.getElementById("user-input").value = ""; | ||
|
||
const sendButton = document.getElementById("send-button"); | ||
sendButton.disabled = true; | ||
|
||
await fetchChatGPTResponse(userInput); | ||
|
||
sendButton.disabled = false; | ||
} | ||
|
||
// Display a message on the frontend | ||
export function appendMessage(sender, message) { | ||
const messagesDiv = document.getElementById("messages"); | ||
const messageElement = document.createElement("div"); | ||
messageElement.classList.add("message"); | ||
|
||
const senderElement = document.createElement("div"); | ||
senderElement.classList.add("sender"); | ||
senderElement.textContent = sender.toUpperCase(); | ||
|
||
const contentElement = document.createElement("div"); | ||
contentElement.classList.add("content"); | ||
contentElement.textContent = message; | ||
|
||
messageElement.appendChild(senderElement); | ||
messageElement.appendChild(contentElement); | ||
messagesDiv.appendChild(messageElement); | ||
|
||
messagesDiv.scrollTop = messagesDiv.scrollHeight; | ||
} | ||
|
||
// Fetch a response from the ChatGPT API | ||
export async function fetchChatGPTResponse(userInput) { | ||
const ec2 = "https://18.226.98.245:443"; | ||
const local = "http://localhost:3000"; | ||
const apiURL = "https://syntaxsorcerer-backend.fly.dev"; | ||
const codebasePath = "../../codebases/main"; | ||
|
||
const response = await fetch(`${apiURL}/api/chatgpt`, { | ||
method: "POST", | ||
headers: { | ||
"Content-Type": "application/json", | ||
}, | ||
body: JSON.stringify({ prompt: userInput, codebasePath }), | ||
}); | ||
|
||
const botMessage = await response.json(); | ||
if (botMessage.error) { | ||
appendMessage("Error", botMessage.error); | ||
} else { | ||
appendMessage("Assistant", botMessage.text); | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,3 @@ | ||
# flyctl launch added from .gitignore | ||
**/node_modules | ||
fly.toml |
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,2 @@ | ||
node_modules | ||
.env |
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,15 @@ | ||
FROM node | ||
|
||
RUN mkdir -p /usr/src/app | ||
|
||
WORKDIR /usr/src/app | ||
|
||
COPY package.json /usr/src/app/ | ||
|
||
RUN npm install | ||
|
||
COPY . /usr/src/app | ||
|
||
EXPOSE 3000 | ||
|
||
CMD [ "npm", "start" ] |
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,15 @@ | ||
# Basic express server | ||
|
||
Base code from https://github.com/hayk-simonyan/basic-express-api! | ||
|
||
Dockerized express server for testing deployments | ||
|
||
## To run locally | ||
|
||
$ docker build -t basic-express-api . | ||
$ docker run -p 3000:3000 basic-express-api | ||
|
||
## Without docker | ||
|
||
$ npm i | ||
$ npm start |
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 @@ | ||
# fly.toml app configuration file generated for syntaxsorcerer-backend on 2024-08-12T00:47:50-07:00 | ||
# | ||
# See https://fly.io/docs/reference/configuration/ for information about how to use this file. | ||
# | ||
|
||
app = 'syntaxsorcerer-backend' | ||
primary_region = 'sjc' | ||
|
||
[build] | ||
|
||
[http_service] | ||
internal_port = 3000 | ||
force_https = true | ||
auto_stop_machines = 'stop' | ||
auto_start_machines = true | ||
min_machines_running = 0 | ||
processes = ['app'] | ||
|
||
[[vm]] | ||
memory = '1gb' | ||
cpu_kind = 'shared' | ||
cpus = 1 |
Oops, something went wrong.