mirror of
https://github.com/wassname/stampy-chat.git
synced 2026-09-11 12:50:34 +08:00
fix date display
This commit is contained in:
+12
-5
@@ -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)
|
||||
|
||||
@@ -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>
|
||||
);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user