Spaces:
Configuration error

File size: 755 Bytes
10d6a91
 
 
 
d81e2df
10d6a91
 
 
 
 
 
 
 
 
 
d81e2df
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#endpointe ait model 
import requests
from config import HUGGINGFACE_API_URL, HUGGINGFACE_API_KEY


def get_huggingface_prediction(input_data): #input_data'yı main.py ile entegre etmeliyim
    headers = {
        "Authorization": f"Bearer {HUGGINGFACE_API_KEY}"
    }
    payload = {
        "inputs": input_data
    }

    response = requests.post(HUGGINGFACE_API_URL, headers=headers, json=payload)
    return response.json()



def calculate_similarity(text1, text2):
    model = SentenceTransformer('paraphrase-MiniLM-L6-v2')
    embedding1 = model.encode(text1, convert_to_tensor=True)
    embedding2 = model.encode(text2, convert_to_tensor=True)
    similarity_score = util.pytorch_cos_sim(embedding1, embedding2)
    return similarity_score.item()