File tree Expand file tree Collapse file tree 4 files changed +27
-131
lines changed Expand file tree Collapse file tree 4 files changed +27
-131
lines changed Original file line number Diff line number Diff line change 2
2
import uvicorn
3
3
from kura .cli .server import api
4
4
from rich import print
5
+ import os
5
6
6
7
app = typer .Typer ()
7
8
8
9
9
10
@app .command ()
10
- def start_app ():
11
+ def start_app (
12
+ dir : str = typer .Option (
13
+ "./checkpoints" ,
14
+ help = "Directory to use for checkpoints, relative to the current directory" ,
15
+ ),
16
+ ):
11
17
"""Start the FastAPI server"""
12
-
18
+ os . environ [ "KURA_CHECKPOINT_DIR" ] = dir
13
19
uvicorn .run (api , host = "0.0.0.0" , port = 8000 )
14
20
print (
15
21
"\n [bold green]🚀 Access website at[/bold green] [bold blue][http://localhost:8000](http://localhost:8000)[/bold blue]\n "
Original file line number Diff line number Diff line change 11
11
generate_new_chats_per_week_data ,
12
12
)
13
13
import json
14
+ import os
14
15
15
16
api = FastAPI ()
16
17
@@ -57,16 +58,21 @@ async def analyse_conversations(conversation_data: ConversationData):
57
58
for conversation in conversation_data .data
58
59
]
59
60
60
- # Load clusters from checkpoint file if it exists
61
61
clusters_file = (
62
- Path (__file__ ). parent . parent . parent
63
- / "checkpoints/ dimensionality_checkpoints.json"
62
+ Path (os . path . abspath ( os . environ [ "KURA_CHECKPOINT_DIR" ]))
63
+ / "dimensionality_checkpoints.json"
64
64
)
65
65
clusters = []
66
66
67
+ print (clusters_file )
68
+
69
+ # Load clusters from checkpoint file if it exists
70
+
67
71
if not clusters_file .exists ():
68
- kura = Kura ()
69
- kura .conversations = conversations
72
+ kura = Kura (
73
+ checkpoint_dir = Path (os .path .abspath (os .environ ["KURA_CHECKPOINT_DIR" ])),
74
+ conversations = conversations [:100 ],
75
+ )
70
76
await kura .cluster_conversations ()
71
77
72
78
with open (clusters_file ) as f :
Original file line number Diff line number Diff line change @@ -25,10 +25,17 @@ def __init__(
25
25
meta_cluster_model : BaseMetaClusterModel = MetaClusterModel (),
26
26
dimensionality_reduction : BaseDimensionalityReduction = HDBUMAP (),
27
27
max_clusters : int = 10 ,
28
- checkpoint_dir : str = "checkpoints" ,
28
+ checkpoint_dir : str = "./ checkpoints" ,
29
29
cluster_checkpoint_name : str = "clusters.json" ,
30
30
meta_cluster_checkpoint_name : str = "meta_clusters.json" ,
31
31
):
32
+ # Override checkpoint dirs so that they're the same for the models
33
+ summarisation_model .checkpoint_dir = checkpoint_dir
34
+ cluster_model .checkpoint_dir = checkpoint_dir
35
+ meta_cluster_model .checkpoint_dir = checkpoint_dir
36
+ dimensionality_reduction .checkpoint_dir = checkpoint_dir
37
+
38
+ self .embedding_model = embedding_model
32
39
self .embedding_model = embedding_model
33
40
self .summarisation_model = summarisation_model
34
41
self .conversations = conversations
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments