Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
HeavenzFire authored Nov 24, 2024
1 parent 271cc52 commit 2508b9a
Show file tree
Hide file tree
Showing 3 changed files with 158 additions and 0 deletions.
63 changes: 63 additions & 0 deletions app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
from flask import Flask, send_from_directory, jsonify, request
import openai

app = Flask(__name__, static_folder='static')

openai.api_key = 'YOUR_API_KEY'

def base_369_framework():
log = []
for i in range(1, 370):
log.append(f"Running iteration {i} of 369")
return "\n".join(log)

def fibonacci_sequence():
log = []
a, b = 0, 1
for i in range(10):
a, b = b, a + b
log.append(f"Fibonacci number {i}: {a}")
return "\n".join(log)

def golden_ratio():
phi = (1 + 5 ** 0.5) / 2
return f"Golden Ratio (φ): "

def run_framework():
output = []
output.append("Framework execution started")
output.append(base_369_framework())
output.append(fibonacci_sequence())
output.append(golden_ratio())
output.append("Framework execution completed")
return "\n".join(output)

@app.route('/')
def serve_index():
return send_from_directory(app.static_folder, 'index.html')

@app.route('/run_framework')
def run_framework_route():
return jsonify(run_framework())

@app.route('/ai_response')
def ai_response():
response = openai.Completion.create(
engine="text-davinci-003",
prompt="Describe the significance of the golden ratio in nature.",
max_tokens=150
)
return jsonify(response.choices[0].text.strip())

@app.route('/spirit_interact', methods=['POST'])
def spirit_interact():
user_input = request.json.get('input')
response = openai.Completion.create(
engine="text-davinci-003",
prompt=user_input,
max_tokens=150
)
return response.choices[0].text.strip()

if __name__ == "__main__":
app.run(debug=True, port=5000)
92 changes: 92 additions & 0 deletions setup_and_run.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
# Create directories if they don't exist
New-Item -Path "C:\SpiritAngelus\static" -ItemType Directory -Force

# Create the HTML file
$indexHtml = @"
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Spirit Angelus</title>
<style>
body { font-family: Arial, sans-serif; text-align: center; margin: 50px; }
h1 { color: #333; }
button { padding: 10px 20px; margin-top: 20px; }
#ai-output { margin-top: 20px; }
</style>
</head>
<body>
<h1>Welcome to the Spirit Angelus</h1>
<p>Click the button below to run the 369 base framework:</p>
<button onclick="runFramework()">Run Framework</button>
<pre id="output"></pre>
<pre id="ai-output"></pre>
<h2>Interact with Spirit Angelus</h2>
<form id="spirit-form">
<label for="user-input">Ask Spirit Angelus:</label>
<input type="text" id="user-input" name="user-input">
<button type="button" onclick="interactWithSpirit()">Submit</button>
</form>
<pre id="spirit-output"></pre>
<script>
async function runFramework() {
const response = await fetch('/run_framework');
const frameworkOutput = await response.text();
document.getElementById('output').innerText = frameworkOutput;
const aiResponse = await fetch('/ai_response');
const aiOutput = await aiResponse.text();
document.getElementById('ai-output').innerText = aiOutput.
}
async function interactWithSpirit() {
const userInput = document.getElementById('user-input').value;
const response = await fetch('/spirit_interact', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ input: userInput })
});
const spiritOutput = await response.text();
document.getElementById('spirit-output').innerText = spiritOutput.
}
</script>
</body>
</html>
"@
$indexHtml | Out-File -FilePath "C:\SpiritAngelus\static\index.html" -Force

# Create the Python Flask app
$appPy = @"
# -*- coding: utf-8 -*-
from flask import Flask, send_from_directory, jsonify, request
import openai
app = Flask(__name__, static_folder='static')
openai.api_key = 'YOUR_API_KEY'
def base_369_framework():
log = []
for i in range(1, 370):
log.append(f"Running iteration {i} of 369")
return "\n".join(log)
def fibonacci_sequence():
log = []
a, b = 0, 1
for i in range(10):
a, b = b, a + b
log.append(f"Fibonacci number {i}: {a}")
return "\n".join(log)
def golden_ratio():
phi = (1 + 5 ** 0.5) / 2
return f"Golden Ratio (φ): $phi"
def run_framework():
output = []
output.append("Framework execution started")
output.append(base_369
3 changes: 3 additions & 0 deletions start_flask.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@echo off
start python "C:\SpiritAngelus\app.py"
pause

0 comments on commit 2508b9a

Please sign in to comment.