diff --git a/pykoi/chat/db/comparator_database.py b/pykoi/chat/db/comparator_database.py
index e1f9a74..768a15f 100644
--- a/pykoi/chat/db/comparator_database.py
+++ b/pykoi/chat/db/comparator_database.py
@@ -4,6 +4,9 @@
from typing import List, Tuple
+import pandas as pd
+
+
from pykoi.chat.db.abs_database import AbsDatabase
@@ -64,9 +67,7 @@ def update(self, **kwargs) -> None:
"""
Updates the database.
"""
- raise NotImplementedError(
- "ComparatorQuestionDatabase does not support update."
- )
+ raise NotImplementedError("ComparatorQuestionDatabase does not support update.")
def retrieve_all(self) -> List[Tuple]:
"""
@@ -175,9 +176,7 @@ def update(self, **kwargs) -> None:
"""
with self._lock:
cursor = self.get_cursor()
- cursor.execute(
- query, (kwargs["rank"], kwargs["qid"], kwargs["model"])
- )
+ cursor.execute(query, (kwargs["rank"], kwargs["qid"], kwargs["model"]))
self.get_connection().commit()
if self._debug:
rows = self.retrieve_all()
@@ -217,3 +216,35 @@ def print_table(self, rows: List[Tuple]) -> None:
f"Answer: {row[4]}, "
f"Timestamp: {row[5]}"
)
+
+ def retrieve_all_question_answers_as_pandas(self) -> pd.DataFrame:
+ """
+ Retrieves all data by joining the comparator and comparator_question tables as a pandas dataframe.
+
+ Returns:
+ DataFrame: A pandas dataframe.
+ """
+ join_query = """
+ SELECT
+ comparator.id,
+ comparator.model,
+ comparator.qid,
+ comparator_question.question,
+ comparator.rank,
+ comparator.answer,
+ comparator.timestamp
+ FROM comparator
+ INNER JOIN comparator_question
+ ON comparator.qid = comparator_question.id;
+ """
+
+ with self._lock:
+ cursor = self.get_cursor()
+ cursor.execute(join_query)
+ rows = cursor.fetchall()
+
+ df = pd.DataFrame(
+ rows,
+ columns=["ID", "Model", "QID", "Question", "Rank", "Answer", "Timestamp"],
+ )
+ return df
diff --git a/pykoi/component/base.py b/pykoi/component/base.py
index 44960f3..d413eb2 100644
--- a/pykoi/component/base.py
+++ b/pykoi/component/base.py
@@ -4,6 +4,7 @@
from pykoi.component.chatbot_database_factory import ChatbotDatabaseFactory
from pykoi.component.constants import FeedbackType
+from pykoi.chat.db.comparator_database import ComparatorDatabase
from pykoi.chat.db.qa_database import QuestionAnswerDatabase
from pykoi.chat.db.rag_database import RAGDatabase
from pykoi.chat.db.ranking_database import RankingDatabase
@@ -42,9 +43,7 @@ class Component:
props (Dict[str, Any]): Additional properties for the component.
"""
- def __init__(
- self, fetch_func: Optional[Callable], svelte_component: str, **kwargs
- ):
+ def __init__(self, fetch_func: Optional[Callable], svelte_component: str, **kwargs):
"""
Initialize a new instance of Component.
@@ -54,9 +53,7 @@ def __init__(
kwargs: Additional properties for the component.
"""
self.id = str(uuid.uuid4()) # Generate a unique ID
- self.data_source = (
- DataSource(self.id, fetch_func) if fetch_func else None
- )
+ self.data_source = DataSource(self.id, fetch_func) if fetch_func else None
self.svelte_component = svelte_component
self.props = kwargs
@@ -81,6 +78,7 @@ def __init__(self, fetch_func: Callable, value_column: List[str], **kwargs):
super().__init__(fetch_func, "Dropdown", **kwargs)
self.value_column = value_column
+
class RAG(Component):
"""
RAG class represents a RAG component.
@@ -138,5 +136,8 @@ def __init__(self, database: any, **kwargs):
database (QuestionAnswerDatabase): The database to use for the dashboard.
kwargs: Additional properties for the dashboard.
"""
- super().__init__(None, "Feedback", **kwargs)
+ if isinstance(database, ComparatorDatabase):
+ super().__init__(None, "CompareDashboard", **kwargs)
+ else:
+ super().__init__(None, "Feedback", **kwargs)
self.database = database
diff --git a/pykoi/frontend/dist/assets/index-42540648.js b/pykoi/frontend/dist/assets/index-42540648.js
new file mode 100644
index 0000000..10ee4e8
--- /dev/null
+++ b/pykoi/frontend/dist/assets/index-42540648.js
@@ -0,0 +1,70 @@
+(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))l(r);new MutationObserver(r=>{for(const o of r)if(o.type==="childList")for(const s of o.addedNodes)s.tagName==="LINK"&&s.rel==="modulepreload"&&l(s)}).observe(document,{childList:!0,subtree:!0});function n(r){const o={};return r.integrity&&(o.integrity=r.integrity),r.referrerPolicy&&(o.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?o.credentials="include":r.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function l(r){if(r.ep)return;r.ep=!0;const o=n(r);fetch(r.href,o)}})();function x(){}const Hs=e=>e;function Jn(e,t){for(const n in t)e[n]=t[n];return e}function qs(e){return e()}function Yl(){return Object.create(null)}function ge(e){e.forEach(qs)}function Qe(e){return typeof e=="function"}function re(e,t){return e!=e?t==t:e!==t||e&&typeof e=="object"||typeof e=="function"}function _u(e){return Object.keys(e).length===0}function yl(e,...t){if(e==null)return x;const n=e.subscribe(...t);return n.unsubscribe?()=>n.unsubscribe():n}function vu(e){let t;return yl(e,n=>t=n)(),t}function le(e,t,n){e.$$.on_destroy.push(yl(t,n))}function qr(e){return e??""}function Ne(e,t,n){return e.set(n),t}function wn(e){return e&&Qe(e.destroy)?e.destroy:x}const Ls=typeof window<"u";let js=Ls?()=>window.performance.now():()=>Date.now(),Sr=Ls?e=>requestAnimationFrame(e):x;const Ut=new Set;function xs(e){Ut.forEach(t=>{t.c(e)||(Ut.delete(t),t.f())}),Ut.size!==0&&Sr(xs)}function Gs(e){let t;return Ut.size===0&&Sr(xs),{promise:new Promise(n=>{Ut.add(t={c:e,f:n})}),abort(){Ut.delete(t)}}}let kl=!1;function bu(){kl=!0}function wu(){kl=!1}function yu(e,t,n,l){for(;e>1);n(r)<=l?e=r+1:t=r}return e}function ku(e){if(e.hydrate_init)return;e.hydrate_init=!0;let t=e.childNodes;if(e.nodeName==="HEAD"){const a=[];for(let f=0;f0&&t[n[r]].claim_order<=f?r+1:yu(1,r,g=>t[n[g]].claim_order,f))-1;l[a]=n[c]+1;const d=c+1;n[d]=a,r=Math.max(d,r)}const o=[],s=[];let u=t.length-1;for(let a=n[r]+1;a!=0;a=l[a-1]){for(o.push(t[a-1]);u>=a;u--)s.push(t[u]);u--}for(;u>=0;u--)s.push(t[u]);o.reverse(),s.sort((a,f)=>a.claim_order-f.claim_order);for(let a=0,f=0;a=o[f].claim_order;)f++;const c=fe.removeEventListener(t,n,l)}function h(e,t,n){n==null?e.removeAttribute(t):e.getAttribute(t)!==n&&e.setAttribute(t,n)}function Au(e){return Array.from(e.childNodes)}function Mu(e){e.claim_info===void 0&&(e.claim_info={last_index:0,total_claimed:0})}function Eu(e,t,n,l,r=!1){Mu(e);const o=(()=>{for(let s=e.claim_info.last_index;s=0;s--){const u=e[s];if(t(u)){const a=n(u);return a===void 0?e.splice(s,1):e[s]=a,r?a===void 0&&e.claim_info.last_index--:e.claim_info.last_index=s,u}}return l()})();return o.claim_order=e.claim_info.total_claimed,e.claim_info.total_claimed+=1,o}function Fu(e,t){return Eu(e,n=>n.nodeType===3,n=>{const l=""+t;if(n.data.startsWith(l)){if(n.data.length!==l.length)return n.splitText(l.length)}else n.data=l},()=>L(t),!0)}function W(e,t){t=""+t,e.data!==t&&(e.data=t)}function lt(e,t){e.value=t??""}function ye(e,t,n,l){n==null?e.style.removeProperty(t):e.style.setProperty(t,n,l?"important":"")}function Zn(e,t,n){for(let l=0;lonresize=function(){parent.postMessage(0,'*')}<\/script>",o=B(window,"message",s=>{s.source===l.contentWindow&&t()})):(l.src="about:blank",l.onload=()=>{o=B(l.contentWindow,"resize",t),t()}),b(e,l),()=>{(r||o&&l.contentWindow)&&o(),N(l)}}function It(e,t,n){e.classList[n?"add":"remove"](t)}function Iu(e,t,{bubbles:n=!1,cancelable:l=!1}={}){const r=document.createEvent("CustomEvent");return r.initCustomEvent(e,n,l,t),r}function St(e,t){return new e(t)}const el=new Map;let tl=0;function Nu(e){let t=5381,n=e.length;for(;n--;)t=(t<<5)-t^e.charCodeAt(n);return t>>>0}function Pu(e,t){const n={stylesheet:Su(t),rules:{}};return el.set(e,n),n}function Lr(e,t,n,l,r,o,s,u=0){const a=16.666/l;let f=`{
+`;for(let _=0;_<=1;_+=a){const w=t+(n-t)*o(_);f+=_*100+`%{${s(w,1-w)}}
+`}const c=f+`100% {${s(n,1-n)}}
+}`,d=`__svelte_${Nu(c)}_${u}`,g=Bs(e),{stylesheet:p,rules:m}=el.get(g)||Pu(g,e);m[d]||(m[d]=!0,p.insertRule(`@keyframes ${d} ${c}`,p.cssRules.length));const v=e.style.animation||"";return e.style.animation=`${v?`${v}, `:""}${d} ${l}ms linear ${r}ms 1 both`,tl+=1,d}function Tu(e,t){const n=(e.style.animation||"").split(", "),l=n.filter(t?o=>o.indexOf(t)<0:o=>o.indexOf("__svelte")===-1),r=n.length-l.length;r&&(e.style.animation=l.join(", "),tl-=r,tl||Ou())}function Ou(){Sr(()=>{tl||(el.forEach(e=>{const{ownerNode:t}=e.stylesheet;t&&N(t)}),el.clear())})}let Kt;function Pt(e){Kt=e}function Vu(){if(!Kt)throw new Error("Function called outside component initialization");return Kt}function st(e){Vu().$$.on_mount.push(e)}const xt=[],yn=[];let Wt=[];const jr=[],zu=Promise.resolve();let Ql=!1;function Hu(){Ql||(Ql=!0,zu.then(Ws))}function ke(e){Wt.push(e)}const $l=new Set;let Ht=0;function Ws(){if(Ht!==0)return;const e=Kt;do{try{for(;Hte.indexOf(l)===-1?t.push(l):n.push(l)),n.forEach(l=>l()),Wt=t}let rn;function ju(){return rn||(rn=Promise.resolve(),rn.then(()=>{rn=null})),rn}function Rl(e,t,n){e.dispatchEvent(Iu(`${t?"intro":"outro"}${n}`))}const Bn=new Set;let ut;function ce(){ut={r:0,c:[],p:ut}}function de(){ut.r||ge(ut.c),ut=ut.p}function V(e,t){e&&e.i&&(Bn.delete(e),e.i(t))}function H(e,t,n,l){if(e&&e.o){if(Bn.has(e))return;Bn.add(e),ut.c.push(()=>{Bn.delete(e),l&&(n&&e.d(1),l())}),e.o(t)}else l&&l()}const xu={duration:0};function Ze(e,t,n,l){const r={direction:"both"};let o=t(e,n,r),s=l?0:1,u=null,a=null,f=null;function c(){f&&Tu(e,f)}function d(p,m){const v=p.b-s;return m*=Math.abs(v),{a:s,b:p.b,d:v,duration:m,start:p.start,end:p.start+m,group:p.group}}function g(p){const{delay:m=0,duration:v=300,easing:_=Hs,tick:w=x,css:y}=o||xu,$={start:js()+m,b:p};p||($.group=ut,ut.r+=1),u||a?a=$:(y&&(c(),f=Lr(e,s,p,v,m,_,y)),p&&w(0,1),u=d($,v),ke(()=>Rl(e,p,"start")),Gs(M=>{if(a&&M>a.start&&(u=d(a,v),a=null,Rl(e,u.b,"start"),y&&(c(),f=Lr(e,s,u.b,u.duration,0,_,o.css))),u){if(M>=u.end)w(s=u.b,1-s),Rl(e,u.b,"end"),a||(u.b?c():--u.group.r||ge(u.group.c)),u=null;else if(M>=u.start){const k=M-u.start;s=u.a+u.d*_(k/u.duration),w(s,1-s)}}return!!(u||a)}))}return{run(p){Qe(o)?ju().then(()=>{o=o(r),g(p)}):g(p)},end(){c(),u=a=null}}}function Ot(e,t){e.d(1),t.delete(e.key)}function Xs(e,t){H(e,1,1,()=>{t.delete(e.key)})}function ct(e,t,n,l,r,o,s,u,a,f,c,d){let g=e.length,p=o.length,m=g;const v={};for(;m--;)v[e[m].key]=m;const _=[],w=new Map,y=new Map,$=[];for(m=p;m--;){const S=d(r,o,m),R=n(S);let C=s.get(R);C?l&&$.push(()=>C.p(S,t)):(C=f(R,S),C.c()),w.set(R,_[m]=C),R in v&&y.set(R,Math.abs(m-v[R]))}const M=new Set,k=new Set;function E(S){V(S,1),S.m(u,c),s.set(S.key,S),c=S.first,p--}for(;g&&p;){const S=_[p-1],R=e[g-1],C=S.key,F=R.key;S===R?(c=S.first,g--,p--):w.has(F)?!s.has(C)||M.has(C)?E(S):k.has(F)?g--:y.get(C)>y.get(F)?(k.add(C),E(S)):(M.add(F),g--):(a(R,s),g--)}for(;g--;){const S=e[g];w.has(S.key)||a(S,s)}for(;p;)E(_[p-1]);return ge($),_}function Ys(e,t){const n={},l={},r={$$scope:1};let o=e.length;for(;o--;){const s=e[o],u=t[o];if(u){for(const a in s)a in u||(l[a]=1);for(const a in u)r[a]||(n[a]=u[a],r[a]=1);e[o]=u}else for(const a in s)r[a]=1}for(const s in l)s in n||(n[s]=void 0);return n}function Qs(e){return typeof e=="object"&&e!==null?e:{}}const Gu=/[&"]/g,Bu=/[&<]/g;function Uu(e,t=!1){const n=String(e),l=t?Gu:Bu;l.lastIndex=0;let r="",o=0;for(;l.test(n);){const s=l.lastIndex-1,u=n[s];r+=n.substring(o,s)+(u==="&"?"&":u==='"'?""":"<"),o=s+1}return r+n.substring(o)}function Wu(e,t){if(!e||!e.$$render)throw t==="svelte:component"&&(t+=" this={...}"),new Error(`<${t}> is not a valid SSR component. You may need to review your build config to ensure that dependencies are compiled, rather than imported as pre-compiled modules. Otherwise you may need to fix a <${t}>.`);return e}let Al;function Ks(e){function t(n,l,r,o,s){const u=Kt,a={on_destroy:Al,context:new Map(s||(u?u.$$.context:[])),on_mount:[],before_update:[],after_update:[],callbacks:Yl()};Pt({$$:a});const f=e(n,l,r,o);return Pt(u),f}return{render:(n={},{$$slots:l={},context:r=new Map}={})=>{Al=[];const o={title:"",head:"",css:new Set},s=t(o,n,{},l,r);return ge(Al),{html:s,css:{code:Array.from(o.css).map(u=>u.code).join(`
+`),map:null},head:o.title+o.head}},$$render:t}}function te(e){e&&e.c()}function Xu(e,t){e&&e.l(t)}function J(e,t,n,l){const{fragment:r,after_update:o}=e.$$;r&&r.m(t,n),l||ke(()=>{const s=e.$$.on_mount.map(qs).filter(Qe);e.$$.on_destroy?e.$$.on_destroy.push(...s):ge(s),e.$$.on_mount=[]}),o.forEach(ke)}function Z(e,t){const n=e.$$;n.fragment!==null&&(Lu(n.after_update),ge(n.on_destroy),n.fragment&&n.fragment.d(t),n.on_destroy=n.fragment=null,n.ctx=[])}function Yu(e,t){e.$$.dirty[0]===-1&&(xt.push(e),Hu(),e.$$.dirty.fill(0)),e.$$.dirty[t/31|0]|=1<{const m=p.length?p[0]:g;return f.ctx&&r(f.ctx[d],f.ctx[d]=m)&&(!f.skip_bound&&f.bound[d]&&f.bound[d](m),c&&Yu(e,d)),g}):[],f.update(),c=!0,ge(f.before_update),f.fragment=l?l(f.ctx):!1,t.target){if(t.hydrate){bu();const d=Au(t.target);f.fragment&&f.fragment.l(d),d.forEach(N)}else f.fragment&&f.fragment.c();t.intro&&V(e.$$.fragment),J(e,t.target,t.anchor,t.customElement),wu(),Ws()}Pt(a)}class ie{$destroy(){Z(this,1),this.$destroy=x}$on(t,n){if(!Qe(n))return x;const l=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return l.push(n),()=>{const r=l.indexOf(n);r!==-1&&l.splice(r,1)}}$set(t){this.$$set&&!_u(t)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}}const qt=[];function Kl(e,t){return{subscribe:Ae(e,t).subscribe}}function Ae(e,t=x){let n;const l=new Set;function r(u){if(re(e,u)&&(e=u,n)){const a=!qt.length;for(const f of l)f[1](),qt.push(f,e);if(a){for(let f=0;f{l.delete(f),l.size===0&&n&&(n(),n=null)}}return{set:r,update:o,subscribe:s}}function Qu(e,t,n){const l=!Array.isArray(e),r=l?[e]:e,o=t.length<2;return Kl(n,s=>{let u=!1;const a=[];let f=0,c=x;const d=()=>{if(f)return;c();const p=t(l?a[0]:a,s);o?s(p):c=Qe(p)?p:x},g=r.map((p,m)=>yl(p,v=>{a[m]=v,f&=~(1<{f|=1<e;const n=typeof e;if(n!==typeof t||Array.isArray(e)!==Array.isArray(t))throw new Error("Cannot interpolate values of different type");if(Array.isArray(e)){const l=t.map((r,o)=>Jl(e[o],r));return r=>l.map(o=>o(r))}if(n==="object"){if(!e||!t)throw new Error("Object cannot be null");if(xr(e)&&xr(t)){e=e.getTime(),t=t.getTime();const o=t-e;return s=>new Date(e+s*o)}const l=Object.keys(t),r={};return l.forEach(o=>{r[o]=Jl(e[o],t[o])}),o=>{const s={};return l.forEach(u=>{s[u]=r[u](o)}),s}}if(n==="number"){const l=t-e;return r=>e+r*l}throw new Error(`Cannot interpolate ${n} values`)}function $r(e,t={}){const n=Ae(e);let l,r=e;function o(s,u){if(e==null)return n.set(e=s),Promise.resolve();r=s;let a=l,f=!1,{delay:c=0,duration:d=400,easing:g=Hs,interpolate:p=Jl}=Jn(Jn({},t),u);if(d===0)return a&&(a.abort(),a=null),n.set(e=r),Promise.resolve();const m=js()+c;let v;return l=Gs(_=>{if(_d?(n.set(e=s),!1):(n.set(e=v(g(w/d))),!0)}),l.promise}return{set:o,update:(s,u)=>o(s(r,e),u),subscribe:n.subscribe}}const Ve=Ae([]),Ml=Ae([]),El=Ae([]),kn=Ae([]),rt=Ae("all"),Gr=Ae({"n/a":1,up:1,down:1}),Ku=["who","what","how","why","where","does","can","n/a"],Zl=$r(Ku.map(e=>({question:e,count:0}))),er=Ae(new Set);var tr="http://www.w3.org/1999/xhtml";const Br={svg:"http://www.w3.org/2000/svg",xhtml:tr,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function Js(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),Br.hasOwnProperty(t)?{space:Br[t],local:e}:e}function Ju(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===tr&&t.documentElement.namespaceURI===tr?t.createElement(e):t.createElementNS(n,e)}}function Zu(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function Zs(e){var t=Js(e);return(t.local?Zu:Ju)(t)}function ef(){}function ea(e){return e==null?ef:function(){return this.querySelector(e)}}function tf(e){typeof e!="function"&&(e=ea(e));for(var t=this._groups,n=t.length,l=new Array(n),r=0;r=$&&($=y+1);!(k=_[$])&&++$=0;)(s=l[r])&&(o&&s.compareDocumentPosition(o)^4&&o.parentNode.insertBefore(s,o),o=s);return this}function Mf(e){e||(e=Ef);function t(d,g){return d&&g?e(d.__data__,g.__data__):!d-!g}for(var n=this._groups,l=n.length,r=new Array(l),o=0;ot?1:e>=t?0:NaN}function Ff(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function Df(){return Array.from(this)}function If(){for(var e=this._groups,t=0,n=e.length;t1?this.each((t==null?xf:typeof t=="function"?Bf:Gf)(e,t,n??"")):Wf(this.node(),e)}function Wf(e,t){return e.style.getPropertyValue(t)||ra(e).getComputedStyle(e,null).getPropertyValue(t)}function Xf(e){return function(){delete this[e]}}function Yf(e,t){return function(){this[e]=t}}function Qf(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function Kf(e,t){return arguments.length>1?this.each((t==null?Xf:typeof t=="function"?Qf:Yf)(e,t)):this.node()[e]}function ia(e){return e.trim().split(/^|\s+/)}function Rr(e){return e.classList||new oa(e)}function oa(e){this._node=e,this._names=ia(e.getAttribute("class")||"")}oa.prototype={add:function(e){var t=this._names.indexOf(e);t<0&&(this._names.push(e),this._node.setAttribute("class",this._names.join(" ")))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(e){return this._names.indexOf(e)>=0}};function sa(e,t){for(var n=Rr(e),l=-1,r=t.length;++l=0&&(n=t.slice(l+1),t=t.slice(0,l)),{type:t,name:n}})}function $c(e){return function(){var t=this.__on;if(t){for(var n=0,l=-1,r=t.length,o;n`${w[0].toUpperCase()}${w.slice(1)}`),d=parseFloat(o[`padding${c[0]}`]),g=parseFloat(o[`padding${c[1]}`]),p=parseFloat(o[`margin${c[0]}`]),m=parseFloat(o[`margin${c[1]}`]),v=parseFloat(o[`border${c[0]}Width`]),_=parseFloat(o[`border${c[1]}Width`]);return{delay:t,duration:n,easing:l,css:w=>`overflow: hidden;opacity: ${Math.min(w*20,1)*s};${u}: ${w*a}px;padding-${f[0]}: ${w*d}px;padding-${f[1]}: ${w*g}px;margin-${f[0]}: ${w*p}px;margin-${f[1]}: ${w*m}px;border-${f[0]}-width: ${w*v}px;border-${f[1]}-width: ${w*_}px;`}}function Pn(e,{delay:t=0,duration:n=400,easing:l=Cr,start:r=0,opacity:o=0}={}){const s=getComputedStyle(e),u=+s.opacity,a=s.transform==="none"?"":s.transform,f=1-r,c=u*(1-o);return{delay:t,duration:n,easing:l,css:(d,g)=>`
+ transform: ${a} scale(${1-f*g});
+ opacity: ${u-c*g}
+ `}}function nr(e,t=2){if(e===0)return"0 Bytes";const n=1024,l=t<0?0:t,r=["Bytes","KB","MB","GB","TB","PB","EB","ZB","YB"],o=Math.floor(Math.log(e)/Math.log(n));return parseFloat((e/Math.pow(n,o)).toFixed(l))+" "+r[o]}function Nc(e){let t={who:0,what:0,how:0,why:0,where:0,does:0,can:0,"n/a":0};for(let l=0;l({question:l,count:t[l]}))}function ca(e){return e.map(t=>{const n=t.question.split(" ").length,l=t.answer.split(" ").length;return{index:t.index,question:+n,answer:+l,vote:t.vote}})}function Pc(e,t){e.classList.add("tooltip"),e.setAttribute("tabindex",0);function n(){const r=document.createElement("span");r.textContent=t,r.setAttribute("id","tooltip"),e.appendChild(r),e.addEventListener("mouseleave",l),e.addEventListener("blur",l),e.removeEventListener("mouseenter",n),e.removeEventListener("focus",n)}function l(){e.removeChild(e.querySelector("#tooltip")),e.removeEventListener("mouseleave",l),e.removeEventListener("blur",l),e.addEventListener("mouseenter",n),e.addEventListener("focus",n)}return e.addEventListener("mouseenter",n),e.addEventListener("focus",n),{onDestroy(){e.classList.remove("tooltip"),e.removeEventListener("mouseenter",n),e.removeEventListener("focus",n)}}}function Ur(e,t,n){const l=e.slice();return l[16]=t[n],l[18]=n,l}function Wr(e){let t,n,l,r,o,s;function u(...f){return e[9](e[18],...f)}function a(...f){return e[10](e[18],...f)}return{c(){t=A("div"),n=A("button"),n.textContent="👍",l=P(),r=A("button"),r.textContent="👎",h(n,"class","small-button thumbs-up svelte-19cad35"),h(r,"class","small-button thumbs-down svelte-19cad35"),h(t,"class","feedback-buttons svelte-19cad35")},m(f,c){T(f,t,c),b(t,n),b(t,l),b(t,r),o||(s=[B(n,"click",u),B(r,"click",a)],o=!0)},p(f,c){e=f},d(f){f&&N(t),o=!1,ge(s)}}}function Xr(e,t){let n,l,r,o,s,u,a,f,c,d=t[16].question+"",g,p,m,v,_,w,y,$=t[16].answer+"",M,k,E,S,R,C,F=t[0]&&Wr(t);return{key:e,first:null,c(){n=A("div"),l=A("div"),r=A("div"),o=P(),s=A("div"),u=A("div"),a=A("h5"),a.textContent="Question:",f=P(),c=A("p"),g=L(d),p=P(),m=A("div"),v=A("div"),_=A("h5"),_.textContent="Response:",w=P(),y=A("p"),M=L($),k=P(),F&&F.c(),E=P(),h(r,"class","avatar"),h(a,"class","bold svelte-19cad35"),h(u,"class","question svelte-19cad35"),h(_,"class","bold svelte-19cad35"),h(v,"class","answer svelte-19cad35"),h(m,"class","answers svelte-19cad35"),h(s,"class","message-content svelte-19cad35"),h(l,"class","chat-message-center svelte-19cad35"),h(n,"class","chat-message svelte-19cad35"),this.first=n},m(I,D){T(I,n,D),b(n,l),b(l,r),b(l,o),b(l,s),b(s,u),b(u,a),b(u,f),b(u,c),b(c,g),b(s,p),b(s,m),b(m,v),b(v,_),b(v,w),b(v,y),b(y,M),b(v,k),F&&F.m(v,null),b(n,E),R||(C=wn(S=Oc.call(null,n,t[18]===t[4].length-1)),R=!0)},p(I,D){t=I,D&16&&d!==(d=t[16].question+"")&&W(g,d),D&16&&$!==($=t[16].answer+"")&&W(M,$),t[0]?F?F.p(t,D):(F=Wr(t),F.c(),F.m(v,null)):F&&(F.d(1),F=null),S&&Qe(S.update)&&D&16&&S.update.call(null,t[18]===t[4].length-1)},d(I){I&&N(n),F&&F.d(),R=!1,C()}}}function Tc(e){let t,n,l,r,o,s,u=[],a=new Map,f,c,d,g,p,m,v=(e[2]?e[3]:"Send")+"",_,w,y,$,M,k,E=e[4];const S=R=>R[18];for(let R=0;RVote Feedback Instructions
+
Ask a question to receive an answer from the chatbot. If the response is
+ satisfactory, click on the 👍
+ button. If the repsonse is not satisfactory, click on the
+ 👎 button.
Ask a question and click on the better of the two responses. The better
+ response will be outlined in green, the worse
+ response outlined in red. This data will be
+ automatically fed to RLHF.
Ask a question to receive an answer from the chatbot. If the response is
+ satisfactory, click on the 👍
+ button. If the response is not satisfactory, click on the
+ 👎 button.
Ask a question and rank the answers across the models. Drag each answer to
+ rank it, in ascending order, from left-to-right. Optionally, select the
+ rank for each via the corresponding dropdown.
+
+ `,l=P(),r=A("div"),o=A("section"),s=A("div");for(let E=0;E{e.scrollIntoView({behavior:"smooth"})},0)}async function So(e){console.log("run update",e);const n=await fetch("/chat/comparator/db/update",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({data:e})});if(n.ok)console.log("ok",n);else{const l=await n.text();alert(l)}}function Jg(e,t,n){let l,r,o;le(e,El,k=>n(7,o=k));let{numModels:s=1}=t,{models:u=[0]}=t,a="",f="",c=!1;st(async()=>{if(await new Promise(k=>setTimeout(k,200)),p){const k=new X(p,{animation:150,onUpdate(E){k.toArray()}});k.toArray()}});const d=async k=>{k.preventDefault(),a=f,n(3,f=""),n(4,c=!0);let E={question:a};for(let R of u)E[R]="Loading...";Ne(El,o=[...o,E],o);const S=await fetch(`/chat/comparator/${a}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({prompt:a})});if(S.ok){const R=await S.json();n(1,u=Object.keys(R.answer)),n(0,s=u.length);for(let C of u)E[C]=R.answer[C];E.qid=R.qid,El.update(C=>(C[C.length-1]=E,C))}else{const R=await S.text();alert(R)}n(4,c=!1)};let g=0;setInterval(()=>{n(11,g=(g+1)%4)},200);let p,m;function v(k,E){const S=E,C=dt(k.currentTarget.parentNode).selectAll("div.answer").nodes().map(z=>z.id);C.forEach((z,O)=>{dt(`#${z}`).select(".answer-rank").property("value",O+1)});let F=[];for(let[z,O]of C.entries()){const U=parseInt(O.split("-")[1]),G=u[U],$e={rank:z,model:G};F.push($e)}let I=o.filter(z=>z.qid===S),D=[];for(let z of F){const O={model:z.model,qid:parseInt(S),rank:parseInt(z.rank)+1,answer:I[0][z.model]};D.push(O)}So(D)}function _(k,E,S){const R=E,C=parseInt(k.target.value),F=u[S],I={qid:R,rank:parseInt(C),model:F};let D=[],O=o.filter(G=>G.qid===I.qid)[0][I.model];const U={model:I.model,qid:parseInt(I.qid),rank:parseInt(I.rank),answer:O};D.push(U),So(D)}const w=(k,E,S)=>_(S,k.qid,E),y=(k,E)=>v(E,k.qid);function $(k){yn[k?"unshift":"push"](()=>{p=k,n(2,p)})}function M(){f=this.value,n(3,f)}return e.$$set=k=>{"numModels"in k&&n(0,s=k.numModels),"models"in k&&n(1,u=k.models)},e.$$.update=()=>{e.$$.dirty&1&&n(6,l="1fr ".repeat(s).trim()),e.$$.dirty&2048&&n(5,r=".".repeat(g).padEnd(3)),e.$$.dirty&4100&&p&&(n(12,m=new X(p,{animation:150,dataIdAttr:"id",onUpdate(k){m.toArray()}})),m.toArray())},[s,u,p,f,c,r,l,o,d,v,_,g,m,w,y,$,M]}class Zg extends ie{constructor(t){super(),oe(this,t,Jg,Qg,re,{numModels:0,models:1})}}const tn=Ae([{model:"llama",qid:1,rank:1,answer:"Llama's first unique answer."},{model:"gpt3.5",qid:1,rank:2,answer:"GPT-3.5's first unique answer."},{model:"gpt4",qid:1,rank:3,answer:"GPT-4's first unique answer."},{model:"claude",qid:1,rank:4,answer:"Claude's first unique answer."},{model:"llama",qid:2,rank:4,answer:"Llama's second unique answer."},{model:"gpt3.5",qid:2,rank:2,answer:"GPT-3.5's second unique answer."},{model:"gpt4",qid:2,rank:4,answer:"GPT-4's second unique answer."},{model:"claude",qid:2,rank:3,answer:"'s second unique answer."}]);function Co(e,t,n){const l=e.slice();return l[20]=t[n],l}function $o(e,t,n){const l=e.slice();return l[20]=t[n],l[24]=n,l}function Ro(e,t,n){const l=e.slice();return l[25]=t[n],l}function Ao(e){let t,n,l,r,o=`Q.${e[25]}`,s,u;return{c(){t=j("g"),n=j("line"),r=j("text"),s=L(o),h(n,"class","axis-tick svelte-1nna9rx"),h(n,"x1","0"),h(n,"x2","0"),h(n,"y1",0),h(n,"y2",l=-e[5]+e[12].bottom+e[12].top),h(n,"stroke","black"),h(n,"stroke-dasharray","4"),h(r,"class","axis-text svelte-1nna9rx"),h(r,"y","15"),h(r,"text-anchor","middle"),h(t,"transform",u=`translate(${e[3](e[25])+0} ${e[5]-e[12].bottom})`),h(t,"class","svelte-1nna9rx")},m(a,f){T(a,t,f),b(t,n),b(t,r),b(r,s)},p(a,f){f&32&&l!==(l=-a[5]+a[12].bottom+a[12].top)&&h(n,"y2",l),f&256&&o!==(o=`Q.${a[25]}`)&&W(s,o),f&296&&u!==(u=`translate(${a[3](a[25])+0} ${a[5]-a[12].bottom})`)&&h(t,"transform",u)},d(a){a&&N(t)}}}function Mo(e){let t=Number.isInteger(e[25]),n,l=t&&Ao(e);return{c(){l&&l.c(),n=_e()},m(r,o){l&&l.m(r,o),T(r,n,o)},p(r,o){o&256&&(t=Number.isInteger(r[25])),t?l?l.p(r,o):(l=Ao(r),l.c(),l.m(n.parentNode,n)):l&&(l.d(1),l=null)},d(r){l&&l.d(r),r&&N(n)}}}function Eo(e,t){let n,l,r,o,s,u,a,f,c;function d(){return t[15](t[24])}function g(){return t[16](t[24])}return{key:e,first:null,c(){n=j("path"),o=j("path"),h(n,"class","model-path-outer svelte-1nna9rx"),h(n,"d",l=t[10](t[20])),h(n,"stroke","white"),h(n,"data-model",r=t[2][t[24]]),h(o,"class","model-path svelte-1nna9rx"),h(o,"d",s=t[10](t[20])),h(o,"role","img"),h(o,"stroke",u=t[11](t[2][t[24]])),h(o,"data-model",a=t[2][t[24]]),this.first=n},m(p,m){T(p,n,m),T(p,o,m),f||(c=[B(o,"mouseover",d),B(o,"focus",g),B(o,"mouseout",pl),B(o,"blur",pl)],f=!0)},p(p,m){t=p,m&1536&&l!==(l=t[10](t[20]))&&h(n,"d",l),m&516&&r!==(r=t[2][t[24]])&&h(n,"data-model",r),m&1536&&s!==(s=t[10](t[20]))&&h(o,"d",s),m&2564&&u!==(u=t[11](t[2][t[24]]))&&h(o,"stroke",u),m&516&&a!==(a=t[2][t[24]])&&h(o,"data-model",a)},d(p){p&&N(n),p&&N(o),f=!1,ge(c)}}}function Fo(e,t){let n,l,r,o,s,u,a=t[20].rank+"",f,c,d,g;return{key:e,first:null,c(){n=j("g"),l=j("circle"),u=j("text"),f=L(a),h(l,"r",r=t[20].answer.length/2*0+12),h(l,"fill",o=t[11](t[20].model)),h(l,"stroke","white"),h(l,"class","model-circle svelte-1nna9rx"),h(l,"role","img"),h(l,"data-model",s=t[20].model),h(u,"class","bump-text svelte-1nna9rx"),h(u,"text-anchor","middle"),h(u,"alignment-baseline","middle"),h(u,"color","white"),h(u,"fill","white"),h(n,"transform",c=`translate(${t[3](t[20].qid)}, ${t[4](t[20].rank)})`),h(n,"class","svelte-1nna9rx"),this.first=n},m(p,m){T(p,n,m),b(n,l),b(n,u),b(u,f),d||(g=[B(l,"mouseover",t[17]),B(l,"focus",t[18]),B(l,"mouseout",pl),B(l,"blur",pl)],d=!0)},p(p,m){t=p,m&128&&r!==(r=t[20].answer.length/2*0+12)&&h(l,"r",r),m&2176&&o!==(o=t[11](t[20].model))&&h(l,"fill",o),m&128&&s!==(s=t[20].model)&&h(l,"data-model",s),m&128&&a!==(a=t[20].rank+"")&&W(f,a),m&152&&c!==(c=`translate(${t[3](t[20].qid)}, ${t[4](t[20].rank)})`)&&h(n,"transform",c)},d(p){p&&N(n),d=!1,ge(g)}}}function ep(e){let t,n,l,r,o,s,u,a,f,c,d,g,p,m=[],v=new Map,_,w=[],y=new Map,$,M,k,E,S,R=e[8],C=[];for(let O=0;OO[24];for(let O=0;OO[20].model+O[20].qid;for(let O=0;Oe[19].call(t))},m(O,U){T(O,t,U),b(t,n),b(n,l);for(let G=0;G{e.style.opacity=1})}function tp(e,t,n){let l,r,o,s,u,a,f,c,d,g,p;le(e,tn,S=>n(7,p=S));let m,v,_={top:35,bottom:15,left:10,right:0};function w(S){document.querySelectorAll(".model-path, .model-path-outer, .model-circle").forEach(R=>{R.style.opacity=.12}),document.querySelectorAll(`.model-path[data-model="${l[S]}"], .model-circle[data-model="${l[S]}"]`).forEach(R=>{R.style.opacity=1})}const y=S=>w(S),$=S=>w(S),M=()=>w(i),k=()=>w(i);function E(){v=this.offsetWidth,m=this.offsetHeight,n(1,v),n(0,m)}return e.$$.update=()=>{e.$$.dirty&128&&n(2,l=Array.from(new Set(p.map(S=>S.model)))),e.$$.dirty&2&&n(6,r=v-_.left-_.right),e.$$.dirty&1&&n(5,o=m-_.top-_.bottom),e.$$.dirty&192&&n(3,s=Mi().domain(p.map(S=>S.qid)).padding(.3).range([_.left,r-_.right])),e.$$.dirty&128&&n(14,u=p.map(S=>S.rank).sort((S,R)=>S-R)),e.$$.dirty&16416&&n(4,a=Mi().domain(u).padding(1).range([_.top,o-_.bottom])),e.$$.dirty&128&&n(11,f=$t().domain(p.map(S=>S.model)).range(["#FF5470","#1B2D45","#00EBC7","#FDE24F","red"])),e.$$.dirty&24&&n(10,c=Zh().x(S=>s(S.qid)).y(S=>a(S.rank))),e.$$.dirty&132&&n(9,d=l.map(S=>p.filter(R=>R.model===S))),e.$$.dirty&8&&n(8,g=s.domain().length>10?s.domain().filter((S,R)=>R%2===0):s.domain())},[m,v,l,s,a,o,r,p,g,d,c,f,_,w,u,y,$,M,k,E]}class np extends ie{constructor(t){super(),oe(this,t,tp,ep,re,{})}}function Do(e,t,n){const l=e.slice();return l[13]=t[n],l[15]=n,l}function Io(e,t,n){const l=e.slice();return l[16]=t[n],l}function No(e,t,n){const l=e.slice();return l[16]=t[n],l}function Po(e){let t,n,l=e[16]+"",r,o;return{c(){t=j("g"),n=j("text"),r=L(l),h(n,"class","axis-text svelte-1y9gffu"),h(n,"x","-5"),h(n,"y","0"),h(n,"text-anchor","end"),h(t,"transform",o=`translate(${e[9].left} ${e[8](e[16])+e[8].bandwidth()/2})`)},m(s,u){T(s,t,u),b(t,n),b(n,r)},p(s,u){u&4&&l!==(l=s[16]+"")&&W(r,l),u&260&&o!==(o=`translate(${s[9].left} ${s[8](s[16])+s[8].bandwidth()/2})`)&&h(t,"transform",o)},d(s){s&&N(t)}}}function To(e){let t,n,l=e[16]+"",r,o;return{c(){t=j("g"),n=j("text"),r=L(l),h(n,"class","axis-text svelte-1y9gffu"),h(n,"y","15"),h(n,"text-anchor","middle"),h(t,"transform",o=`translate(${e[7](e[16])}, ${e[4]-e[9].bottom})`)},m(s,u){T(s,t,u),b(t,n),b(n,r)},p(s,u){u&128&&l!==(l=s[16]+"")&&W(r,l),u&144&&o!==(o=`translate(${s[7](s[16])}, ${s[4]-s[9].bottom})`)&&h(t,"transform",o)},d(s){s&&N(t)}}}function Oo(e){let t,n=e[16]%2==0&&To(e);return{c(){n&&n.c(),t=_e()},m(l,r){n&&n.m(l,r),T(l,t,r)},p(l,r){l[16]%2==0?n?n.p(l,r):(n=To(l),n.c(),n.m(t.parentNode,t)):n&&(n.d(1),n=null)},d(l){n&&n.d(l),l&&N(t)}}}function Vo(e){let t,n,l,r,o,s,u,a=e[13].avgRank.toFixed(2)+"",f,c,d;return{c(){t=j("rect"),u=j("text"),f=L(a),h(t,"y",n=e[8](e[13].model)),h(t,"x",e[9].left),h(t,"width",l=e[7](e[13].avgRank)-e[9].left),h(t,"height",r=e[8].bandwidth()),h(t,"fill",o=e[6](e[13].model)),h(t,"class","model-path"),h(t,"data-model",s=e[5][e[15]]),h(u,"class","label-text svelte-1y9gffu"),h(u,"y",c=e[8](e[13].model)+e[8].bandwidth()/2),h(u,"x",d=e[7](e[13].avgRank)+5),h(u,"text-anchor","start"),h(u,"dominant-baseline","middle")},m(g,p){T(g,t,p),T(g,u,p),b(u,f)},p(g,p){p&260&&n!==(n=g[8](g[13].model))&&h(t,"y",n),p&132&&l!==(l=g[7](g[13].avgRank)-g[9].left)&&h(t,"width",l),p&256&&r!==(r=g[8].bandwidth())&&h(t,"height",r),p&68&&o!==(o=g[6](g[13].model))&&h(t,"fill",o),p&32&&s!==(s=g[5][g[15]])&&h(t,"data-model",s),p&4&&a!==(a=g[13].avgRank.toFixed(2)+"")&&W(f,a),p&260&&c!==(c=g[8](g[13].model)+g[8].bandwidth()/2)&&h(u,"y",c),p&132&&d!==(d=g[7](g[13].avgRank)+5)&&h(u,"x",d)},d(g){g&&N(t),g&&N(u)}}}function lp(e){let t,n,l,r,o,s,u,a,f,c,d,g,p=e[2].map(zo),m=[];for(let $=0;$e[12].call(t))},m($,M){T($,t,M),b(t,n);for(let k=0;ke.model;function rp(e,t,n){let l,r,o,s,u,a,f,c,d;le(e,tn,_=>n(11,d=_));let g=300,p=500,m={top:50,bottom:0,left:100,right:0};function v(){p=this.offsetWidth,g=this.offsetHeight,n(1,p),n(0,g)}return e.$$.update=()=>{e.$$.dirty&2048&&n(10,l=d.reduce((_,w)=>(_[w.model]?(_[w.model].sum+=w.rank,_[w.model].count++):_[w.model]={sum:w.rank,count:1},_),{})),e.$$.dirty&1024&&n(2,r=Object.keys(l).map(_=>({model:_,avgRank:l[_].sum/l[_].count}))),e.$$.dirty&2&&n(3,o=p-m.left-m.right),e.$$.dirty&1&&n(4,s=g-m.top-m.bottom),e.$$.dirty&20&&n(8,u=Vt().rangeRound([m.top,s-m.bottom]).padding(.05).domain(r.map(_=>_.model))),e.$$.dirty&12&&n(7,a=Ge().rangeRound([m.left,o-m.right]).domain([0,ht(r,_=>_.avgRank)])),e.$$.dirty&4&&n(6,f=$t().domain(r.map(_=>_.model)).range(["#FF5470","#1B2D45","#00EBC7","#FDE24F"])),e.$$.dirty&2048&&n(5,c=Array.from(new Set(d.map(_=>_.model))))},[g,p,r,o,s,c,f,a,u,m,l,d,v]}class ip extends ie{constructor(t){super(),oe(this,t,rp,lp,re,{})}}function Ho(e,t,n){const l=e.slice();return l[20]=t[n],l[22]=n,l}function qo(e,t,n){const l=e.slice();return l[23]=t[n],l[25]=n,l}function Lo(e,t,n){const l=e.slice();return l[23]=t[n],l}function jo(e){let t,n=e[23].key+"",l,r,o;function s(){return e[10](e[23])}return{c(){t=A("th"),l=L(n),h(t,"class","svelte-owgjbp")},m(u,a){T(u,t,a),b(t,l),r||(o=B(t,"click",s),r=!0)},p(u,a){e=u,a&64&&n!==(n=e[23].key+"")&&W(l,n)},d(u){u&&N(t),r=!1,o()}}}function xo(e,t){let n,l=(t[20][t[23].key].length>Bo&&t[4]!==`${t[22]}-${t[25]}`?`${t[20][t[23].key].substring(0,40)}...`:t[20][t[23].key])+"",r,o,s,u;function a(){return t[11](t[22],t[25])}return{key:e,first:null,c(){n=A("td"),r=L(l),h(n,"class",o="cell-type-"+t[23].type+" svelte-owgjbp"),ye(n,"background",t[23].key==="change"?t[7](t[20][t[23].key]):"none"),It(n,"active",t[4]===`${t[22]}-${t[25]}`),this.first=n},m(f,c){T(f,n,c),b(n,r),s||(u=B(n,"click",a),s=!0)},p(f,c){t=f,c&112&&l!==(l=(t[20][t[23].key].length>Bo&&t[4]!==`${t[22]}-${t[25]}`?`${t[20][t[23].key].substring(0,40)}...`:t[20][t[23].key])+"")&&W(r,l),c&64&&o!==(o="cell-type-"+t[23].type+" svelte-owgjbp")&&h(n,"class",o),c&96&&ye(n,"background",t[23].key==="change"?t[7](t[20][t[23].key]):"none"),c&80&&It(n,"active",t[4]===`${t[22]}-${t[25]}`)},d(f){f&&N(n),s=!1,u()}}}function Go(e){let t,n=[],l=new Map,r,o=e[6];const s=u=>u[23].key;for(let u=0;un(9,s=M));let u={};const a=pt(".2f");function f(M){let k=M.reduce((S,R)=>(S[R.model]||(S[R.model]=[]),S[R.model].push(R.rank),S),{});return Object.entries(k).map(([S,R])=>{let C=R.reduce((I,D)=>(I[D]=(I[D]||0)+1,I),{}),F=Object.entries(C).reduce((I,D)=>D[1]>I[1]?D:I)[0];return{model:S,overall_rank:Number(F),average_rank:a(Jd(R)),standard_deviation_rank:a(Vd(R))}})}u={...{columns:{},style:"normal",paged:25},...u};const d=Ge().domain([-1,0,1]).range(["#FF5470","#f8f8f8","#00ebc7"]);let{sortable:g,index:p,paged:m}=u,v,_=!0;if(g&&p)throw new Error("A table can either be ranked or sortable, but not both");p=1,g=1;let w=null;const y=M=>{g&&(v===M.key&&n(2,_=!_),n(1,v=M.key))},$=(M,k)=>{n(4,w=w===`${M}-${k}`?null:`${M}-${k}`)};return e.$$.update=()=>{if(e.$$.dirty&512,e.$$.dirty&512&&n(8,l=f(s)),e.$$.dirty&774){v&&n(8,l=l.slice().sort((k,E)=>{let S=k[v],R=E[v];if(S==R)return JSON.stringify(k).localeCompare(JSON.stringify(E));let C=S>R?1:S{const k=u.columns[M]||{};return{key:M,type:k.type||typeof l[0][M],options:k}}))},n(5,o=[]),[u,v,_,g,w,o,r,d,l,s,y,$]}let up=class extends ie{constructor(t){super(),oe(this,t,ap,op,re,{})}};function Uo(e,t,n){const l=e.slice();return l[19]=t[n],l}function Wo(e,t,n){const l=e.slice();return l[22]=t[n],l}function Xo(e,t,n){const l=e.slice();return l[25]=t[n],l[27]=n,l}function Yo(e){let t,n=e[25]+"",l,r,o,s=e[25]+"",u,a;return{c(){t=j("text"),l=L(n),o=j("text"),u=L(s),h(t,"class","axis-text svelte-t6wv8i"),h(t,"x",r=e[7].left+e[5](e[25])+e[5].bandwidth()/2),h(t,"y",e[7].top-10),h(t,"text-anchor","middle"),h(o,"class","axis-text svelte-t6wv8i"),h(o,"x",e[7].left-10),h(o,"y",a=e[7].top+e[4](e[25])+e[4].bandwidth()/2),h(o,"text-anchor","end"),h(o,"dominant-baseline","middle")},m(f,c){T(f,t,c),b(t,l),T(f,o,c),b(o,u)},p(f,c){c&8&&n!==(n=f[25]+"")&&W(l,n),c&40&&r!==(r=f[7].left+f[5](f[25])+f[5].bandwidth()/2)&&h(t,"x",r),c&8&&s!==(s=f[25]+"")&&W(u,s),c&24&&a!==(a=f[7].top+f[4](f[25])+f[4].bandwidth()/2)&&h(o,"y",a)},d(f){f&&N(t),f&&N(o)}}}function Qo(e){let t,n,l,r,o,s,u,a,f=e[6](e[2][e[19]][e[22]])+"",c,d,g,p;return{c(){t=j("rect"),a=j("text"),c=L(f),h(t,"x",n=e[7].left+e[5](e[22])),h(t,"y",l=e[7].top+e[4](e[19])),h(t,"width",r=e[5].bandwidth()),h(t,"height",o=e[4].bandwidth()),h(t,"fill",s=e[8](e[19],e[22])),h(t,"rx","4"),h(t,"ry","4"),h(t,"class","model-path"),h(t,"data-model",u=e[19]),h(a,"x",d=e[7].left+e[5](e[22])+e[5].bandwidth()/2),h(a,"y",g=e[7].top+e[4](e[19])+e[4].bandwidth()/2),h(a,"text-anchor","middle"),h(a,"dominant-baseline","middle"),h(a,"class","model-path"),h(a,"data-model",p=e[19])},m(m,v){T(m,t,v),T(m,a,v),b(a,c)},p(m,v){v&40&&n!==(n=m[7].left+m[5](m[22]))&&h(t,"x",n),v&24&&l!==(l=m[7].top+m[4](m[19]))&&h(t,"y",l),v&32&&r!==(r=m[5].bandwidth())&&h(t,"width",r),v&16&&o!==(o=m[4].bandwidth())&&h(t,"height",o),v&8&&s!==(s=m[8](m[19],m[22]))&&h(t,"fill",s),v&8&&u!==(u=m[19])&&h(t,"data-model",u),v&12&&f!==(f=m[6](m[2][m[19]][m[22]])+"")&&W(c,f),v&40&&d!==(d=m[7].left+m[5](m[22])+m[5].bandwidth()/2)&&h(a,"x",d),v&24&&g!==(g=m[7].top+m[4](m[19])+m[4].bandwidth()/2)&&h(a,"y",g),v&8&&p!==(p=m[19])&&h(a,"data-model",p)},d(m){m&&N(t),m&&N(a)}}}function Ko(e){let t,n=e[3],l=[];for(let r=0;re[16].call(t))},m(g,p){T(g,t,p),b(t,n);for(let m=0;mn(15,p=k));const m=pt(".1f");function v(k){let E=k.reduce((C,F)=>(C[F.qid]||(C[F.qid]=[]),C[F.qid].push(F),C),{}),S=Array.from(new Set(k.map(C=>C.model))),R=S.reduce((C,F)=>(C[F]=S.reduce((I,D)=>(I[D]={sum:0,count:0},I),{}),C),{});for(let C in E){let F=E[C];for(let I of S)for(let D of S){let z=F.find(U=>U.model===I),O=F.find(U=>U.model===D);z&&O&&(R[I][D].sum+=O.rank-z.rank,R[I][D].count++)}}for(let C in R)for(let F in R[C])R[C][F].count>0?R[C][F]=R[C][F].sum/R[C][F].count:R[C][F]=0;return R}let _=500,w=500,y={top:50,bottom:0,left:65,right:25};function $(k,E){let S=l[k][E];return S===0?"white":S>=0?g(k):g(E)}function M(){w=this.offsetWidth,_=this.offsetHeight,n(1,w),n(0,_)}return e.$$.update=()=>{e.$$.dirty&32768&&n(2,l=v(p)),e.$$.dirty&32768&&n(3,r=Array.from(new Set(p.map(k=>k.model)))),e.$$.dirty&2&&n(14,o=w-y.left-y.right),e.$$.dirty&1&&n(13,s=_-y.top-y.bottom),e.$$.dirty&16392&&n(5,u=Vt().range([0,o]).domain(r).padding(.05)),e.$$.dirty&8200&&n(4,a=Vt().range([0,s]).domain(r).padding(.05)),e.$$.dirty&4&&n(12,f=Object.values(l).flatMap(k=>Object.values(k))),e.$$.dirty&4096&&n(11,c=lr(f)),e.$$.dirty&4096&&n(10,d=ht(f)),e.$$.dirty&8&&n(9,g=$t().domain(r).range(["#FF5470","#1B2D45","#00EBC7","#FDE24F"])),e.$$.dirty&3592&&r.reduce((k,E)=>(k[E]=Ra().domain([c,d]).interpolator(ir("white",g(E))),k),{})},[_,w,l,r,a,u,m,y,$,g,d,c,f,s,o,p,M]}class dp extends ie{constructor(t){super(),oe(this,t,cp,fp,re,{})}}function Jo(e,t,n){const l=e.slice();return l[7]=t[n],l[9]=n,l}function hp(e){let t;return{c(){t=A("div"),t.innerHTML="
To view the comparison dashboard, you must first rank some comparisons!
Ask a question to receive an answer from the chatbot. If the response is
- satisfactory, click on the 👍
- button. If the repsonse is not satisfactory, click on the
- 👎 button.
Ask a question and click on the better of the two responses. The better
- response will be outlined in green, the worse
- response outlined in red. This data will be
- automatically fed to RLHF.
Ask a question to receive an answer from the chatbot. If the response is
- satisfactory, click on the 👍
- button. If the response is not satisfactory, click on the
- 👎 button.
Ask a question and rank the answers across the models. Drag each answer to
- rank it, in ascending order, from left-to-right. Optionally, select the
- rank for each via the corresponding dropdown.
-
- `,r=D(),i=R("div"),o=R("section"),l=R("div");for(let E=0;E{e.scrollIntoView({behavior:"smooth"})},0)}async function ml(e){console.log("run update",e);const n=await fetch("/chat/comparator/db/update",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({data:e})});if(n.ok)console.log("ok",n);else{const r=await n.text();alert(r)}}function Qg(e,t,n){let r,i,o;ee(e,kr,$=>n(7,o=$));let{numModels:l=1}=t,{models:a=[0]}=t,s="",u="",c=!1;ut(async()=>{if(await new Promise($=>setTimeout($,200)),g){const $=new L(g,{animation:150,onUpdate(E){$.toArray()}});$.toArray()}});const f=async $=>{$.preventDefault(),s=u,n(3,u=""),n(4,c=!0);let E={question:s};for(let k of a)E[k]="Loading...";Oe(kr,o=[...o,E],o);const S=await fetch(`/chat/comparator/${s}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({prompt:s})});if(S.ok){const k=await S.json();n(1,a=Object.keys(k.answer)),n(0,l=a.length);for(let y of a)E[y]=k.answer[y];E.qid=k.qid,kr.update(y=>(y[y.length-1]=E,y))}else{const k=await S.text();alert(k)}n(4,c=!1)};let d=0;setInterval(()=>{n(11,d=(d+1)%4)},200);let g,p;function m($,E){const S=E,y=st($.currentTarget.parentNode).selectAll("div.answer").nodes().map(P=>P.id);y.forEach((P,B)=>{st(`#${P}`).select(".answer-rank").property("value",B+1)});let M=[];for(let[P,B]of y.entries()){const ge=parseInt(B.split("-")[1]),oe=a[ge],Ee={rank:P,model:oe};M.push(Ee)}let I=o.filter(P=>P.qid===S),F=[];for(let P of M){const B={model:P.model,qid:parseInt(S),rank:parseInt(P.rank)+1,answer:I[0][P.model]};F.push(B)}ml(F)}function _($,E,S){const k=E,y=parseInt($.target.value),M=a[S],I={qid:k,rank:parseInt(y),model:M};let F=[],B=o.filter(oe=>oe.qid===I.qid)[0][I.model];const ge={model:I.model,qid:parseInt(I.qid),rank:parseInt(I.rank),answer:B};F.push(ge),ml(F)}const b=($,E,S)=>_(S,$.qid,E),w=($,E)=>m(E,$.qid);function C($){hn[$?"unshift":"push"](()=>{g=$,n(2,g)})}function A(){u=this.value,n(3,u)}return e.$$set=$=>{"numModels"in $&&n(0,l=$.numModels),"models"in $&&n(1,a=$.models)},e.$$.update=()=>{e.$$.dirty&1&&n(6,r="1fr ".repeat(l).trim()),e.$$.dirty&2048&&n(5,i=".".repeat(d).padEnd(3)),e.$$.dirty&4100&&g&&(n(12,p=new L(g,{animation:150,dataIdAttr:"id",onUpdate($){p.toArray()}})),p.toArray())},[l,a,g,u,c,i,r,o,f,m,_,d,p,b,w,C,A]}class Kg extends ie{constructor(t){super(),se(this,t,Qg,Xg,re,{numModels:0,models:1})}}function Jg(e){const t=+this._x.call(null,e),n=+this._y.call(null,e);return la(this.cover(t,n),t,n,e)}function la(e,t,n,r){if(isNaN(t)||isNaN(n))return e;var i,o=e._root,l={data:r},a=e._x0,s=e._y0,u=e._x1,c=e._y1,f,d,g,p,m,_,b,w;if(!o)return e._root=l,e;for(;o.length;)if((m=t>=(f=(a+u)/2))?a=f:u=f,(_=n>=(d=(s+c)/2))?s=d:c=d,i=o,!(o=o[b=_<<1|m]))return i[b]=l,e;if(g=+e._x.call(null,o.data),p=+e._y.call(null,o.data),t===g&&n===p)return l.next=o,i?i[b]=l:e._root=l,e;do i=i?i[b]=new Array(4):e._root=new Array(4),(m=t>=(f=(a+u)/2))?a=f:u=f,(_=n>=(d=(s+c)/2))?s=d:c=d;while((b=_<<1|m)===(w=(p>=d)<<1|g>=f));return i[w]=o,i[b]=l,e}function Zg(e){var t,n,r=e.length,i,o,l=new Array(r),a=new Array(r),s=1/0,u=1/0,c=-1/0,f=-1/0;for(n=0;nc&&(c=i),of&&(f=o));if(s>c||u>f)return this;for(this.cover(s,u).cover(c,f),n=0;ne||e>=i||r>t||t>=o;)switch(u=(tc||(a=p.y0)>f||(s=p.x1)=b)<<1|e>=_)&&(p=d[d.length-1],d[d.length-1]=d[d.length-1-m],d[d.length-1-m]=p)}else{var w=e-+this._x.call(null,g.data),C=t-+this._y.call(null,g.data),A=w*w+C*C;if(A=(d=(l+s)/2))?l=d:s=d,(m=f>=(g=(a+u)/2))?a=g:u=g,t=n,!(n=n[_=m<<1|p]))return this;if(!n.length)break;(t[_+1&3]||t[_+2&3]||t[_+3&3])&&(r=t,b=_)}for(;n.data!==e;)if(i=n,!(n=n.next))return this;return(o=n.next)&&delete n.next,i?(o?i.next=o:delete i.next,this):t?(o?t[_]=o:delete t[_],(n=t[0]||t[1]||t[2]||t[3])&&n===(t[3]||t[2]||t[1]||t[0])&&!n.length&&(r?r[b]=n:this._root=n),this):(this._root=o,this)}function oh(e){for(var t=0,n=e.length;td.index){var I=g-k.x-k.vx,F=p-k.y-k.vy,P=I*I+F*F;Pg+M||Ep+M||Su.r&&(u.r=u[c].r)}function s(){if(t){var u,c=t.length,f;for(n=new Array(c),u=0;u{}};function aa(){for(var e=0,t=arguments.length,n={},r;e=0&&(r=n.slice(i+1),n=n.slice(0,i)),n&&!t.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:r}})}jn.prototype=aa.prototype={constructor:jn,on:function(e,t){var n=this._,r=vh(e+"",n),i,o=-1,l=r.length;if(arguments.length<2){for(;++o0)for(var n=new Array(i),r=0,i,o;r=0&&e._call.call(void 0,t),e=e._next;--Wt}function wl(){At=(ur=wn.now())+br,Wt=on=0;try{yh()}finally{Wt=0,Ch(),At=0}}function Sh(){var e=wn.now(),t=e-ur;t>ua&&(br-=t,ur=e)}function Ch(){for(var e,t=ar,n,r=1/0;t;)t._call?(r>t._time&&(r=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:ar=n);ln=e,ai(r)}function ai(e){if(!Wt){on&&(on=clearTimeout(on));var t=e-At;t>24?(e<1/0&&(on=setTimeout(wl,e-wn.now()-br)),Jt&&(Jt=clearInterval(Jt))):(Jt||(ur=wn.now(),Jt=setInterval(Sh,ua)),Wt=1,ca(wl))}}const kh=1664525,$h=1013904223,yl=4294967296;function Rh(){let e=1;return()=>(e=(kh*e+$h)%yl)/yl}var Ah=10,Eh=Math.PI*(3-Math.sqrt(5));function Mh(e){var t,n=1,r=.001,i=1-Math.pow(r,1/300),o=0,l=.6,a=new Map,s=da(f),u=aa("tick","end"),c=Rh();e==null&&(e=[]);function f(){d(),u.call("tick",t),n1?(_==null?a.delete(m):a.set(m,p(_)),t):a.get(m)},find:function(m,_,b){var w=0,C=e.length,A,$,E,S,k;for(b==null?b=1/0:b*=b,w=0;w1?(u.on(m,_),t):u.on(m)}}}function Fh(e){var t=Je(.1),n,r,i;typeof e!="function"&&(e=Je(e==null?0:+e));function o(a){for(var s=0,u=n.length,c;se[4]?1:0),h(t,"class",g="file-circle-g "+(e[20].size>e[4]?"large":"")+" svelte-h2ab3o"),h(t,"style",p=e[5](e[20].x,e[20].y)),h(t,"role","img")},m(w,C){T(w,t,C),v(t,n),v(t,o),v(o,a),v(o,s),v(s,c),m=!0,_||(b=[j(t,"mouseover",e[6]),j(t,"mouseout",e[7]),j(t,"focus",e[6]),j(t,"blur",e[7])],_=!0)},p(w,C){(!m||C&12&&r!==(r=w[3](w[20].size)))&&h(n,"r",r),(!m||C&4)&&l!==(l=w[20].file+"")&&Q(a,l),(!m||C&4)&&u!==(u=Kr(w[20].size)+"")&&Q(c,u),(!m||C&20&&f!==(f=w[20].size>w[4]?1:0))&&h(o,"opacity",f),(!m||C&20&&g!==(g="file-circle-g "+(w[20].size>w[4]?"large":"")+" svelte-h2ab3o"))&&h(t,"class",g),(!m||C&4&&p!==(p=w[5](w[20].x,w[20].y)))&&h(t,"style",p)},i(w){m||(w&&Se(()=>{m&&(i||(i=Ke(n,Rn,{duration:1e3},!0)),i.run(1))}),w&&Se(()=>{m&&(d||(d=Ke(o,Rn,{duration:1e3},!0)),d.run(1))}),m=!0)},o(w){w&&(i||(i=Ke(n,Rn,{duration:1e3},!1)),i.run(0)),w&&(d||(d=Ke(o,Rn,{duration:1e3},!1)),d.run(0)),m=!1},d(w){w&&x(t),w&&i&&i.end(),w&&d&&d.end(),_=!1,_e(b)}}}function Ih(e){let t,n,r,i,o=e[2],l=[];for(let s=0;sV(l[s],1,1,()=>{l[s]=null});return{c(){t=R("div"),n=U("svg");for(let s=0;se[15].call(t))},m(s,u){T(s,t,u),v(t,n);for(let c=0;cn(14,c=$));let f=600,d=350,g=!0,p=!1;const m=($,E)=>`transform: translate(${$}px, ${E}px)`,_=[-4,4],b=[-1,1];function w(){n(8,g=!0),n(9,p=!0);const $=st(this);$r(".file-circle-g").select("text").style("opacity",0),$.raise(),$.select("circle").attr("fill","var(--red)"),$.select("text").style("opacity",1)}const C=()=>{const $=$r(".file-circle-g");$.select("circle").attr("fill","var(--yellow)"),$.select("text").style("opacity",0),n(9,p=!1),setTimeout(()=>{n(8,g=!1)},1e3)};function A(){f=this.offsetWidth,d=this.offsetHeight,n(0,f),n(1,d)}return e.$$.update=()=>{e.$$.dirty&16387&&n(2,r=c.map($=>({...$,x:f/2,y:d/2,tickCount:0}))),e.$$.dirty&16384&&console.log(c.map($=>$.size).sort(($,E)=>$-E)),e.$$.dirty&1&&n(13,i=Fh().x(f/2)),e.$$.dirty&2&&n(12,o=Dh().y(d/2)),e.$$.dirty&16384&&n(3,s=We().domain(sn(c,$=>$.size)).range([12,60])),e.$$.dirty&8&&n(10,l=mh().radius($=>s($.size)+1).iterations(3)),e.$$.dirty&16384&&n(4,a=id(c.map($=>$.size).sort(($,E)=>$-E),.85)),e.$$.dirty&1&&We().domain(_).range([5,f]),e.$$.dirty&2&&We().domain(b).range([d,5]),e.$$.dirty&4&&n(11,u=Mh().nodes(r).on("tick",()=>{n(2,r=[...r])})),e.$$.dirty&15360&&(u.force("x",i),u.force("y",o),u.force("collide",l),u.alpha(.02),u.restart()),e.$$.dirty&19468&&(s.domain(sn(c,$=>$.size)),r.forEach($=>$.radius=s($.size)),u.nodes(r),l.radius($=>$.radius+.5)),e.$$.dirty&768&&g===!1&&(p||$r(".large").select("text").style("opacity",1))},[f,d,r,s,a,m,w,C,g,p,l,u,o,i,c,A]}class Ph extends ie{constructor(t){super(),se(this,t,Nh,Ih,re,{})}}/**
- * table-core
- *
- * Copyright (c) TanStack
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE.md file in the root directory of this source tree.
- *
- * @license MIT
- */function pt(e,t){return typeof e=="function"?e(t):e}function je(e,t){return n=>{t.setState(r=>({...r,[e]:pt(n,r[e])}))}}function fr(e){return e instanceof Function}function xh(e){return Array.isArray(e)&&e.every(t=>typeof t=="number")}function Th(e,t){const n=[],r=i=>{i.forEach(o=>{n.push(o);const l=t(o);l!=null&&l.length&&r(l)})};return r(e),n}function G(e,t,n){let r=[],i;return()=>{let o;n.key&&n.debug&&(o=Date.now());const l=e();if(!(l.length!==r.length||l.some((u,c)=>r[c]!==u)))return i;r=l;let s;if(n.key&&n.debug&&(s=Date.now()),i=t(...l),n==null||n.onChange==null||n.onChange(i),n.key&&n.debug&&n!=null&&n.debug()){const u=Math.round((Date.now()-o)*100)/100,c=Math.round((Date.now()-s)*100)/100,f=c/16,d=(g,p)=>{for(g=String(g);g.length