File tree Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change
1
+ import requests
2
+
3
+ def Get_Embeddings_Sentences_API (textoflink ):
4
+ listofsentences_embeddings = []
5
+ try :
6
+ session = requests .Session ()
7
+ session .headers .update ({'Authorization' : 'Token ?' })
8
+ resultAPi = session .post ('http://127.0.0.1:8000/v1/beta/api/embeddings_sentences/' ,
9
+ data = {'text' : textoflink })
10
+ if resultAPi .status_code == 200 :
11
+ listofsentences_embeddings = resultAPi .json ()
12
+ else :
13
+ listofsentences_embeddings = {'error' :'Status code is: ' + str (resultAPi .status_code )}
14
+ except Exception as e :
15
+ print (str (e ))
16
+ pass
17
+
18
+ return listofsentences_embeddings
19
+
20
+ listres = Get_Embeddings_Sentences_API ("cat play with ball.\r \n cat is on the table." )
21
+ if 'error' not in listres :
22
+ for key in listres ['Embeddings' ]:
23
+ for i in key .items ():
24
+ print ("sentence :" ,i [0 ])
25
+ print ("embbedding :" , i [1 ])
26
+ else :
27
+ print (listres )
You can’t perform that action at this time.
0 commit comments