Spaces:
Runtime error
Runtime error
Update icons, text, and prompts (merge PR #28 from barun-saha/visual)
Browse filesThis view is limited to 50 files because it contains too many changes. Β See raw diff
Files changed (50)
- README.md+8-2
- app.py+5-2
- bootstrap-icons-1.11.3/png128/bank2.pngDeleted
- bootstrap-icons-1.11.3/png128/flower3.pngDeleted
- global_config.py+1-1
- helpers/image_search.py+30-5
- helpers/pptx_helper.py+5-2
- bootstrap-icons-1.11.3/png128/0-circle.png β icons/png128/0-circle.pngRenamed
- bootstrap-icons-1.11.3/png128/1-circle.png β icons/png128/1-circle.pngRenamed
- bootstrap-icons-1.11.3/png128/123.png β icons/png128/123.pngRenamed
- bootstrap-icons-1.11.3/png128/2-circle.png β icons/png128/2-circle.pngRenamed
- bootstrap-icons-1.11.3/png128/3-circle.png β icons/png128/3-circle.pngRenamed
- bootstrap-icons-1.11.3/png128/4-circle.png β icons/png128/4-circle.pngRenamed
- bootstrap-icons-1.11.3/png128/5-circle.png β icons/png128/5-circle.pngRenamed
- bootstrap-icons-1.11.3/png128/6-circle.png β icons/png128/6-circle.pngRenamed
- bootstrap-icons-1.11.3/png128/7-circle.png β icons/png128/7-circle.pngRenamed
- bootstrap-icons-1.11.3/png128/8-circle.png β icons/png128/8-circle.pngRenamed
- bootstrap-icons-1.11.3/png128/9-circle.png β icons/png128/9-circle.pngRenamed
- bootstrap-icons-1.11.3/png128/activity.png β icons/png128/activity.pngRenamed
- bootstrap-icons-1.11.3/png128/airplane.png β icons/png128/airplane.pngRenamed
- bootstrap-icons-1.11.3/png128/alarm.png β icons/png128/alarm.pngRenamed
- bootstrap-icons-1.11.3/png128/alphabet.png β icons/png128/alphabet.pngRenamed
- bootstrap-icons-1.11.3/png128/amazon.png β icons/png128/amazon.pngRenamed
- bootstrap-icons-1.11.3/png128/android2.png β icons/png128/android.pngRenamed
- bootstrap-icons-1.11.3/png128/apple.png β icons/png128/apple.pngRenamed
- bootstrap-icons-1.11.3/png128/archive.png β icons/png128/archive.pngRenamed
- icons/png128/artificial-intelligence-brain.pngAdded
- bootstrap-icons-1.11.3/png128/award-fill.png β icons/png128/award-fill.pngRenamed
- bootstrap-icons-1.11.3/png128/award.png β icons/png128/award.pngRenamed
- bootstrap-icons-1.11.3/png128/balloon.png β icons/png128/balloon.pngRenamed
- bootstrap-icons-1.11.3/png128/ban.png β icons/png128/ban.pngRenamed
- bootstrap-icons-1.11.3/png128/bandaid.png β icons/png128/bandaid.pngRenamed
- bootstrap-icons-1.11.3/png128/bank.png β icons/png128/bank.pngRenamed
- bootstrap-icons-1.11.3/png128/bar-chart-line.png β icons/png128/bar-chart-line.pngRenamed
- bootstrap-icons-1.11.3/png128/basket.png β icons/png128/basket.pngRenamed
- bootstrap-icons-1.11.3/png128/battery-charging.png β icons/png128/battery-charging.pngRenamed
- bootstrap-icons-1.11.3/png128/bell-slash.png β icons/png128/bell-slash.pngRenamed
- bootstrap-icons-1.11.3/png128/bell.png β icons/png128/bell.pngRenamed
- bootstrap-icons-1.11.3/png128/bicycle.png β icons/png128/bicycle.pngRenamed
- bootstrap-icons-1.11.3/png128/bing.png β icons/png128/bing.pngRenamed
- bootstrap-icons-1.11.3/png128/binoculars.png β icons/png128/binoculars.pngRenamed
- bootstrap-icons-1.11.3/png128/bluetooth.png β icons/png128/bluetooth.pngRenamed
- bootstrap-icons-1.11.3/png128/book.png β icons/png128/book.pngRenamed
- bootstrap-icons-1.11.3/png128/bookmark.png β icons/png128/bookmark.pngRenamed
- bootstrap-icons-1.11.3/png128/bootstrap.png β icons/png128/bootstrap.pngRenamed
- bootstrap-icons-1.11.3/png128/briefcase.png β icons/png128/briefcase.pngRenamed
- bootstrap-icons-1.11.3/png128/broadcast-pin.png β icons/png128/broadcast-pin.pngRenamed
- bootstrap-icons-1.11.3/png128/browser-chrome.png β icons/png128/browser-chrome.pngRenamed
- bootstrap-icons-1.11.3/png128/browser-edge.png β icons/png128/browser-edge.pngRenamed
- bootstrap-icons-1.11.3/png128/browser-firefox.png β icons/png128/browser-firefox.pngRenamed
40 unmodified lines4142434445464748495040 unmodified linesClicking on the button will download the file.# Known Issues- **Connection timeout**: Requests sent to the Hugging Face Inference endpoint might time out.A maximum of five retries are attempted. If it still does not work, wait for a while and try again.The following is not an issue but might appear as a strange behavior:- **Cannot paste text in the input box**: If the length of the copied text is greater than the maximum40 unmodified lines4142434445464748495051525354555640 unmodified linesClicking on the button will download the file.# IconsSlideDeck AI uses a subset of icons from [bootstrap-icons-1.11.3](https://github.com/twbs/icons)(MIT license) in the slides. A few icons from [SVG Repo](https://www.svgrepo.com/)(CC0, MIT, and Apache licenses) are also used.# Known Issues- **Connection timeout**: Requests sent to the Hugging Face Inference endpoint might time out. If it still does not work, wait for a while and try again.The following is not an issue but might appear as a strange behavior:- **Cannot paste text in the input box**: If the length of the copied text is greater than the maximum
211 unmodified lines2122132142152162172187 unmodified lines226227228229230231232211 unmodified lines# Update the progress barprogress_percentage = min(len(response) / APPROX_TARGET_LENGTH, 0.95)progress_bar.progress(progress_percentage, text='Streaming content...')history.add_user_message(prompt)history.add_ai_message(response)7 unmodified lines'Cleaned JSON response:: original length: %d | cleaned length: %d',len(response), len(response_cleaned))logger.debug('Cleaned JSON: %s', response_cleaned)# Now create the PPT fileprogress_bar.progress(211 unmodified lines2122132142152162172182192202217 unmodified lines229230231232233234235211 unmodified lines# Update the progress barprogress_percentage = min(len(response) / APPROX_TARGET_LENGTH, 0.95)progress_bar.progress(progress_percentage,text='Streaming content...this might take a while...')history.add_user_message(prompt)history.add_ai_message(response)7 unmodified lines'Cleaned JSON response:: original length: %d | cleaned length: %d',len(response), len(response_cleaned))# logger.debug('Cleaned JSON: %s', response_cleaned)# Now create the PPT fileprogress_bar.progress(
34 unmodified lines3536373839404134 unmodified linesREFINEMENT_PROMPT_TEMPLATE = 'langchain_templates/chat_prompts/refinement_template_v4_two_cols_img.txt'LLM_PROGRESS_MAX = 90ICONS_DIR = 'bootstrap-icons-1.11.3/png128/'PPTX_TEMPLATE_FILES = {'Basic': {34 unmodified lines3536373839404134 unmodified linesREFINEMENT_PROMPT_TEMPLATE = 'langchain_templates/chat_prompts/refinement_template_v4_two_cols_img.txt'LLM_PROGRESS_MAX = 90ICONS_DIR = 'icons/png128/'PPTX_TEMPLATE_FILES = {'Basic': {
8 unmodified lines91011121314151617181920212223248 unmodified lines3334353637383 unmodified lines4243444546474852 unmodified lines10110210310410510610713 unmodified lines1211221238 unmodified linesfrom urllib.parse import urlparse, parse_qsimport requestsREQUEST_TIMEOUT = 12MAX_PHOTOS = 3# Only show warningslogging.getLogger('urllib3').setLevel(logging.WARNING)# Disable all child loggers of urllib3, e.g. urllib3.connectionpoollogging.getLogger('urllib3').propagate = False8 unmodified linesThis function sends a GET request to the Pexels API with the specified search queryand authorization header containing the API key. It returns the JSON response from the API.:param query: The search query for finding images.:param size: The size of the images: small, medium, or large.:param per_page: No. of results to be displayed per page.3 unmodified linesurl = 'https://api.pexels.com/v1/search'headers = {'Authorization': os.getenv('PEXEL_API_KEY')}params = {'query': query,52 unmodified lines:raises requests.exceptions.RequestException: If the request to the URL fails."""response = requests.get(url, stream=True, timeout=REQUEST_TIMEOUT)response.raise_for_status()image_data = BytesIO(response.content)13 unmodified linesheight = int(query_params.get('h', [0])[0])return width, height8 unmodified lines9101112131415161718192021222324252627288 unmodified lines37383940414243444546474849503 unmodified lines545556575859606152 unmodified lines11411511611711811912012112212312413 unmodified lines1381391401411421431441451461471488 unmodified linesfrom urllib.parse import urlparse, parse_qsimport requestsfrom dotenv import load_dotenvload_dotenv()REQUEST_TIMEOUT = 12MAX_PHOTOS = 3# Only show errorslogging.getLogger('urllib3').setLevel(logging.ERROR)# Disable all child loggers of urllib3, e.g. urllib3.connectionpool# logging.getLogger('urllib3').propagate = True8 unmodified linesThis function sends a GET request to the Pexels API with the specified search queryand authorization header containing the API key. It returns the JSON response from the API.[2024-08-31] Note:`curl` succeeds but API call via Python `requests` fail. Apparently, this could be due toCloudflare (or others) blocking the requests, perhaps identifying as Web-scraping. So,changing the user-agent to Firefox.https://stackoverflow.com/a/74674276/147021https://stackoverflow.com/a/51268523/147021https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/User-Agent/Firefox#linux:param query: The search query for finding images.:param size: The size of the images: small, medium, or large.:param per_page: No. of results to be displayed per page.3 unmodified linesurl = 'https://api.pexels.com/v1/search'headers = {'Authorization': os.getenv('PEXEL_API_KEY'),'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64; rv:10.0) Gecko/20100101 Firefox/10.0',}params = {'query': query,52 unmodified lines:raises requests.exceptions.RequestException: If the request to the URL fails."""headers = {'Authorization': os.getenv('PEXEL_API_KEY'),'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64; rv:10.0) Gecko/20100101 Firefox/10.0',}response = requests.get(url, headers=headers, stream=True, timeout=REQUEST_TIMEOUT)response.raise_for_status()image_data = BytesIO(response.content)13 unmodified linesheight = int(query_params.get('h', [0])[0])return width, heightif __name__ == '__main__':print(search_pexels(query='people'))
27 unmodified lines282930313233465 unmodified lines4995005015025035045051 unmodified line5075085095105115125137 unmodified lines52152252352452552624 unmodified lines55155255355455555627 unmodified lines# English Metric Unit (used by PowerPoint) to inchesEMU_TO_INCH_SCALING_FACTOR = 1.0 / 914400INCHES_2 = pptx.util.Inches(2)INCHES_1_5 = pptx.util.Inches(1.5)INCHES_1 = pptx.util.Inches(1)465 unmodified linesmatch = ICONS_REGEX.search(item)if not match:print('No icon/text pattern match found...skipping to the next item')continueicon_name = match.group(1)1 unmodified lineicon_path = f'{GlobalConfig.ICONS_DIR}/{icon_name}.png'left = spacing + idx * (ICON_SIZE + spacing)top = pptx.util.Inches(2) # Adjust the vertical position as needed# Calculate the center position for alignmentcenter = left + ICON_SIZE / 27 unmodified linesINCHES_1, INCHES_1)shape.fill.solid()# Set the icon's background shape colorcolor = random.choice(ICON_COLORS)24 unmodified linestext_frame = text_box.text_frametext_frame.text = accompanying_texttext_frame.word_wrap = True# Center the text verticallytext_frame.vertical_anchor = pptx.enum.text.MSO_ANCHOR.MIDDLE27 unmodified lines28293031323334465 unmodified lines5005015025035045055061 unmodified line5085095105115125135147 unmodified lines52252352452552652752824 unmodified lines55355455555655755855927 unmodified lines# English Metric Unit (used by PowerPoint) to inchesEMU_TO_INCH_SCALING_FACTOR = 1.0 / 914400INCHES_3 = pptx.util.Inches(3)INCHES_2 = pptx.util.Inches(2)INCHES_1_5 = pptx.util.Inches(1.5)INCHES_1 = pptx.util.Inches(1)465 unmodified linesmatch = ICONS_REGEX.search(item)if not match:# print('No icon/text pattern match found...skipping to the next item')continueicon_name = match.group(1)1 unmodified lineicon_path = f'{GlobalConfig.ICONS_DIR}/{icon_name}.png'left = spacing + idx * (ICON_SIZE + spacing)top = INCHES_3# Calculate the center position for alignmentcenter = left + ICON_SIZE / 27 unmodified linesINCHES_1, INCHES_1)shape.fill.solid()shape.shadow.inherit = False# Set the icon's background shape colorcolor = random.choice(ICON_COLORS)24 unmodified linestext_frame = text_box.text_frametext_frame.text = accompanying_texttext_frame.word_wrap = Truetext_frame.paragraphs[0].alignment = pptx.enum.text.PP_ALIGN.CENTER# Center the text verticallytext_frame.vertical_anchor = pptx.enum.text.MSO_ANCHOR.MIDDLE
README.md+8-2
app.py+5-2
bootstrap-icons-1.11.3/png128/bank2.pngDeleted
bootstrap-icons-1.11.3/png128/flower3.pngDeleted
global_config.py+1-1
helpers/image_search.py+30-5
helpers/pptx_helper.py+5-2
bootstrap-icons-1.11.3/png128/0-circle.png β icons/png128/0-circle.pngRenamed
bootstrap-icons-1.11.3/png128/1-circle.png β icons/png128/1-circle.pngRenamed
bootstrap-icons-1.11.3/png128/123.png β icons/png128/123.pngRenamed
bootstrap-icons-1.11.3/png128/2-circle.png β icons/png128/2-circle.pngRenamed
bootstrap-icons-1.11.3/png128/3-circle.png β icons/png128/3-circle.pngRenamed
bootstrap-icons-1.11.3/png128/4-circle.png β icons/png128/4-circle.pngRenamed
bootstrap-icons-1.11.3/png128/5-circle.png β icons/png128/5-circle.pngRenamed
bootstrap-icons-1.11.3/png128/6-circle.png β icons/png128/6-circle.pngRenamed
bootstrap-icons-1.11.3/png128/7-circle.png β icons/png128/7-circle.pngRenamed
bootstrap-icons-1.11.3/png128/8-circle.png β icons/png128/8-circle.pngRenamed
bootstrap-icons-1.11.3/png128/9-circle.png β icons/png128/9-circle.pngRenamed
bootstrap-icons-1.11.3/png128/activity.png β icons/png128/activity.pngRenamed
bootstrap-icons-1.11.3/png128/airplane.png β icons/png128/airplane.pngRenamed
bootstrap-icons-1.11.3/png128/alarm.png β icons/png128/alarm.pngRenamed
bootstrap-icons-1.11.3/png128/alphabet.png β icons/png128/alphabet.pngRenamed
bootstrap-icons-1.11.3/png128/amazon.png β icons/png128/amazon.pngRenamed
bootstrap-icons-1.11.3/png128/android2.png β icons/png128/android.pngRenamed
bootstrap-icons-1.11.3/png128/apple.png β icons/png128/apple.pngRenamed
bootstrap-icons-1.11.3/png128/archive.png β icons/png128/archive.pngRenamed
icons/png128/artificial-intelligence-brain.pngAdded
bootstrap-icons-1.11.3/png128/award-fill.png β icons/png128/award-fill.pngRenamed
bootstrap-icons-1.11.3/png128/award.png β icons/png128/award.pngRenamed
bootstrap-icons-1.11.3/png128/balloon.png β icons/png128/balloon.pngRenamed
bootstrap-icons-1.11.3/png128/ban.png β icons/png128/ban.pngRenamed
bootstrap-icons-1.11.3/png128/bandaid.png β icons/png128/bandaid.pngRenamed
bootstrap-icons-1.11.3/png128/bank.png β icons/png128/bank.pngRenamed
bootstrap-icons-1.11.3/png128/bar-chart-line.png β icons/png128/bar-chart-line.pngRenamed
bootstrap-icons-1.11.3/png128/basket.png β icons/png128/basket.pngRenamed
bootstrap-icons-1.11.3/png128/battery-charging.png β icons/png128/battery-charging.pngRenamed
bootstrap-icons-1.11.3/png128/bell-slash.png β icons/png128/bell-slash.pngRenamed
bootstrap-icons-1.11.3/png128/bell.png β icons/png128/bell.pngRenamed
bootstrap-icons-1.11.3/png128/bicycle.png β icons/png128/bicycle.pngRenamed
bootstrap-icons-1.11.3/png128/bing.png β icons/png128/bing.pngRenamed
bootstrap-icons-1.11.3/png128/binoculars.png β icons/png128/binoculars.pngRenamed
bootstrap-icons-1.11.3/png128/bluetooth.png β icons/png128/bluetooth.pngRenamed
bootstrap-icons-1.11.3/png128/book.png β icons/png128/book.pngRenamed
bootstrap-icons-1.11.3/png128/bookmark.png β icons/png128/bookmark.pngRenamed
bootstrap-icons-1.11.3/png128/bootstrap.png β icons/png128/bootstrap.pngRenamed
bootstrap-icons-1.11.3/png128/briefcase.png β icons/png128/briefcase.pngRenamed
bootstrap-icons-1.11.3/png128/broadcast-pin.png β icons/png128/broadcast-pin.pngRenamed
bootstrap-icons-1.11.3/png128/browser-chrome.png β icons/png128/browser-chrome.pngRenamed
bootstrap-icons-1.11.3/png128/browser-edge.png β icons/png128/browser-edge.pngRenamed
bootstrap-icons-1.11.3/png128/browser-firefox.png β icons/png128/browser-firefox.pngRenamed