Spaces:
Build error
Build error
File size: 2,123 Bytes
7e5cb25 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
import Link from "next/link"
import db from "@/utils/db"
export default async function PromptDetails({ params }) {
const { slug } = params
const [prompt] = await db`SELECT * FROM prompts WHERE slug = ${slug}`
// get results with their model (join)
const results =
await db`SELECT * FROM results INNER JOIN models ON results.model = models.id WHERE prompt = ${prompt.id} ORDER BY models.name ASC`
console.log("results", results)
const rubrics = await db`SELECT * FROM rubrics WHERE prompt = ${prompt.id}`
return (
<>
<h3>Prompt asked:</h3>
<br />
<pre style={{ maxWidth: 800 }}>{prompt.text}</pre>
<br />
{prompt.note && <p>Note: {prompt.note}</p>}
<br />
<table>
<thead>
<tr>
<th width={200}>Model</th>
<th>Answer</th>
<th width={150}>Latency</th>
<th width={150}>Rate</th>
<th width={150}>Score</th>
</tr>
</thead>
<tbody>
{results.map((result, i) => (
<tr key={i}>
<td>
<Link
href={`/model/${result.api_id
.split("/")
.pop()
.toLowerCase()}`}
>
{result.name}
</Link>
</td>
<td>
<pre>{result.result.trim().substring(0, 1000)}</pre>
</td>
<td>{parseInt(result.duration)}ms</td>
<td>{result.rate.toFixed(2)}</td>
<td>
{typeof result.score === "number" ? result.score : "not rated"}
</td>
</tr>
))}
</tbody>
</table>
<br />
<pre>
<p>This prompt is automatically graded using these rubrics:</p>
<ul>
{rubrics
.sort((a, b) => a.grading - b.grading)
.map((rubric, i) => (
<li key={i}>
the answer {rubric.grading} ({rubric.points} points)
</li>
))}
</ul>
</pre>
</>
)
}
|