Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!-- templates/index.html -->
- <!DOCTYPE html>
- <html>
- <head>
- <title>CK3 Faith Maker</title>
- <link rel="stylesheet" href="{{ url_for('static', filename='style.css') }}">
- </head>
- <body>
- <h1>CK3 Faith Maker</h1>
- <form method="POST">
- <label for="religion_name">Enter Religion Name:</label><br>
- <input type="text" name="religion_name"><br><br>
- <p>Select three tenets:</p>
- {% for tenet in available_tenets %}
- <input type="checkbox" name="selected_tenets" value="{{ tenet }}">{{ tenet }}<br>
- {% endfor %}
- <!-- ... (previous input fields) -->
- <input type="submit" value="Generate Religion">
- </form>
- <h2>Generated Religion:</h2>
- <p>{{ generated_religion }}</p>
- </body>
- </html>
- <!-- app.py -->
- from flask import Flask, render_template, request
- import openai
- from config import OPENAI_API_KEY
- # OPENAI_API_KEY is my API key in the config.py file (same level as app.py)
- # OPENAI_API_KEY = "sk-[otherstuffhere]"
- app = Flask(__name__)
- openai.api_key = OPENAI_API_KEY
- # Define the available tenets
- available_tenets = [
- "Polyamory", "Pursuit of Power", "Religious Law", "Ritual Cannibalism", "Ritual Celebrations",
- "Sacred Lies", "Sanctity of Nature", "Tax Nonbelievers", "Unrelenting Faith", "Vows of Poverty",
- "Adorcism", "Alexandrian Catechism", "Ancestor Worship", "Aniconism", "Armed Pilgrimages",
- "Auspicious Birthright", "Bhakti", "Dharmic Pacifism", "Hedonistic", "Human Sacrifice",
- "Inner Journey", "Pacifism", "Pastoral Isolation", "Reincarnation", "Rite", "Ritual Hospitality",
- "Ritual Suicide", "Sacred Childbirth", "Sacrificial Ceremonies", "Sanctioned False Conversions",
- "Sky Burials", "Struggle and Submission", "Sun Worship", "Warmonger", "Gruesome Festivals",
- "Christian Syncretism", "Islamic Syncretism", "Jewish Syncretism", "Eastern Syncretism",
- "Syncretic Folk Traditions"
- ]
- # Function to find the closest matching tenets based on user input
- def find_relevant_tenets(user_input):
- relevant_tenets = []
- user_keywords = user_input.split() # Split user input into keywords
- # Dictionary to store tenets and their relevance scores
- tenet_scores = {}
- # Calculate relevance scores for each tenet based on keyword matching
- for tenet in available_tenets:
- tenet_keywords = tenet.lower().split() # Split tenet into keywords
- relevance_score = sum(keyword in tenet_keywords for keyword in user_keywords)
- tenet_scores[tenet] = relevance_score
- # Select the top three relevant tenets
- relevant_tenets = sorted(tenet_scores, key=lambda x: tenet_scores[x], reverse=True)[:3]
- return relevant_tenets
- @app.route('/', methods=['GET', 'POST'])
- def index():
- generated_religion = ""
- if request.method == 'POST':
- religion_name = request.form['religion_name']
- user_input = religion_name.lower() # Convert user input to lowercase for comparison
- selected_tenets = find_relevant_tenets(user_input)
- # Create a list of doctrines and tenets based on user's religion input
- main_doctrines = {
- "Views on Gender": ["Male Dominated", "Equal", "Female Dominated"],
- "Religious Attitude": ["Fundamentalist", "Righteous", "Pluralist"],
- "Clerical Tradition": ["Theocratic", "Lay Clergy"],
- "Head of Faith": ["None", "Spiritual", "Temporal"],
- "Pilgrimage Attitude": ["Forbidden", "Encouraged", "Mandatory"],
- # Add more main doctrines...
- }
- marriage_doctrines = {
- "Marriage Type": ["mono", "poly", "Consorts/Concubines"],
- "Divorced": ["disallowed", "Must be Approved", "Always allowed"],
- "Bastardy": ["None", "Legitimization", "No Legitimization"],
- "Consanguinity": ["Close-kin Taboo", "Cousin", "Avunculate", "Unrestricted"],
- # Add more marriage doctrines...
- }
- crime_doctrines = {
- "Same Sex": ["Crime", "Shunned", "Accepted"],
- "Male Adultery": ["Crime", "Shunned", "Accepted"],
- "Female Adultery": ["Crime", "Shunned", "Accepted"],
- "Deviancy": ["Crime", "Shunned", "Accepted"],
- "Witch": ["Crime", "Shunned", "Accepted", "Virtuous"],
- "Kinslaying": ["Dynastic is Crime", "Familial is Crime", "Close-kin is Crime", "Shunned Accepted"],
- # Add more crime doctrines...
- }
- clerical_doctrines = {
- "Clerical Function": ["control", "alms and pacification", "recruitment"],
- "Clerical Gender": ["only men", "either", "only women"],
- "Clerical Marriage": ["allowed", "disallowed"],
- "Clerical Appointment": ["Temporal+Revocable", "Spiritual+Revocable", "Temporal+for Life", "Spiritual+for Life"],
- # Add more clerical doctrines...
- }
- # Construct the prompt
- prompt = f"Generate a CK3 religion based on the following beliefs:\n"
- prompt += f"Religion Name: {religion_name}\n"
- prompt += f"Selected Tenets: {', '.join(selected_tenets)}\n"
- for doctrine, options in main_doctrines.items():
- prompt += f"{doctrine}: {options}\n"
- for doctrine, options in marriage_doctrines.items():
- prompt += f"{doctrine}: {options}\n"
- for doctrine, options in crime_doctrines.items():
- prompt += f"{doctrine}: {options}\n"
- for doctrine, options in clerical_doctrines.items():
- prompt += f"{doctrine}: {options}\n"
- # Call OpenAI API to generate religion based on user input
- response = openai.Completion.create(
- engine="text-davinci-003", # Choose the appropriate engine
- prompt=prompt,
- max_tokens=300 # Adjust as needed
- )
- generated_religion = response.choices[0].text
- return render_template('index.html', generated_religion=generated_religion)
- if __name__ == '__main__':
- app.run(debug=True)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement