File tree Expand file tree Collapse file tree 3 files changed +13
-33
lines changed Expand file tree Collapse file tree 3 files changed +13
-33
lines changed Original file line number Diff line number Diff line change 11from importlib import util
22import os
3- import re
43
5- def get_version_from_setup ():
6- try :
7- setup_path = os .path .join (os .path .dirname (os .path .dirname (__file__ )), 'setup.py' )
8- with open (setup_path , 'r' ) as f :
9- content = f .read ()
10- version_match = re .search (r'version=["\']([^"\']+)["\']' , content )
11- if version_match :
12- return version_match .group (1 )
13- except Exception :
14- pass
15- return "unknown"
4+ # Version information
5+ __version__ = "0.1.3"
166
177# Get the path to the root optillm.py
188spec = util .spec_from_file_location (
@@ -46,9 +36,6 @@ def get_version_from_setup():
4636# Export streaming response generation
4737generate_streaming_response = module .generate_streaming_response
4838
49- # Version information
50- __version__ = get_version_from_setup ()
51-
5239# List of exported symbols
5340__all__ = [
5441 'main' ,
Original file line number Diff line number Diff line change 44import os
55from bs4 import BeautifulSoup
66from urllib .parse import urlparse
7+ from optillm import __version__
78
89SLUG = "readurls"
910
10- def get_version ():
11- try :
12- # Get path to setup.py relative to this file
13- current_dir = os .path .dirname (__file__ )
14- package_root = os .path .dirname (os .path .dirname (current_dir ))
15- setup_path = os .path .join (package_root , 'setup.py' )
16-
17- with open (setup_path , 'r' ) as f :
18- content = f .read ()
19- version_match = re .search (r'version=["\']([^"\']+)["\']' , content )
20- if version_match :
21- return version_match .group (1 )
22- except Exception :
23- pass
24- return "unknown"
25-
2611def extract_urls (text : str ) -> List [str ]:
2712 # Updated regex pattern to be more precise
2813 url_pattern = re .compile (r'https?://[^\s\'"]+' )
@@ -41,9 +26,8 @@ def extract_urls(text: str) -> List[str]:
4126
4227def fetch_webpage_content (url : str , max_length : int = 100000 ) -> str :
4328 try :
44- version = get_version ()
4529 headers = {
46- 'User-Agent' : f'optillm/{ version } (https://github.com/codelion/optillm)'
30+ 'User-Agent' : f'optillm/{ __version__ } (https://github.com/codelion/optillm)'
4731 }
4832
4933 response = requests .get (url , headers = headers , timeout = 10 )
Original file line number Diff line number Diff line change 11from setuptools import setup , find_packages
22
3+ def read_version ():
4+ version_dict = {}
5+ try :
6+ with open ('optillm/__init__.py' , 'r' ) as f :
7+ exec (f .read (), version_dict )
8+ return version_dict .get ('__version__' , 'unknown' )
9+ except Exception :
10+ return 'unknown'
11+
312setup (
413 name = "optillm" ,
514 version = "0.1.2" ,
You can’t perform that action at this time.
0 commit comments