Spaces:
Running
Running
Download assets/FeedView-DZctvmtw.js from huggingface/paperswithcode: direct link, hf CLI and curl.
- Browser
- Download file 14.7 kB
-
https://huggingface.co/spaces/huggingface/paperswithcode/resolve/main/assets/FeedView-DZctvmtw.js
- Command line
-
hf download hf://spaces/huggingface/paperswithcode/assets/FeedView-DZctvmtw.js
-
curl -L -o FeedView-DZctvmtw.js https://huggingface.co/spaces/huggingface/paperswithcode/resolve/main/assets/FeedView-DZctvmtw.js
14.7 kB
| import{j as e,H as re,L as j,b as ee,c as se,d as ne,r as m,i as K,e as ae,f as ie,C as oe}from"./index-C2uVRBgm.js";import{d as G,t as Q}from"./colors-CYJo8Vj2.js";import{L as le,F as ce,B as de,M as he}from"./mail-D5enfadp.js";import{P as me}from"./plus-S7qjFpAw.js";import{r as Y}from"./research-C0QOOVFw.js";import{P as pe}from"./components-B2P9mD5v.js";import{M as ue,c as ge,S as P}from"./chatPrompts-B5jCAxs8.js";import{P as fe}from"./PaperFeedFilters-DL0OUsb1.js";import{r as xe,P as je,w as be}from"./PaperDateFilter-Bcm0yGcB.js";import{S as ye,P as we,D as ve,u as Ne,a as ke,M as _e,R as Se,W as Pe,A as Le,b as Ae,q as Te,c as Ce,g as Fe}from"./chatLaunch-BS5TAhHH.js";import{c as Ee}from"./chat-BZwHRqJu.js";import{c as V}from"./catalog-CUh96gFy.js";import{u as Me}from"./usePapers-DqIfr-UY.js";import{u as De}from"./useIntersectionObserver-cggSTlhW.js";import{S}from"./skeleton-BtMQpCs1.js";import{A as Re,a as He}from"./alert-7oLVYxe5.js";import{u as B}from"./useQuery-DceN3et-.js";import{u as Oe}from"./useInfiniteQuery-D83MX4up.js";import"./paperQueryKeys-BP2E-0yf.js";import"./LatexTitle-D0kKUw3O.js";import"./papers-BSHjPS5U.js";import"./safeExternalHref-CkBrsh84.js";import"./AgentLogos-CrC7Cwax.js";import"./popover-sfEMbQ9e.js";import"./chevron-down-DSGJs-Ut.js";import"./earth-D7OyK13S.js";function X({signedIn:r,popularTasks:f=[]}){const i=[...r?[]:[e.jsx(e.Fragment,{children:"Sign in with your Hugging Face account. Your follows stay private."})],e.jsxs(e.Fragment,{children:["Open any task, method, benchmark, author, or organization page and click"," ",e.jsxs("span",{className:"following-intro-pill",children:[e.jsx(me,{"aria-hidden":"true"}),"Follow"]}),"."]}),e.jsxs(e.Fragment,{children:["New papers and benchmark results from everything you follow appear here, ranked like the trending feed. You can also get them as a weekly email from ",e.jsx(j,{to:"/settings",children:"Settings"}),"."]})];return e.jsxs("section",{className:"following-intro","aria-labelledby":"following-intro-title",children:[e.jsx("h2",{id:"following-intro-title",children:"Build your personal research feed"}),e.jsx("p",{className:"following-intro-lead",children:"Follow the tasks, benchmarks, authors, and organizations you care about, and this page collects their latest papers and results in one place."}),e.jsx("ol",{className:"following-intro-steps",children:i.map((o,d)=>e.jsxs("li",{children:[e.jsx("span",{"aria-hidden":"true",children:d+1}),e.jsx("p",{children:o})]},d))}),!r&&e.jsx("div",{className:"following-intro-signin",children:e.jsx(re,{returnTo:"/following",label:"Sign in to start following"})}),e.jsxs("div",{className:"following-intro-browse",children:[e.jsxs(j,{to:"/tasks",children:[e.jsx(le,{"aria-hidden":"true"}),"Browse tasks"]}),e.jsxs(j,{to:"/methods",children:[e.jsx(ce,{"aria-hidden":"true"}),"Browse methods"]}),e.jsxs(j,{to:"/organizations",children:[e.jsx(de,{"aria-hidden":"true"}),"Browse organizations"]}),r&&e.jsxs(j,{to:"/settings",children:[e.jsx(he,{"aria-hidden":"true"}),"Weekly email"]})]}),f.length>0&&e.jsxs("div",{className:"following-intro-popular",children:[e.jsx("h3",{children:"Popular tasks to follow"}),e.jsx("div",{children:f.map(o=>e.jsx(j,{to:`/tasks/${o.slug}`,children:G(o.name,o.slug)},o.id))})]})]})}const Ie=[["trending","trending"],["date_published","newest"],["citation_count","most cited"]],J=45,qe=1800,Be=25,$e=350,Ke=r=>{const[f,i]=m.useState(P[0].slice(0,1)),[o,d]=m.useState(0);return m.useEffect(()=>{var y,L;if(!r)return;if((L=(y=window.matchMedia)==null?void 0:y.call(window,"(prefers-reduced-motion: reduce)"))!=null&&L.matches){i(P[0]),d(0);return}let h=0,g=1,l=!1,x;i(P[0].slice(0,g)),d(0);const b=()=>{const v=P[h];if(!l){if(g+=1,i(v.slice(0,g)),g===v.length){l=!0,x=window.setTimeout(b,qe);return}x=window.setTimeout(b,J);return}if(g-=1,i(v.slice(0,g)),g===0){l=!1,h=(h+1)%P.length,d(h),x=window.setTimeout(b,$e);return}x=window.setTimeout(b,Be)};return x=window.setTimeout(b,J),()=>window.clearTimeout(x)},[r]),{placeholder:f,prompt:P[o]}},ze=r=>r==="trending"||r==="date_published"||r==="citation_count"?r:"trending",Ue=()=>{var R,H,O,I;const r=ee(),f=ae(),i=!!((R=se())!=null&&R.user),d=((H=B({queryKey:["chatModels"],queryFn:Fe,retry:!1,enabled:K()&&i&&!f}).data)==null?void 0:H.items)??(ie()?ye:we),[h,g]=m.useState({text:"",paperMentions:[]}),l=h.text,[x,b]=m.useState(0),[y,L]=m.useState(ve),[v,T]=m.useState(!0),[N,C]=m.useState("low"),[k,F]=m.useState(!1),[w,E]=m.useState(null),{placeholder:z,prompt:U}=Ke(!l),A=l?ge(l):U,p=m.useRef(null),M=B({queryKey:["chatAvailability"],queryFn:()=>Ee.getAvailability(),retry:!1,enabled:K()}),W=!!((O=M.data)!=null&&O.web_search_available),_=K()&&((I=M.data)==null?void 0:I.paper_mentions_enabled)!==!1,n=Ne({draft:h,onChange:g,enabled:_,textareaRef:p});m.useLayoutEffect(()=>{const t=p.current;if(!t)return;const c=()=>{if(t.style.height="auto",l){t.style.height=`${Math.min(t.scrollHeight,160)}px`;return}const u=t.placeholder,s=P.reduce((a,q)=>(t.placeholder=q,Math.max(a,t.scrollHeight)),0);t.placeholder=u,t.style.height=`${Math.min(s,160)}px`};return c(),window.addEventListener("resize",c),()=>window.removeEventListener("resize",c)},[l]);const D=async(t=h)=>{const c=t.text.trim();if(!(!c||k)){if(f){const u=new URLSearchParams({q:c,model:y}),s=`${oe}?${u}`,a=window.open(s,"_blank");if(!a){E(s);return}a.opener=null,E(null),g({text:"",paperMentions:[]});return}F(!0),Te(t,y,{webSearchEnabled:v,reasoningEffort:N});try{const u=await Ce(y,N);r(`/chat/${u.id}`)}catch{r("/chat")}}};return e.jsxs(e.Fragment,{children:[!f&&e.jsx("div",{className:"ask-home-new",children:"Hint: type @ to bring papers into context, or press Tab to use a suggestion"}),e.jsxs("div",{className:"ask-home",children:[e.jsxs("div",{className:"ask-home-textarea-wrap",children:[e.jsx(ke,{text:h.text,mentions:h.paperMentions,scrollTop:x,variant:"home",completion:l?A:""}),e.jsx("textarea",{ref:p,rows:1,value:l,placeholder:z,"aria-label":"Ask the assistant",disabled:k,onChange:t=>n.updateText(t.target.value,t.target.selectionStart),onSelect:t=>n.refresh(t.currentTarget.selectionStart),onClick:t=>n.refresh(t.currentTarget.selectionStart),onScroll:t=>b(t.currentTarget.scrollTop),onBlur:t=>{var c,u;(u=(c=t.relatedTarget)==null?void 0:c.closest)!=null&&u.call(c,".chat-paper-picker")||window.setTimeout(n.close,0)},onKeyDown:t=>{if(!n.keyDown(t)){if(t.key==="Tab"&&!t.shiftKey&&A){t.preventDefault();const c=l+A;n.updateText(c,c.length),window.requestAnimationFrame(()=>{var u;return(u=p.current)==null?void 0:u.setSelectionRange(c.length,c.length)});return}t.key==="Enter"&&!t.shiftKey&&(t.preventDefault(),D())}},role:_?"combobox":void 0,"aria-expanded":_?n.open:void 0,"aria-controls":n.open?n.pickerId:void 0,"aria-activedescendant":n.open&&n.results.length?`${n.optionIdPrefix}-${n.activeIndex}`:void 0,"aria-autocomplete":_?"list":void 0,"aria-describedby":n.message?"ask-home-paper-mention-message":void 0})]}),w&&e.jsx("div",{className:"chat-paper-mention-message",role:"alert",children:e.jsx("a",{href:w,target:"_blank",rel:"noreferrer",children:"Open this question on paperswithcode.co"})}),n.message&&e.jsx("div",{id:"ask-home-paper-mention-message",className:"chat-paper-mention-message",role:"alert",children:n.message}),e.jsxs("div",{className:"ask-home-foot",children:[e.jsxs("div",{className:"ask-home-provider-tools",children:[e.jsx(_e,{models:d,selectedModel:y,onModelChange:L}),!f&&e.jsx(Se,{value:N,onChange:C,disabled:k}),W&&e.jsx(Pe,{enabled:v,onChange:T,disabled:k})]}),e.jsx("button",{type:"button",className:`chat-send${l.trim()?" chat-send-on":""}`,onClick:()=>void D(),disabled:!l.trim()||k,"aria-label":"Ask the assistant",children:e.jsx(Le,{})})]}),e.jsx(Ae,{open:n.open,query:n.query,results:n.results,activeIndex:n.activeIndex,loading:n.loading,error:n.error,onSelect:n.select,id:n.pickerId,optionIdPrefix:n.optionIdPrefix})]})]})},te={task:"Task",method:"Method",benchmark:"Benchmark",author:"Author",organization:"Org"},Z=Object.keys(te),js=({following:r=!1})=>{var R,H,O,I,t,c,u;const f=ee(),i=se(),o=i==null?void 0:i.user,[d,h]=ne(),g=ze(d.get("order_by")),l=xe(d,void 0,r?"month":"week"),x=d.get("has_code")==="true",b=d.get("has_hf_artifacts")==="true",y=s=>{const a=new URLSearchParams(d);a.set("order_by",s),r?f(`/?${a}`):h(a)},L=s=>{const a=new URLSearchParams(d);s?a.set("has_code","true"):a.delete("has_code"),h(a)},v=s=>{const a=new URLSearchParams(d);s?a.set("has_hf_artifacts","true"):a.delete("has_hf_artifacts"),h(a)},T=B({queryKey:["top-tasks-sidebar"],queryFn:()=>V.topTasks(8),staleTime:10*60*1e3}),N=B({queryKey:["trending-tasks-sidebar"],queryFn:()=>V.trendingTasks({limit:8,level:0}),staleTime:10*60*1e3}),C=Me({enabled:!r,page_size:30,order_by:g,order_dir:"desc",start_date:l.startDate,end_date:l.endDate,include_resources:!0,has_code:x,has_hf_artifacts:b}),k={...l,hasCode:x,hasHfArtifacts:b},F=Oe({queryKey:["research-feed",o==null?void 0:o.hf_subject,k],queryFn:({pageParam:s})=>Y.following(s,k),initialPageParam:0,getNextPageParam:(s,a)=>s.length===40?a.length*40:void 0,enabled:r&&!!o}),w=B({queryKey:["research-follows",o==null?void 0:o.hf_subject],queryFn:Y.follows,enabled:r&&!!o}),E=r&&!!o&&((R=w.data)==null?void 0:R.length)===0,z=m.useMemo(()=>r&&w.data?[...w.data].sort((s,a)=>Z.indexOf(s.kind)-Z.indexOf(a.kind)):[],[r,w.data]),U=r&&(!!(i!=null&&i.isLoading)||!!o&&!E),A=(H=T.data)==null?void 0:H.slice(0,8),p=r?F:C,M=m.useMemo(()=>{var s,a;return r?((s=F.data)==null?void 0:s.pages.flatMap(q=>q.map($=>({...Q($.paper),followReasons:$.reasons}))))??[]:((a=C.data)==null?void 0:a.pages.flatMap(q=>q.results.map($=>({...Q($),followReasons:void 0}))))??[]},[r,F.data,C.data]),{targetRef:W,isIntersecting:_}=De({rootMargin:"400px"});m.useEffect(()=>{_&&p.hasNextPage&&!p.isFetchingNextPage&&p.fetchNextPage()},[_,p.hasNextPage,p.isFetchingNextPage]);const n=p.isLoading||r&&(i==null?void 0:i.isLoading),D=p.error;return e.jsxs("div",{className:"page",children:[e.jsx("div",{className:"feed-header",children:e.jsxs("div",{children:[e.jsxs("h1",{className:"feed-title",children:["Trending ",e.jsx("em",{children:"Research"})]}),e.jsx("div",{className:"feed-subtitle",children:"Curated daily from arXiv and Hugging Face"})]})}),e.jsxs("div",{className:"layout-with-sidebar",children:[e.jsxs("aside",{className:"sidebar",children:[U?e.jsxs("div",{className:"sidebar-section sidebar-section-follows",children:[e.jsx("div",{className:"sidebar-label",children:"You follow"}),((i==null?void 0:i.isLoading)||w.isLoading)&&e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:8},children:Array.from({length:4}).map((s,a)=>e.jsx(S,{className:"h-5 w-full"},a))}),w.isError&&e.jsx("div",{style:{fontSize:12,color:"var(--ink-faint)"},children:"Couldn't load your follows."}),z.map(s=>e.jsxs(j,{to:s.url,className:"sidebar-link sidebar-follow-link",children:[e.jsx("span",{className:"sidebar-follow-kind",children:te[s.kind]}),e.jsx("span",{className:"sidebar-follow-name",children:s.name})]},`${s.kind}-${s.entity_id}`))]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"sidebar-section sidebar-section-top-domains",children:[e.jsx("div",{className:"sidebar-label",children:"Top Domains"}),T.isLoading&&e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:8},children:Array.from({length:6}).map((s,a)=>e.jsx(S,{className:"h-5 w-full"},a))}),(O=T.data)==null?void 0:O.map(s=>e.jsxs(j,{to:`/tasks/${s.slug}`,className:"sidebar-link",children:[G(s.name,s.slug),s.paper_count!=null&&e.jsx("span",{className:"count",children:s.paper_count})]},s.id)),e.jsx(j,{to:"/tasks",className:"sidebar-link",style:{marginTop:8,fontStyle:"italic"},children:"all domains →"})]}),e.jsxs("div",{className:"sidebar-section sidebar-section-trending-domains",children:[e.jsx("div",{className:"sidebar-label",children:"Trending Domains"}),N.isLoading&&e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:8},children:Array.from({length:6}).map((s,a)=>e.jsx(S,{className:"h-5 w-full"},a))}),((t=(I=N.data)==null?void 0:I.results)==null?void 0:t.length)===0&&!N.isLoading&&e.jsx("div",{style:{fontSize:12,color:"var(--ink-faint)"},children:"No domains gaining momentum right now."}),(u=(c=N.data)==null?void 0:c.results)==null?void 0:u.map(s=>e.jsxs(j,{to:`/tasks/${s.slug}`,className:"sidebar-link",children:[G(s.name,s.slug),e.jsxs("span",{className:"count",children:[s.share_lift.toFixed(1),"x"]})]},s.id))]})]}),e.jsx(ue,{})]}),e.jsxs("div",{className:"feed-main",children:[(K()||ae())&&e.jsx("div",{className:"feed-chat",children:e.jsx(Ue,{})}),e.jsxs("div",{className:"feed-content",children:[e.jsxs("div",{className:"sort-bar home-feed-sort-bar",children:[e.jsxs("div",{className:"paper-feed-toolbar-controls",children:[e.jsxs("div",{className:"sort-options",children:[Ie.map(([s,a])=>e.jsx("button",{className:`sort-btn ${!r&&g===s?"active":""}`,onClick:()=>y(s),children:a},s)),e.jsx("button",{className:`sort-btn ${r?"active":""}`,onClick:()=>{const s=new URLSearchParams(d);s.delete("order_by");const a=s.toString();f(a?`/following?${a}`:"/following")},children:"following"})]}),e.jsx(fe,{hasCode:x,hasHfArtifacts:b,onHasCodeChange:L,onHasHfArtifactsChange:v})]}),e.jsx(je,{startDate:l.startDate,endDate:l.endDate,onChange:s=>h(be(d,s))})]}),D&&e.jsx(Re,{variant:"destructive",className:"mb-4",children:e.jsxs(He,{children:["Failed to load papers. ",e.jsx("button",{type:"button",onClick:()=>void p.refetch(),children:"Try again"})]})}),r&&!(i!=null&&i.isLoading)&&!o?e.jsx(X,{signedIn:!1,popularTasks:A}):E?e.jsx(X,{signedIn:!0,popularTasks:A}):n?e.jsx("div",{className:"paper-list",children:Array.from({length:6}).map((s,a)=>e.jsxs("div",{className:"paper-card",children:[e.jsx("div",{className:"paper-thumb-wrap",children:e.jsx(S,{className:"paper-thumb-skeleton"})}),e.jsxs("div",{className:"paper-body",style:{flex:1,gap:12},children:[e.jsx(S,{className:"h-6 w-3/4"}),e.jsx(S,{className:"h-4 w-1/2"}),e.jsx(S,{className:"h-12 w-full"})]})]},a))}):M.length===0?D?null:e.jsx("div",{className:"no-results",children:r?e.jsxs(e.Fragment,{children:["No papers from your follows match these filters. Widen the date range, or follow more from ",e.jsx(j,{to:"/tasks",children:"tasks"}),", ",e.jsx(j,{to:"/methods",children:"methods"}),", benchmark, author, or organization pages."]}):"No papers in this window."}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"paper-list",children:M.map((s,a)=>e.jsx(pe,{paper:s,rank:a+1,followReasons:s.followReasons},s.id))}),e.jsx("div",{ref:W,style:{height:1}}),p.isFetchingNextPage&&e.jsx("div",{style:{padding:"20px 0",textAlign:"center",color:"var(--ink-faint)"},children:"Loading more…"})]})]})]})]})]})};export{Ue as AskAssistant,js as default}; | |