File size: 666 Bytes
6d584c3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import wikipedia
from constants import MODEL_NAME_INFO
    
def get_model_info(model_name):
    try:
        if model_name in MODEL_NAME_INFO:
            return MODEL_NAME_INFO[model_name][0], MODEL_NAME_INFO[model_name][1] 
        
        description = wikipedia.summary(model_name, sentences=4)
        link = wikipedia.page(model_name).url
        return description, link
    
    
    except ConnectionError:
        return "Couldn't fetch data due to connection error!", "No link found!"
        
    except wikipedia.exceptions.PageError:
        print(f"No Wikipedia page found for '{model_name}'")
        return "No description found!", "No link found!"