Spaces:
Runtime error
Runtime error
add error handling
Browse files
main.py
CHANGED
@@ -9,6 +9,7 @@ from cleantext import clean
|
|
9 |
from docx import Document
|
10 |
import os
|
11 |
import cohere
|
|
|
12 |
import string
|
13 |
import numpy as np
|
14 |
from numpy.linalg import norm
|
@@ -103,11 +104,14 @@ def get_resume(request: Request, resume: UploadFile = File(...)):
|
|
103 |
return clean_text
|
104 |
|
105 |
def coSkillEmbed(text):
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
|
|
|
|
|
|
111 |
|
112 |
def cosine(A, B):
|
113 |
return np.dot(A,B)/(norm(A)*norm(B))
|
|
|
9 |
from docx import Document
|
10 |
import os
|
11 |
import cohere
|
12 |
+
from cohere import CohereError
|
13 |
import string
|
14 |
import numpy as np
|
15 |
from numpy.linalg import norm
|
|
|
104 |
return clean_text
|
105 |
|
106 |
def coSkillEmbed(text):
|
107 |
+
try:
|
108 |
+
co = cohere.Client(os.getenv("COHERE_TOKEN"))
|
109 |
+
response = co.embed(
|
110 |
+
model='large',
|
111 |
+
texts=[text])
|
112 |
+
return response.embeddings
|
113 |
+
except CohereError as e:
|
114 |
+
return e
|
115 |
|
116 |
def cosine(A, B):
|
117 |
return np.dot(A,B)/(norm(A)*norm(B))
|