about summary refs log tree commit diff
diff options
context:
space:
mode:
authorPjotr Prins2026-04-06 09:57:53 +0200
committerPjotr Prins2026-04-06 09:57:53 +0200
commit5da54ef6347acdba3613e3b1b161b66013817206 (patch)
treedcdba71e7c25fa0569f469ae0be777064c81af7d
parent5c28db960087ddb282a13e4dd2c3a3dd5c4cc207 (diff)
downloadgenecup-5da54ef6347acdba3613e3b1b161b66013817206.tar.gz
Create template
-rwxr-xr-xserver.py27
-rw-r--r--templates/create-ontology.html23
2 files changed, 50 insertions, 0 deletions
diff --git a/server.py b/server.py
index c81cbc9..a20d388 100755
--- a/server.py
+++ b/server.py
@@ -346,6 +346,33 @@ def logout():
 def about():
     return render_template('about.html',version=version())
 
+@app.route("/create-ontology", methods=["GET", "POST"])
+def create_ontology():
+    from more_functions import gemini_query
+    default_prompt = (
+        "Give me a list of terms on substance abuse disorder (SUD) that act "
+        "as traits and classifiers in scientific literature with a focus on "
+        "behaviour and brain attributes related to the hippocampus. Avoid "
+        "aliases and synonyms as well as gene names. Each term should be "
+        "1-3 words (max). Give me a list of at least 20, but no more than "
+        "80, most used terms. Return only the terms, one per line, no "
+        "numbering. Add abbreviations and aliases as a list with each term, "
+        "separated by commas")
+    if request.method == "POST":
+        prompt = request.form.get("prompt", default_prompt)
+        try:
+            result = gemini_query(prompt)
+            terms = [t.strip() for t in result.strip().split("\n") if t.strip()]
+            return render_template('create-ontology.html',
+                                   prompt=prompt, result=result,
+                                   count=len(terms), version=version())
+        except Exception as e:
+            return render_template('create-ontology.html',
+                                   prompt=prompt, result=f"Error: {e}",
+                                   count=0, version=version())
+    return render_template('create-ontology.html',
+                           prompt=default_prompt, result=None,
+                           count=0, version=version())
 
 # Ontology selection
 @app.route("/index_ontology", methods=["POST", "GET"])
diff --git a/templates/create-ontology.html b/templates/create-ontology.html
new file mode 100644
index 0000000..44d8ef1
--- /dev/null
+++ b/templates/create-ontology.html
@@ -0,0 +1,23 @@
+{% extends "layout.html" %}
+{% block content %}
+
+<div class="container mt-4">
+  <h3>Create Ontology with Gemini AI</h3>
+
+  <form method="POST" action="/create-ontology">
+    <div class="form-group">
+      <label for="prompt">Prompt:</label>
+      <textarea class="form-control" id="prompt" name="prompt" rows="6">{{ prompt }}</textarea>
+    </div>
+    <button type="submit" class="btn btn-primary">Create Ontology</button>
+  </form>
+
+  {% if result %}
+  <div class="form-group mt-4">
+    <label for="result">Result ({{ count }} terms):</label>
+    <textarea class="form-control" id="result" rows="20" readonly>{{ result }}</textarea>
+  </div>
+  {% endif %}
+</div>
+
+{% endblock %}