talktollm 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 AMA Mazing
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,9 @@
1
+ Metadata-Version: 2.1
2
+ Name: talktollm
3
+ Version: 0.1.0
4
+ License-File: LICENSE
5
+ Requires-Dist: pywin32
6
+ Requires-Dist: pyautogui
7
+ Requires-Dist: pillow
8
+ Requires-Dist: webbrowser
9
+ Requires-Dist: optimisewait
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,23 @@
1
+ from setuptools import setup, find_packages
2
+
3
+ setup(
4
+ name='talktollm',
5
+ version='0.1.0',
6
+ packages=find_packages(),
7
+ include_package_data=True,
8
+ package_data={
9
+ 'talktollm': ['images/*/*'],
10
+ },
11
+ install_requires=[
12
+ 'pywin32',
13
+ 'pyautogui',
14
+ 'pillow',
15
+ 'webbrowser',
16
+ 'optimisewait'
17
+ ],
18
+ entry_points={
19
+ 'console_scripts': [
20
+ 'talktollm=talktollm:talkto',
21
+ ],
22
+ },
23
+ )
@@ -0,0 +1,126 @@
1
+ from time import sleep
2
+ import win32clipboard
3
+ from optimisewait import optimiseWait, set_autopath
4
+ import pyautogui
5
+ import time
6
+ import pywintypes
7
+ import base64
8
+ import io
9
+ from PIL import Image
10
+ import importlib.resources
11
+ import tempfile
12
+ import webbrowser
13
+ import os
14
+
15
+ def set_image_path(llm):
16
+ """Dynamically sets the image path for optimisewait based on package installation location."""
17
+ try:
18
+ # Use importlib.resources to get the path to the images directory
19
+ with importlib.resources.path('talktollm', 'images') as images_dir:
20
+ image_path = images_dir / llm
21
+ set_autopath(str(image_path))
22
+ except ModuleNotFoundError:
23
+ print("Warning: 'talktollm' package not found. Using temporary directory for images.")
24
+ temp_dir = tempfile.gettempdir()
25
+ image_path = os.path.join(temp_dir, 'talktollm_images', llm)
26
+ os.makedirs(image_path, exist_ok=True)
27
+ set_autopath(image_path)
28
+
29
+ def set_clipboard(text, retries=3, delay=0.2):
30
+ for i in range(retries):
31
+ try:
32
+ win32clipboard.OpenClipboard()
33
+ win32clipboard.EmptyClipboard()
34
+ try:
35
+ win32clipboard.SetClipboardText(str(text))
36
+ except Exception:
37
+ # Fallback for Unicode characters
38
+ win32clipboard.SetClipboardData(win32clipboard.CF_UNICODETEXT, str(text).encode('utf-16le'))
39
+ win32clipboard.CloseClipboard()
40
+ return # Success
41
+ except pywintypes.error as e:
42
+ if e.winerror == 5: # Access is denied
43
+ print(f"Clipboard access denied. Retrying... (Attempt {i+1}/{retries})")
44
+ time.sleep(delay)
45
+ else:
46
+ raise # Re-raise other pywintypes errors
47
+ except Exception as e:
48
+ raise # Re-raise other exceptions
49
+ print(f"Failed to set clipboard after {retries} attempts.")
50
+
51
+ def talkto(llm, prompt, imagedata=None):
52
+ llm = llm.lower()
53
+ set_image_path(llm)
54
+ urls = {
55
+ 'deepseek': 'https://chat.deepseek.com/',
56
+ 'gemini': 'https://aistudio.google.com/prompts/new_chat'
57
+ }
58
+
59
+
60
+ webbrowser.open_new_tab(urls[llm])
61
+
62
+ optimiseWait('loaded',clicks=0)
63
+
64
+ optimiseWait('message',clicks=2)
65
+
66
+ # If there are images, paste each one
67
+ if imagedata:
68
+ for img in imagedata:
69
+ set_clipboard_image(img)
70
+ pyautogui.hotkey('ctrl', 'v')
71
+ sleep(7) # Ensure upload completes before pasting the next image
72
+
73
+ set_clipboard(prompt)
74
+ pyautogui.hotkey('ctrl', 'v')
75
+
76
+ sleep(1)
77
+
78
+ optimiseWait('run')
79
+
80
+ if llm == 'gemini':
81
+ optimiseWait('done',clicks=0)
82
+
83
+ optimiseWait('copy')
84
+
85
+ pyautogui.hotkey('ctrl', 'w')
86
+
87
+ pyautogui.hotkey('alt', 'tab')
88
+
89
+ # Get LLM's response
90
+ win32clipboard.OpenClipboard()
91
+ response = win32clipboard.GetClipboardData()
92
+ win32clipboard.CloseClipboard()
93
+
94
+ return response
95
+
96
+ def set_clipboard_image(image_data, retries=3, delay=0.2):
97
+ """Set image data to clipboard with retries"""
98
+ for attempt in range(retries):
99
+ try:
100
+ binary_data = base64.b64decode(image_data.split(',')[1])
101
+ image = Image.open(io.BytesIO(binary_data))
102
+
103
+ output = io.BytesIO()
104
+ image.convert("RGB").save(output, "BMP")
105
+ data = output.getvalue()[14:] # Remove bitmap header
106
+ output.close()
107
+
108
+ win32clipboard.OpenClipboard()
109
+ win32clipboard.EmptyClipboard()
110
+ win32clipboard.SetClipboardData(win32clipboard.CF_DIB, data)
111
+ win32clipboard.CloseClipboard()
112
+ return True
113
+ except pywintypes.error as e:
114
+ if e.winerror == 5: # Access is denied
115
+ print(f"Clipboard access denied. Retrying... (Attempt {attempt+1}/{retries})")
116
+ time.sleep(delay)
117
+ else:
118
+ raise # Re-raise other pywintypes errors
119
+ except Exception as e:
120
+ print(f"Error setting image to clipboard: {e}")
121
+ return False
122
+ return False
123
+
124
+
125
+ if __name__ == "__main__":
126
+ print(talkto('gemini','How to easily get element names and such for selenium or other headless webbrowser automation',chatgpt='gpt-4o'))
@@ -0,0 +1,9 @@
1
+ Metadata-Version: 2.1
2
+ Name: talktollm
3
+ Version: 0.1.0
4
+ License-File: LICENSE
5
+ Requires-Dist: pywin32
6
+ Requires-Dist: pyautogui
7
+ Requires-Dist: pillow
8
+ Requires-Dist: webbrowser
9
+ Requires-Dist: optimisewait
@@ -0,0 +1,16 @@
1
+ LICENSE
2
+ setup.py
3
+ talktollm/__init__.py
4
+ talktollm.egg-info/PKG-INFO
5
+ talktollm.egg-info/SOURCES.txt
6
+ talktollm.egg-info/dependency_links.txt
7
+ talktollm.egg-info/entry_points.txt
8
+ talktollm.egg-info/requires.txt
9
+ talktollm.egg-info/top_level.txt
10
+ talktollm/images/deepseek/copy.png
11
+ talktollm/images/deepseek/message.png
12
+ talktollm/images/deepseek/run.png
13
+ talktollm/images/gemini/copy.png
14
+ talktollm/images/gemini/done.png
15
+ talktollm/images/gemini/message.png
16
+ talktollm/images/gemini/run.png
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ talktollm = talktollm:talkto
@@ -0,0 +1,5 @@
1
+ pywin32
2
+ pyautogui
3
+ pillow
4
+ webbrowser
5
+ optimisewait
@@ -0,0 +1 @@
1
+ talktollm