Merge branch 'devel' into docs/OPS-68

This commit is contained in:
An0nymous 2025-03-23 16:09:14 +00:00 committed by GitHub
commit 7e2f6b7676
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 76 additions and 33 deletions

View file

@ -66,13 +66,6 @@ AI_BASE_URL: str = "http://ollama:11434/api"
AI_GEN_ENDPOINT: str = "/generate"
def foobar():
"""WE KNOW"""
a = 3
b = 3
return a + b
@dataclass
class Haiku:
"""
@ -121,7 +114,8 @@ class Haiku:
ai_response = str(r.json()["response"])
logging.warning(ai_response)
lines = ai_response.split("\n")
for _ in range(0, 2):
while len(lines) != 3:
lines.pop()
logging.warning(lines)
if len(lines) != 3:

View file

@ -53,13 +53,6 @@ app = Flask(__name__)
store = StoreManager(Path("/tmp/store.db"))
def foobar():
"""WE KNOW"""
a = 3
b = 3
return a + b
@app.route("/")
def index_view():
"""
@ -154,6 +147,8 @@ def generate_haiku():
if request.method == 'POST':
json_data = request.get_json()
prompt = json_data["prompt"]
if len(prompt) > 100:
return "Content Too Large", 413
haiku = Haiku.request_haiku(prompt)
id = store.save_haiku(haiku)
return str(id)

View file

@ -56,13 +56,6 @@ from senju.haiku import Haiku
DEFAULT_DB_PATH: Path = Path("/var/lib/senju.json")
def foobar():
"""WE KNOW"""
a = 3
b = 3
return a + b
class StoreManager:
"""
Manages the storage and retrieval of haiku data using TinyDB.

View file

@ -8,6 +8,8 @@
<input
type="text"
id="user-input"
minlength="0"
maxlength="100"
placeholder="Type your prompt here..."
class="w-full px-4 py-3 text-lg border-2 border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-violet-600"
/>
@ -32,42 +34,43 @@ document.getElementById("submit-btn").addEventListener("click", function() {
let responseBox = document.getElementById("response-box");
let responseText = document.getElementById("ai-response");
// Hide the response box initially
responseBox.classList.add("opacity-0");
if (userInput.trim() === "") {
responseText.textContent = "Please enter a prompt!";
}
else if (userInput.length > 100) {
responseText.textContent = "Input must under 100 characters long!";
}
else if (userInput.trim()==="amogus"){
else if (userInput.trim() === "amogus") {
responseText.textContent = "🤖 AI is thinking...";
responseBox.classList.remove("opacity-0");
// Simulated AI response delay
setTimeout(() => {
responseText.textContent = `Sus imposter ඞ`;
responseText.textContent = "Sus imposter ඞ";
}, 1500);
}
}
else {
responseText.textContent = "🤖 AI is thinking...";
responseBox.classList.remove("opacity-0");
console.log(userInput );
fetch('/api/v1/haiku', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({'prompt': userInput})
body: JSON.stringify({ 'prompt': userInput })
})
.then(response => response.text())
.then(data => {
console.log(data);
let id = parseInt(data, 10);
window.location.href = "/haiku/"+id;
window.location.href = "/haiku/" + id;
})
.catch(error => {
document.getElementById('result').innerHTML = '<strong>Error:</strong> ' + error.message;
responseText.textContent = 'Error: ' + error.message;
});
}
});
</script>
{% endblock %}