-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmodels.py
36 lines (27 loc) · 986 Bytes
/
models.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import sys
import subprocess
import logging
from langchain_core.pydantic_v1 import BaseModel, Field
logger = logging.getLogger(__name__)
class Bookmark(BaseModel):
"""
A bookmark to a website
"""
title: str = Field(description="The title of the bookmark")
url: str = Field(description="The URL of the bookmark")
source: str = Field(description="The source of the bookmark")
def open(self):
if sys.platform == "win32":
subprocess.Popen(["start", self.url], shell=True)
elif sys.platform == "darwin":
subprocess.Popen(["open", self.url])
elif sys.platform == "linux":
subprocess.Popen(["xdg-open", self.url])
else:
logger.warning(f'Platform "{sys.platform}" not supported. Printing URL instead')
logger.info(self.url)
class Bookmarks(BaseModel):
"""
A list of bookmarks
"""
bookmarks: list[Bookmark] = Field(description="A list of bookmarks")