fix date display

This commit is contained in:
Fraser
2023-04-06 21:17:52 -04:00
parent 20c9369209
commit 10ba7e75e0
2 changed files with 21 additions and 8 deletions
+12 -5
View File
@@ -1,5 +1,6 @@
from typing import List, Tuple
import dataclasses
import datetime
import itertools
import numpy as np
import openai
@@ -63,16 +64,22 @@ def get_top_k_blocks(index, user_query: str, k: int = 20) -> List[Block]:
include_metadata=True,
vector=query_embedding
)
blocks = [
Block(
blocks = []
for match in query_response['matches']:
date = match['metadata']['date']
if type(date) == datetime.date: date = date.strftime("%Y-%m-%d") # iso8601
blocks.append(Block(
title = match['metadata']['title'],
author = match['metadata']['author'],
date = match['metadata']['date'],
date = date,
url = match['metadata']['url'],
tags = match['metadata']['tags'],
text = match['metadata']['text']
) for match in query_response['matches']
]
))
t2 = time.time()
print("Time to get top-k blocks: ", t2 - t1)
+9 -3
View File
@@ -50,13 +50,19 @@ const Colours = [
];
const ShowCitation: React.FC<{citation: Citation, i: number}> = ({citation, i}) => {
var c_str = citation.title;
if (citation.author && citation.author !== "")
c_str += " - " + citation.author;
if (citation.date && citation.date !== "")
c_str += " - " + citation.date;
return (
<a className={Colours[i % Colours.length] + " border-2 flex items-center rounded my-2 text-sm no-underline w-fit"}
href={citation.url} target="_blank" rel="noreferrer">
<span className="mx-1"> [{i + 1}] </span>
<p className="mx-1 my-0">
{citation.title + " - " + citation.author + " - " + citation.date}
</p>
<p className="mx-1 my-0"> {c_str} </p>
</a>
);
};