Add cluster titles for time filter
This commit is contained in:
@@ -134,7 +134,7 @@ function getConnectedComponents(nodes, links) {
|
||||
export function VizTimeFilter() {
|
||||
const fgRef = useRef();
|
||||
const [selectedNode, setSelectedNode] = useState(null);
|
||||
const [inputDate, setInputDate] = useState(Date.now());
|
||||
const [inputDate, setInputDate] = useState(1682353753000);
|
||||
|
||||
const parsedInputDate = useMemo(() => {
|
||||
const d = new Date(inputDate);
|
||||
@@ -242,7 +242,7 @@ export function VizTimeFilter() {
|
||||
nodeCanvasObject={(node, ctx) => {
|
||||
const label = node.label;
|
||||
|
||||
const fontSize = 16 + 32 * Math.min(node.members.length, 5);
|
||||
const fontSize = 32 + 64 * Math.min(node.members.length, 5);
|
||||
ctx.font = `${fontSize}px Sans-Serif`;
|
||||
|
||||
const textWidth = ctx.measureText(label).width;
|
||||
|
||||
@@ -98,18 +98,17 @@ def generate_title(texts):
|
||||
"\n\nTitle:"
|
||||
)
|
||||
try:
|
||||
# response = client.chat.completions.create(
|
||||
# model=OPENAI_MODEL,
|
||||
# messages=[
|
||||
# {"role": "system", "content": "You are a helpful assistant who creates short, meaningful titles."},
|
||||
# {"role": "user", "content": prompt}
|
||||
# ]
|
||||
# )
|
||||
# title = response.choices[0].message.content.strip()
|
||||
# if title.lower().startswith("title:"):
|
||||
# title = title[6:].strip()
|
||||
# return title
|
||||
return "UNNAMED"
|
||||
response = client.chat.completions.create(
|
||||
model=OPENAI_MODEL,
|
||||
messages=[
|
||||
{"role": "system", "content": "You are a helpful assistant who creates short, meaningful titles."},
|
||||
{"role": "user", "content": prompt}
|
||||
]
|
||||
)
|
||||
title = response.choices[0].message.content.strip()
|
||||
if title.lower().startswith("title:"):
|
||||
title = title[6:].strip()
|
||||
return title
|
||||
except Exception as e:
|
||||
print("Error generating title:", e)
|
||||
return "Untitled Cluster"
|
||||
|
||||
Reference in New Issue
Block a user