mirror of
https://github.com/senju1337/senju.git
synced 2025-12-24 07:39:29 +00:00
Merge branch 'devel' into docs/OPS-68
This commit is contained in:
commit
7e2f6b7676
6 changed files with 76 additions and 33 deletions
54
.github/workflows/gendocs.yml
vendored
Normal file
54
.github/workflows/gendocs.yml
vendored
Normal file
|
|
@ -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
|
||||||
4
.gitignore
vendored
4
.gitignore
vendored
|
|
@ -175,5 +175,9 @@ pyrightconfig.json
|
||||||
# Ollama Local Dir
|
# Ollama Local Dir
|
||||||
ollama
|
ollama
|
||||||
|
|
||||||
|
|
||||||
|
# Yes i know
|
||||||
|
*.kate-swp
|
||||||
# sphinx rst files
|
# sphinx rst files
|
||||||
docs/source/_modules
|
docs/source/_modules
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -66,13 +66,6 @@ AI_BASE_URL: str = "http://ollama:11434/api"
|
||||||
AI_GEN_ENDPOINT: str = "/generate"
|
AI_GEN_ENDPOINT: str = "/generate"
|
||||||
|
|
||||||
|
|
||||||
def foobar():
|
|
||||||
"""WE KNOW"""
|
|
||||||
a = 3
|
|
||||||
b = 3
|
|
||||||
return a + b
|
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class Haiku:
|
class Haiku:
|
||||||
"""
|
"""
|
||||||
|
|
@ -121,7 +114,8 @@ class Haiku:
|
||||||
ai_response = str(r.json()["response"])
|
ai_response = str(r.json()["response"])
|
||||||
logging.warning(ai_response)
|
logging.warning(ai_response)
|
||||||
lines = ai_response.split("\n")
|
lines = ai_response.split("\n")
|
||||||
for _ in range(0, 2):
|
|
||||||
|
while len(lines) != 3:
|
||||||
lines.pop()
|
lines.pop()
|
||||||
logging.warning(lines)
|
logging.warning(lines)
|
||||||
if len(lines) != 3:
|
if len(lines) != 3:
|
||||||
|
|
|
||||||
|
|
@ -53,13 +53,6 @@ app = Flask(__name__)
|
||||||
store = StoreManager(Path("/tmp/store.db"))
|
store = StoreManager(Path("/tmp/store.db"))
|
||||||
|
|
||||||
|
|
||||||
def foobar():
|
|
||||||
"""WE KNOW"""
|
|
||||||
a = 3
|
|
||||||
b = 3
|
|
||||||
return a + b
|
|
||||||
|
|
||||||
|
|
||||||
@app.route("/")
|
@app.route("/")
|
||||||
def index_view():
|
def index_view():
|
||||||
"""
|
"""
|
||||||
|
|
@ -154,6 +147,8 @@ def generate_haiku():
|
||||||
if request.method == 'POST':
|
if request.method == 'POST':
|
||||||
json_data = request.get_json()
|
json_data = request.get_json()
|
||||||
prompt = json_data["prompt"]
|
prompt = json_data["prompt"]
|
||||||
|
if len(prompt) > 100:
|
||||||
|
return "Content Too Large", 413
|
||||||
haiku = Haiku.request_haiku(prompt)
|
haiku = Haiku.request_haiku(prompt)
|
||||||
id = store.save_haiku(haiku)
|
id = store.save_haiku(haiku)
|
||||||
return str(id)
|
return str(id)
|
||||||
|
|
|
||||||
|
|
@ -56,13 +56,6 @@ from senju.haiku import Haiku
|
||||||
DEFAULT_DB_PATH: Path = Path("/var/lib/senju.json")
|
DEFAULT_DB_PATH: Path = Path("/var/lib/senju.json")
|
||||||
|
|
||||||
|
|
||||||
def foobar():
|
|
||||||
"""WE KNOW"""
|
|
||||||
a = 3
|
|
||||||
b = 3
|
|
||||||
return a + b
|
|
||||||
|
|
||||||
|
|
||||||
class StoreManager:
|
class StoreManager:
|
||||||
"""
|
"""
|
||||||
Manages the storage and retrieval of haiku data using TinyDB.
|
Manages the storage and retrieval of haiku data using TinyDB.
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,8 @@
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
id="user-input"
|
id="user-input"
|
||||||
|
minlength="0"
|
||||||
|
maxlength="100"
|
||||||
placeholder="Type your prompt here..."
|
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"
|
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 responseBox = document.getElementById("response-box");
|
||||||
let responseText = document.getElementById("ai-response");
|
let responseText = document.getElementById("ai-response");
|
||||||
|
|
||||||
|
// Hide the response box initially
|
||||||
|
responseBox.classList.add("opacity-0");
|
||||||
|
|
||||||
if (userInput.trim() === "") {
|
if (userInput.trim() === "") {
|
||||||
responseText.textContent = "Please enter a prompt!";
|
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...";
|
responseText.textContent = "🤖 AI is thinking...";
|
||||||
responseBox.classList.remove("opacity-0");
|
responseBox.classList.remove("opacity-0");
|
||||||
|
|
||||||
// Simulated AI response delay
|
// Simulated AI response delay
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
responseText.textContent = `Sus imposter ඞ`;
|
responseText.textContent = "Sus imposter ඞ";
|
||||||
}, 1500);
|
}, 1500);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
responseText.textContent = "🤖 AI is thinking...";
|
responseText.textContent = "🤖 AI is thinking...";
|
||||||
responseBox.classList.remove("opacity-0");
|
responseBox.classList.remove("opacity-0");
|
||||||
|
|
||||||
console.log(userInput );
|
|
||||||
|
|
||||||
fetch('/api/v1/haiku', {
|
fetch('/api/v1/haiku', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json'
|
'Content-Type': 'application/json'
|
||||||
},
|
},
|
||||||
body: JSON.stringify({'prompt': userInput})
|
body: JSON.stringify({ 'prompt': userInput })
|
||||||
})
|
})
|
||||||
.then(response => response.text())
|
.then(response => response.text())
|
||||||
.then(data => {
|
.then(data => {
|
||||||
console.log(data);
|
|
||||||
let id = parseInt(data, 10);
|
let id = parseInt(data, 10);
|
||||||
window.location.href = "/haiku/"+id;
|
window.location.href = "/haiku/" + id;
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
document.getElementById('result').innerHTML = '<strong>Error:</strong> ' + error.message;
|
responseText.textContent = 'Error: ' + error.message;
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
</script>
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue