Comparisons (synastry) of the own chart and persons
/osszevetesek compares any two of the user's charts (own and persons); the person card and the person's chart page have "Összevetés velem". The comparison page shows a double wheel (first person inside with houses, second outside, aspects between them), the aspects by character, and tabs: paid relationship analysis (synastry unit), the cross aspect grid, house overlays, composite and the full aspect list. Correcting a person within the hour now deletes the user's own comparisons with them instead of being refused; still refused after a paid analysis or when someone else's comparison uses the chart. The relationship analysis prompt is editable on /admin/promptok too, and can be tried on one of the admin's comparisons. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012vLHzh5qUhFtmJhzkcTbXL
This commit is contained in:
@@ -45,7 +45,8 @@ pub struct Job {
|
||||
pub struct PreviewJob {
|
||||
pub id: Uuid,
|
||||
pub kind: String,
|
||||
pub chart_id: Uuid,
|
||||
pub chart_id: Option<Uuid>,
|
||||
pub synastry_id: Option<Uuid>,
|
||||
pub language: String,
|
||||
pub model: String,
|
||||
pub system: String,
|
||||
@@ -91,21 +92,9 @@ impl Analyzer {
|
||||
pub async fn prompt_for(&self, job: &Job) -> Result<Prompt, LlmError> {
|
||||
let kind = Kind::parse(&job.kind).ok_or_else(|| LlmError::Permanent(format!("unknown kind '{}'", job.kind)))?;
|
||||
let db_err = |e: sqlx::Error| LlmError::Transient(format!("database: {e}"));
|
||||
let gone = || LlmError::Permanent("the chart was deleted".into());
|
||||
let text = match kind {
|
||||
Kind::Natal | Kind::Summary => self.natal_text(job.chart_id).await?,
|
||||
Kind::Synastry => {
|
||||
let (result, chart1, chart2): (Value, Value, Value) = sqlx::query_as(
|
||||
"SELECT s.result, c1.result, c2.result FROM synastries s \
|
||||
JOIN charts c1 ON c1.id = s.chart1_id JOIN charts c2 ON c2.id = s.chart2_id WHERE s.id = $1",
|
||||
)
|
||||
.bind(job.synastry_id)
|
||||
.fetch_optional(&self.db)
|
||||
.await
|
||||
.map_err(db_err)?
|
||||
.ok_or_else(gone)?;
|
||||
compact::synastry(&chart1, &chart2, &result)
|
||||
}
|
||||
Kind::Synastry => self.synastry_text(job.synastry_id).await?,
|
||||
};
|
||||
let (base, revision) = prompt::split_version(&job.prompt_version);
|
||||
if base != PROMPT_VERSION {
|
||||
@@ -135,13 +124,27 @@ impl Analyzer {
|
||||
Ok(compact::natal(&chart))
|
||||
}
|
||||
|
||||
/// The compact text of a stored synastry with its two charts.
|
||||
async fn synastry_text(&self, synastry_id: Option<Uuid>) -> Result<String, LlmError> {
|
||||
let (result, chart1, chart2): (Value, Value, Value) = sqlx::query_as(
|
||||
"SELECT s.result, c1.result, c2.result FROM synastries s \
|
||||
JOIN charts c1 ON c1.id = s.chart1_id JOIN charts c2 ON c2.id = s.chart2_id WHERE s.id = $1",
|
||||
)
|
||||
.bind(synastry_id)
|
||||
.fetch_optional(&self.db)
|
||||
.await
|
||||
.map_err(|e| LlmError::Transient(format!("database: {e}")))?
|
||||
.ok_or_else(|| LlmError::Permanent("the synastry was deleted".into()))?;
|
||||
Ok(compact::synastry(&chart1, &chart2, &result))
|
||||
}
|
||||
|
||||
/// Takes the oldest waiting prompt test run, if any.
|
||||
pub async fn claim_preview(&self) -> Result<Option<PreviewJob>, sqlx::Error> {
|
||||
let job: Option<PreviewJob> = sqlx::query_as(
|
||||
"UPDATE prompt_previews SET status = 'running', started_at = now() \
|
||||
WHERE id = (SELECT id FROM prompt_previews WHERE status = 'pending' \
|
||||
ORDER BY created_at LIMIT 1 FOR UPDATE SKIP LOCKED) \
|
||||
RETURNING id, kind, chart_id, language, model, system",
|
||||
RETURNING id, kind, chart_id, synastry_id, language, model, system",
|
||||
)
|
||||
.fetch_optional(&self.db)
|
||||
.await?;
|
||||
@@ -155,10 +158,12 @@ impl Analyzer {
|
||||
pub async fn handle_preview(&self, job: PreviewJob) {
|
||||
let started = Instant::now();
|
||||
let result = async {
|
||||
let kind = Kind::parse(&job.kind)
|
||||
.filter(|k| *k != Kind::Synastry)
|
||||
.ok_or_else(|| LlmError::Permanent(format!("unknown kind '{}'", job.kind)))?;
|
||||
let text = self.natal_text(Some(job.chart_id)).await?;
|
||||
let kind =
|
||||
Kind::parse(&job.kind).ok_or_else(|| LlmError::Permanent(format!("unknown kind '{}'", job.kind)))?;
|
||||
let text = match kind {
|
||||
Kind::Synastry => self.synastry_text(job.synastry_id).await?,
|
||||
_ => self.natal_text(job.chart_id).await?,
|
||||
};
|
||||
let built = prompt::build(kind, &job.language, &text, Some(&job.system));
|
||||
let mut c = self.llm.complete(&job.model, &built).await?;
|
||||
prompt::polish(&job.language, &mut c.content);
|
||||
|
||||
Reference in New Issue
Block a user