@@ -19,14 +19,16 @@ def __init__(
1919 self ,
2020 tune_org_id : str = None ,
2121 tune_api_key : str = None ,
22- base_url : str = "https://studio.tune.app/v1/threads " ,
22+ base_url : str = "https://studio.tune.app/" ,
2323 ):
2424 self .tune_org_id = tune_org_id or tu .ENV .TUNEORG_ID ()
2525 self .tune_api_key = tune_api_key or tu .ENV .TUNEAPI_TOKEN ()
2626 self .base_url = base_url
27- if not tune_api_key :
27+ if not self . tune_api_key :
2828 raise ValueError ("Either pass tune_api_key or set Env var TUNEAPI_TOKEN" )
29- self .sub = get_sub (base_url , self .tune_org_id , self .tune_api_key )
29+ self .sub = get_sub (
30+ base_url + "v1/threads/" , self .tune_org_id , self .tune_api_key
31+ )
3032
3133 def put_thread (self , thread : tt .Thread ) -> tt .Thread :
3234 if not thread .title :
@@ -46,7 +48,7 @@ def put_thread(self, thread: tt.Thread) -> tt.Thread:
4648
4749 tu .logger .info ("Creating new thread" )
4850 print (tu .to_json (body ))
49- out = self .sub . threads ("post" , json = body )
51+ out = self .sub ("post" , json = body )
5052 thread .id = out ["id" ]
5153 return thread
5254
@@ -56,7 +58,7 @@ def get_thread(
5658 messages : bool = False ,
5759 ) -> tt .Thread :
5860 # GET /threads/{thread_id}
59- fn = self .sub .threads . u (thread_id )
61+ fn = self .sub .u (thread_id )
6062 data = fn ()
6163 meta = data .get ("metadata" , {})
6264 if meta == None :
@@ -74,7 +76,7 @@ def get_thread(
7476
7577 if messages :
7678 # GET /threads/{thread_id}/messages
77- fn = self .sub .threads . u (thread_id ).messages
79+ fn = self .sub .u (thread_id ).messages
7880 data = fn ()
7981 for m in data ["data" ]:
8082 text_items = list (filter (lambda x : x ["type" ] == "text" , m ["content" ]))
@@ -101,7 +103,7 @@ def list_threads(
101103 dataset_id : Optional [str ] = None ,
102104 ) -> List [tt .Thread ]:
103105 # GET /threads
104- fn = self .sub . threads
106+ fn = self .sub
105107 params = {
106108 "limit" : limit ,
107109 "order" : order ,
@@ -125,7 +127,7 @@ def list_threads(
125127
126128 def fill_thread_messages (self , thread : tt .Thread ):
127129 # GET /threads/{thread_id}/messages
128- fn = self .sub .threads . u (thread .id ).messages
130+ fn = self .sub .u (thread .id ).messages
129131 data = fn ()
130132 for m in data ["data" ]:
131133 text_items = list (filter (lambda x : x ["type" ] == "text" , m ["content" ]))
0 commit comments