diff options
Diffstat (limited to 'templates')
| -rw-r--r-- | templates/call-gemini.html | 11 | ||||
| -rw-r--r-- | templates/create-ontology.html | 48 | ||||
| -rw-r--r-- | templates/genenames.html | 73 | ||||
| -rw-r--r-- | templates/layout.html | 8 |
4 files changed, 132 insertions, 8 deletions
diff --git a/templates/call-gemini.html b/templates/call-gemini.html new file mode 100644 index 0000000..29a50d8 --- /dev/null +++ b/templates/call-gemini.html @@ -0,0 +1,11 @@ +{% extends "layout.html" %} +{% block content %} + +<meta http-equiv="refresh" content="1; url={{ url }}"> + +<br> +<h3>Calling Gemini API...</h3> +<p>Classifying {{ count }} sentences as cellular/organismal stress.</p> +<p>Please wait, this page will refresh automatically.</p> + +{% endblock %} diff --git a/templates/create-ontology.html b/templates/create-ontology.html new file mode 100644 index 0000000..537c246 --- /dev/null +++ b/templates/create-ontology.html @@ -0,0 +1,48 @@ +{% extends "layout.html" %} +{% block content %} + +<div class="container mt-4"> + <h3>Create Ontology with Gemini AI</h3> + + <form method="POST" action="/create-ontology"> + <input type="hidden" name="action" value="generate"> + <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" onclick="this.style.backgroundColor='#87CEEB'; this.style.borderColor='#87CEEB';">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" name="result" rows="20" form="search-form">{{ result }}</textarea> + </div> + + <form id="search-form" method="POST" action="/create-ontology" class="mt-3"> + <input type="hidden" name="action" value="search"> + <div class="form-group"> + <label for="query">Gene symbols (space or comma separated):</label> + <textarea class="form-control" id="query" name="query" rows="2"></textarea> + </div> + <div id="check_selection_onto"></div> + <button type="submit" class="btn btn-primary" onclick="if(!document.getElementById('query').value.trim()){alert('Please enter at least one gene symbol');return false;}">Search</button> + </form> + + <script> + var lines = document.getElementById('result').value.split('\n'); + var checkbox = ''; + for (var i = 0; i < lines.length; i++) { + var term = lines[i].trim(); + if (term) { + var label = term.split(',')[0].trim(); + checkbox += '<strong><input type="checkbox" name="type" value="' + label + '" checked form="search-form"> ' + label + ' </strong>'; + } + } + checkbox += '<br><strong><input type="checkbox" onClick="var c=document.querySelectorAll(\'input[name=type]\');for(var i=0;i<c.length;i++)c[i].checked=this.checked;"/> (Un)select all</strong>'; + document.getElementById('check_selection_onto').innerHTML = checkbox; + </script> + {% endif %} +</div> + +{% endblock %} diff --git a/templates/genenames.html b/templates/genenames.html index fe22d0b..d1e4960 100644 --- a/templates/genenames.html +++ b/templates/genenames.html @@ -18,11 +18,76 @@ {%endfor%} </ul> <br> - {%else%} + {# --- Added Section for Gemini Prompt --- #} + {% if prompt %} + <div style="display: flex; align-items: center; gap: 10px;"> + <h4>LLM Prompt for {{gene}}</h4> + <button id="copy-button" onclick="copyPromptToClipboard()" class="btn btn-secondary btn-sm">Copy Prompt</button> + </div> + <textarea id="prompt-textarea" rows="20" cols="100" readonly style="width:100%; font-family: monospace; white-space: pre-wrap; word-wrap: break-word;"> +{{ prompt }} + </textarea> + + <script> + function copyPromptToClipboard() { + // Get the textarea element + var textArea = document.getElementById("prompt-textarea"); + var copyButton = document.getElementById("copy-button"); + + try { + // Modern browsers: Use the Clipboard API + navigator.clipboard.writeText(textArea.value).then(function() { + // Success feedback + copyButton.innerText = "Copied!"; + setTimeout(function() { + copyButton.innerText = "Copy Prompt"; + }, 2000); // Revert back to "Copy" after 2 seconds + }, function(err) { + // Error callback for modern API + console.error('Async: Could not copy text: ', err); + // If this fails, try the fallback method + fallbackCopyTextToClipboard(textArea, copyButton); + }); + + } catch (err) { + // If navigator.clipboard is not supported at all, go directly to fallback + console.log('Clipboard API not available, using fallback.'); + fallbackCopyTextToClipboard(textArea, copyButton); + } + } + + function fallbackCopyTextToClipboard(element, button) { + // Select the text field + element.select(); + + // --- THIS IS THE FIX --- + // Set the selection range to the full length of the content. + // This removes the arbitrary 99999 character limit. + element.setSelectionRange(0, element.value.length); + + try { + var successful = document.execCommand('copy'); + if (successful) { + button.innerText = "Copied!"; + setTimeout(function() { + button.innerText = "Copy Prompt"; + }, 2000); + } else { + alert('Oops, unable to copy. Please copy manually.'); + } + } catch (err) { + console.error('Fallback: Oops, unable to copy', err); + alert('Oops, unable to copy. Please copy manually.'); + } + } + </script> + {% else %} + <p>Prompt generation failed or no sentences found.</p> + {% endif %} + {# --- END OF MODIFIED SECTION --- #} + +{%else%} No synonym for {{gene}} is found. {%endif%} <br> {% endblock %} - - - diff --git a/templates/layout.html b/templates/layout.html index 3160de5..ce59f13 100644 --- a/templates/layout.html +++ b/templates/layout.html @@ -16,7 +16,7 @@ <body> <!-- Navigation bar --> -<nav class="navbar navbar-expand-lg navbar-dark bg-dark"> +<nav class="navbar navbar-expand-lg navbar-dark"> <div class="col-1"> <a href="/"><div class='img'><img src="/static/white_logo.png" class="img-fluid", style="width:60%"></div></a> </div> @@ -95,16 +95,16 @@ </div> {% if not no_footer %} - <footer class="footer bg-dark footer-dark"> + <footer class="footer footer-dark"> <div class="container"> <div class="row"> <div class="col-md-6"> - GeneCup {{ version }}: PubMed + GWAS catalog deep learning. + GeneCup {{ version }}: PubMed + GWAS catalog using LLMs. Cite <a href="https://academic.oup.com/g3journal/article/12/5/jkac059/6548160">GeneCup.</a> </div> <div class="col-md-6" align="right"> <a href="https://git.genenetwork.org/genecup/">Code</a> - powered by <a href="https://www.tensorflow.org/">Tensorflow</a> on <a href="https://genenetwork.org/">GeneNetwork.org</a> + powered by <a href="https://gemini.google.com/">Google Gemini</a> on <a href="https://genenetwork.org/">GeneNetwork.org</a> </div> </div> </div> |
