diff --git a/.github/workflows/gendocs.yml b/.github/workflows/gendocs.yml
new file mode 100644
index 0000000..a26ace9
--- /dev/null
+++ b/.github/workflows/gendocs.yml
@@ -0,0 +1,54 @@
+name: Build and Store Documentation Artifact
+
+on:
+ push:
+ branches:
+ - master
+ - devel
+
+permissions:
+ contents: read
+ pages: write
+ id-token: write
+
+jobs:
+ build:
+ runs-on: ubuntu-latest
+ environment:
+ name: github-pages
+ url: ${{ steps.deployment.outputs.page_url }}
+ steps:
+ - name: Checkout code
+ uses: actions/checkout@v3
+ - name: Set up Python
+ uses: actions/setup-python@v3
+ with:
+ python-version: '3.11'
+ - name: Install dependencies
+ run: |
+ python -m pip install --upgrade pip
+ pip install sphinx poetry
+ poetry install
+ - name: Build Sphinx documentation
+ run: |
+ cd docs && ls
+ bash auto_docu.sh
+ - name: Upload documentation files as artifact
+ id: deployment
+ uses: actions/upload-pages-artifact@v3 # or specific "vX.X.X" version tag for this action
+ with:
+ path: docs/build/html/
+
+ deploy:
+ needs: build
+
+ # Deploy to the github-pages environment
+ environment:
+ name: github-pages
+ url: ${{ steps.deployment.outputs.page_url }}
+
+ runs-on: ubuntu-latest
+ steps:
+ - name: Deploy to GitHub Pages
+ id: deployment
+ uses: actions/deploy-pages@v4
diff --git a/.gitignore b/.gitignore
index 706bc04..16c5cfa 100644
--- a/.gitignore
+++ b/.gitignore
@@ -175,5 +175,9 @@ pyrightconfig.json
# Ollama Local Dir
ollama
+
+# Yes i know
+*.kate-swp
# sphinx rst files
docs/source/_modules
+
diff --git a/senju/haiku.py b/senju/haiku.py
index d0305c6..950da8b 100644
--- a/senju/haiku.py
+++ b/senju/haiku.py
@@ -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:
diff --git a/senju/main.py b/senju/main.py
index 99d90a9..7f46035 100644
--- a/senju/main.py
+++ b/senju/main.py
@@ -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)
diff --git a/senju/store_manager.py b/senju/store_manager.py
index 883e3e9..a7aa3c9 100644
--- a/senju/store_manager.py
+++ b/senju/store_manager.py
@@ -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.
diff --git a/senju/templates/prompt.html b/senju/templates/prompt.html
index 218809d..3ce5170 100644
--- a/senju/templates/prompt.html
+++ b/senju/templates/prompt.html
@@ -8,6 +8,8 @@
@@ -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 = 'Error: ' + error.message;
+ responseText.textContent = 'Error: ' + error.message;
});
-
}
});
-
{% endblock %}