mirror of
https://github.com/fsecada01/Pygentic-AI.git
synced 2025-06-23 06:46:03 +00:00
WIP: fixed HTML form issues; components not populating correctly yet
This commit is contained in:
parent
b7a466c714
commit
07e7fa09a5
@ -59,11 +59,13 @@ async def analyze_competition(
|
|||||||
logger.info("Error: OpenAI client not initialized.")
|
logger.info("Error: OpenAI client not initialized.")
|
||||||
return ""
|
return ""
|
||||||
try:
|
try:
|
||||||
response = await ctx.deps.client.aio.models.generate_content(
|
response = ctx.deps.client.chat.completions.create(
|
||||||
model=AI_MODEL,
|
model=AI_MODEL,
|
||||||
contents=prompt,
|
messages=[
|
||||||
|
{"role": "system", "content": prompt},
|
||||||
|
],
|
||||||
)
|
)
|
||||||
return response.text
|
return response.choices[0].message.content
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"Error analyzing competition: {e}")
|
logger.error(f"Error analyzing competition: {e}")
|
||||||
return f"Error analyzing competition: {e}"
|
return f"Error analyzing competition: {e}"
|
||||||
@ -84,7 +86,7 @@ async def get_reddit_insights(
|
|||||||
:param subreddit_name: str
|
:param subreddit_name: str
|
||||||
:return: str
|
:return: str
|
||||||
"""
|
"""
|
||||||
subreddit = ctx.deps.reddit.subreddit(subreddit_name)
|
subreddit = ctx.deps.reddit_client.subreddit(subreddit_name)
|
||||||
search_results = subreddit.search(query)
|
search_results = subreddit.search(query)
|
||||||
|
|
||||||
insights = []
|
insights = []
|
||||||
|
File diff suppressed because it is too large
Load Diff
1
src/frontend/static/js/htmx.min.js
vendored
Normal file
1
src/frontend/static/js/htmx.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
@ -8,15 +8,15 @@ trigger: str = 'submit'
|
|||||||
<div class="container">
|
<div class="container">
|
||||||
<form id="{{ form_id }}"
|
<form id="{{ form_id }}"
|
||||||
{% if method.lower() == 'get' %}
|
{% if method.lower() == 'get' %}
|
||||||
hx-get={{ action }}
|
hx-get="{{ action }}"
|
||||||
{% elif method.lower() == 'post' %}
|
{% elif method.lower() == 'post' %}
|
||||||
hx-post={{ action }}
|
hx-post="{{ action }}"
|
||||||
{% elif method.lower() == 'put' %}
|
{% elif method.lower() == 'put' %}
|
||||||
hx-put={{ action }}
|
hx-put="{{ action }}"
|
||||||
{% elif method.lower() == 'delete' %}
|
{% elif method.lower() == 'delete' %}
|
||||||
hx-delete={{ action }}
|
hx-delete="{{ action }}"
|
||||||
{% endif %}
|
{% endif %}
|
||||||
hx-trigger={{ trigger }}
|
hx-trigger="{{ trigger }}"
|
||||||
hx-target="#{{ target }}">
|
hx-target="#{{ target }}">
|
||||||
{{ content }}
|
{{ content }}
|
||||||
</form>
|
</form>
|
||||||
|
@ -9,13 +9,14 @@
|
|||||||
target={{ target }}
|
target={{ target }}
|
||||||
method={{ method }}>
|
method={{ method }}>
|
||||||
<div class="control">
|
<div class="control">
|
||||||
<label for="search"
|
<label for="url"
|
||||||
class="label">Search</label>
|
class="label">Search</label>
|
||||||
<input type="url"
|
<input type="url"
|
||||||
class="input is-rounded"
|
class="input is-rounded"
|
||||||
id="search"
|
id="url"
|
||||||
name="search"
|
name="url"
|
||||||
placeholder="URL" />
|
placeholder="URL"
|
||||||
|
required />
|
||||||
</div>
|
</div>
|
||||||
{{ content }}
|
{{ content }}
|
||||||
</Form>
|
</Form>
|
@ -1,5 +1,4 @@
|
|||||||
<script type="modules"
|
<script src="{{ url_for('static', path='/js/htmx.min.js') }}"></script>
|
||||||
src="{{ url_for('static', path='/js/htmx.js') }}"></script>
|
|
||||||
<script src="{{ url_for('static', path='/js/jquery.min.js') }}"></script>
|
<script src="{{ url_for('static', path='/js/jquery.min.js') }}"></script>
|
||||||
<script src="{{ url_for('static', path='/js/bulma.js') }}"></script>
|
<script src="{{ url_for('static', path='/js/bulma.js') }}"></script>
|
||||||
<script src="{{ url_for('static', path='/js/bulma-collapsible.min.js') }}">
|
<script src="{{ url_for('static', path='/js/bulma-collapsible.min.js') }}">
|
||||||
|
@ -12,17 +12,19 @@
|
|||||||
<div class="container">
|
<div class="container">
|
||||||
<h1 class="title">Search Here</h1>
|
<h1 class="title">Search Here</h1>
|
||||||
<Search form_id="swotSearch"
|
<Search form_id="swotSearch"
|
||||||
action="/analyze"
|
action={{ url_for('analyze_url') }}
|
||||||
target="status"
|
target="status"
|
||||||
method="post">
|
method="post">
|
||||||
<div class="field mt-1 pt-1">
|
<div class="field mt-1 pt-1">
|
||||||
<div class="control">
|
<div class="control">
|
||||||
<button type="submit"
|
<button type="button"
|
||||||
class="button is-success"
|
class="button is-success"
|
||||||
hx-on:click="
|
hx-on:click="
|
||||||
const [status, result] = ['#status', '#result'].map(id => document.querySelector(id));
|
const [status, result] = ['#status', '#result'].map(id => document.querySelector(id));
|
||||||
status.style.display = 'block';
|
status.style.display = 'block';
|
||||||
result.style.display = 'none';
|
result.style.display = 'none';
|
||||||
|
|
||||||
|
htmx.trigger('#swotSearch', 'submit')
|
||||||
">Analyze</button>
|
">Analyze</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -31,12 +33,12 @@
|
|||||||
</section>
|
</section>
|
||||||
<section class="section">
|
<section class="section">
|
||||||
<div class="container"
|
<div class="container"
|
||||||
id="swotAnalysis">
|
id="status">
|
||||||
<div class="box"
|
<div class="box"
|
||||||
id="status"
|
id="status"
|
||||||
hx-get='/status'
|
hx-get='/status'
|
||||||
hx-trigger='load, every 1s'
|
hx-trigger='load, every 1s'
|
||||||
hx-swap='innerHTML transition: false'
|
hx-swap='innerHTML'
|
||||||
style="display: none">
|
style="display: none">
|
||||||
</div>
|
</div>
|
||||||
<div class="box"
|
<div class="box"
|
||||||
@ -54,4 +56,12 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
{% endblock content %}
|
{% endblock content %}
|
||||||
|
{% block js_content %}
|
||||||
|
<script>
|
||||||
|
document.body.addEventListener("htmx:configRequest", function(evt) {
|
||||||
|
console.log("HTMX Request Configured:", evt.detail);
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
{% endblock js_content %}
|
@ -1,3 +1,5 @@
|
|||||||
|
{% if result %}
|
||||||
|
|
||||||
<section class="section">
|
<section class="section">
|
||||||
<div class="container"
|
<div class="container"
|
||||||
id="result-container">
|
id="result-container">
|
||||||
@ -30,4 +32,5 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
{% endif %}
|
@ -6,8 +6,7 @@
|
|||||||
{% set is_loading = loop.last and not result %}
|
{% set is_loading = loop.last and not result %}
|
||||||
{% set is_tool_message = message.startswith('Using tool') %}
|
{% set is_tool_message = message.startswith('Using tool') %}
|
||||||
<div class="box">
|
<div class="box">
|
||||||
{% set bg_color = 'danger' if is_error else ('dark' if is_loading else "info"
|
{% set bg_color = 'danger' if is_error else ('dark' if is_loading else "info") %}
|
||||||
%}
|
|
||||||
{% if is_error %}
|
{% if is_error %}
|
||||||
{% set content = message.split('body:', 1)[1] %}
|
{% set content = message.split('body:', 1)[1] %}
|
||||||
{% elif is_tool_message %}
|
{% elif is_tool_message %}
|
||||||
@ -15,7 +14,7 @@
|
|||||||
{% else %}
|
{% else %}
|
||||||
{% set content = message %}
|
{% set content = message %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<StatusResult :div_class=bg_color>{{ message }}</StatusResult>
|
<StatusResult div_class={{ bg_color }}>{{ message }}</StatusResult>
|
||||||
</div>
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
Loading…
x
Reference in New Issue
Block a user