willreynolds5 / autogpt-social Goto Github PK
View Code? Open in Web Editor NEWAutonomous Instagram bot which creates and optimizes posts to maximize engagement
License: MIT License
Autonomous Instagram bot which creates and optimizes posts to maximize engagement
License: MIT License
Traceback (most recent call last):
File "C:\Users...........\OneDrive\Documents\INSTAGRAM BOT\AutoGPT-Social\instagram_util\convert_jpg.py", line 13, in convert_to_jpg
os.remove(input_file_path)
PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: 'accounts\..................................\queue\designer_handbag_resting_on_a_marble_surface.jpg'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users...............\OneDrive\Documents\INSTAGRAM BOT\AutoGPT-Social\start_bot.py", line 164, in
main_job(project_name, post_count)
File "C:\Users...................\OneDrive\Documents\INSTAGRAM BOT\AutoGPT-Social\start_bot.py", line 125, in main_job
prompt, post_content, image_path = start_post(prompt, project_name)
File "C:\Users..................\OneDrive\Documents\INSTAGRAM BOT\AutoGPT-Social\start_bot.py", line 38, in start_post
image_path, description = get_image(project_name)
File "C:\Users................\OneDrive\Documents\INSTAGRAM BOT\AutoGPT-Social\start_bot.py", line 54, in get_image
image_path = convert_to_jpg(os.path.join("accounts", project_name, "queue", image_fn))
File "C:\Users................\OneDrive\Documents\INSTAGRAM BOT\AutoGPT-Social\instagram_util\convert_jpg.py", line 17, in convert_to_jpg
raise IOError(f"Error converting {input_file_path} to JPEG")
OSError: Error converting accounts...............................\queue\designer_handbag_resting_on_a_marble_surface.jpg to JPEG
PS C:\Users..............\OneDrive\Documents\INSTAGRAM BOT\AutoGPT-Social>
when i run initialize_bot.py and add hashtag this throw me error HTTP error code 401. I tried looking for this error on instaloader but culdn't fix it.
i tried it locally on my pc (with VPN) and VPS
I commented out the line on line 59 in initialize_bot.py
hashtags = get_related_hashtags([hashtag.strip().replace('#', '') for hashtag in hashtags_input.split(',')])
and the bot post a picture with text, as it should be (i think).
error:
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/ubuntu/.local/lib/python3.10/site-packages/instaloader/instaloadercontext.py", line 352, in get_json
raise ConnectionException("HTTP error code {}.".format(resp.status_code))
instaloader.exceptions.ConnectionException: HTTP error code 401.
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/ubuntu/AutoGPT-Social/initialize_bot.py", line 66, in <module>
main()
File "/home/ubuntu/AutoGPT-Social/initialize_bot.py", line 59, in main
hashtags = get_related_hashtags([hashtag.strip().replace('#', '') for hashtag in hashtags_input.split(',')])
File "/home/ubuntu/AutoGPT-Social/instagram_util/hashtags.py", line 11, in get_related_hashtags
posts = L.get_hashtag_posts(hashtag)
File "/home/ubuntu/.local/lib/python3.10/site-packages/instaloader/instaloader.py", line 1187, in get_hashtag_posts
return Hashtag.from_name(self.context, hashtag).get_posts_resumable()
File "/home/ubuntu/.local/lib/python3.10/site-packages/instaloader/structures.py", line 1539, in from_name
hashtag._obtain_metadata()
File "/home/ubuntu/.local/lib/python3.10/site-packages/instaloader/structures.py", line 1553, in _obtain_metadata
self._node = self._query({"__a": 1, "__d": "dis"})
File "/home/ubuntu/.local/lib/python3.10/site-packages/instaloader/structures.py", line 1548, in _query
json_response = self._context.get_json("explore/tags/{0}/".format(self.name), params)
File "/home/ubuntu/.local/lib/python3.10/site-packages/instaloader/instaloadercontext.py", line 395, in get_json
return self.get_json(path=path, params=params, host=host, session=sess, _attempt=_attempt + 1)
File "/home/ubuntu/.local/lib/python3.10/site-packages/instaloader/instaloadercontext.py", line 395, in get_json
return self.get_json(path=path, params=params, host=host, session=sess, _attempt=_attempt + 1)
File "/home/ubuntu/.local/lib/python3.10/site-packages/instaloader/instaloadercontext.py", line 385, in get_json
raise ConnectionException(error_string) from err
instaloader.exceptions.ConnectionException: JSON Query to explore/tags/it/: HTTP error code 401.
Bro, thank you so much, you're the best!
one question))))), why he writes posts in english? i asked the account summary in another language
I don't know what is my problem:
C:\Users\Owrak>pip install openai instagrapi instaloader Pillow
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: openai in c:\users\owrak\appdata\roaming\python\python311\site-packages (0.28.1)
Requirement already satisfied: instagrapi in c:\users\owrak\appdata\roaming\python\python311\site-packages (2.0.0)
Requirement already satisfied: instaloader in c:\users\owrak\appdata\roaming\python\python311\site-packages (4.10)
Requirement already satisfied: Pillow in c:\users\owrak\appdata\roaming\python\python311\site-packages (10.0.1)
Requirement already satisfied: requests>=2.20 in c:\users\owrak\appdata\roaming\python\python311\site-packages (from openai) (2.31.0)
Requirement already satisfied: tqdm in c:\users\owrak\appdata\roaming\python\python311\site-packages (from openai) (4.66.1)
Requirement already satisfied: aiohttp in c:\users\owrak\appdata\roaming\python\python311\site-packages (from openai) (3.8.5)
Requirement already satisfied: PySocks==1.7.1 in c:\users\owrak\appdata\roaming\python\python311\site-packages (from instagrapi) (1.7.1)
Requirement already satisfied: pydantic==1.10.9 in c:\users\owrak\appdata\roaming\python\python311\site-packages (from instagrapi) (1.10.9)
Requirement already satisfied: pycryptodomex==3.18.0 in c:\users\owrak\appdata\roaming\python\python311\site-packages (from instagrapi) (3.18.0)
Requirement already satisfied: typing-extensions>=4.2.0 in c:\users\owrak\appdata\roaming\python\python311\site-packages (from pydantic==1.10.9->instagrapi) (4.8.0)
Requirement already satisfied: charset-normalizer<4,>=2 in c:\users\owrak\appdata\roaming\python\python311\site-packages (from requests>=2.20->openai) (3.3.0)
Requirement already satisfied: idna<4,>=2.5 in c:\users\owrak\appdata\roaming\python\python311\site-packages (from requests>=2.20->openai) (3.4)
Requirement already satisfied: urllib3<3,>=1.21.1 in c:\users\owrak\appdata\roaming\python\python311\site-packages (from requests>=2.20->openai) (2.0.5)
Requirement already satisfied: certifi>=2017.4.17 in c:\users\owrak\appdata\roaming\python\python311\site-packages (from requests>=2.20->openai) (2023.7.22)
Requirement already satisfied: attrs>=17.3.0 in c:\users\owrak\appdata\roaming\python\python311\site-packages (from aiohttp->openai) (23.1.0)
Requirement already satisfied: multidict<7.0,>=4.5 in c:\users\owrak\appdata\roaming\python\python311\site-packages (from aiohttp->openai) (6.0.4)
Requirement already satisfied: async-timeout<5.0,>=4.0.0a3 in c:\users\owrak\appdata\roaming\python\python311\site-packages (from aiohttp->openai) (4.0.3)
Requirement already satisfied: yarl<2.0,>=1.0 in c:\users\owrak\appdata\roaming\python\python311\site-packages (from aiohttp->openai) (1.9.2)
Requirement already satisfied: frozenlist>=1.1.1 in c:\users\owrak\appdata\roaming\python\python311\site-packages (from aiohttp->openai) (1.4.0)
Requirement already satisfied: aiosignal>=1.1.2 in c:\users\owrak\appdata\roaming\python\python311\site-packages (from aiohttp->openai) (1.3.1)
Requirement already satisfied: colorama in c:\users\owrak\appdata\roaming\python\python311\site-packages (from tqdm->openai) (0.4.6)
C:\Users\Owrak>git clone https://github.com/WillReynolds5/AutoGPT-Social.git
'git' is not recognized as an internal or external command,
operable program or batch file.
C:\Users\Owrak>cd AutoGPT-Social
The system cannot find the path specified.
C:\Users\Owrak>
JSON Query to explore/tags/slayallday/: 404 Not Found [retrying; skip with ^C]
Traceback (most recent call last):
File "C:\Users\PeyMan\AppData\Roaming\Python\Python312\site-packages\instaloader\instaloadercontext.py", line 405, in get_json
raise QueryReturnedNotFoundException("404 Not Found")
instaloader.exceptions.QueryReturnedNotFoundException: 404 Not Found
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\P\AppData\Roaming\Python\Python312\site-packages\instaloader\instaloadercontext.py", line 405, in get_json
raise QueryReturnedNotFoundException("404 Not Found")
instaloader.exceptions.QueryReturnedNotFoundException: 404 Not Found
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\P\AppData\Roaming\Python\Python312\site-packages\instaloader\instaloadercontext.py", line 405, in get_json
raise QueryReturnedNotFoundException("404 Not Found")
instaloader.exceptions.QueryReturnedNotFoundException: 404 Not Found
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\P\AutoGPT-Social\initialize_bot.py", line 66, in
main()
File "C:\Users\P\AutoGPT-Social\initialize_bot.py", line 59, in main
hashtags = get_related_hashtags([hashtag.strip().replace('#', '') for hashtag in hashtags_input.split(',')])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\P\AutoGPT-Social\instagram_util\hashtags.py", line 11, in get_related_hashtags
posts = L.get_hashtag_posts(hashtag)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\P\AppData\Roaming\Python\Python312\site-packages\instaloader\instaloader.py", line 1204, in get_hashtag_posts
return Hashtag.from_name(self.context, hashtag).get_posts_resumable()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\P\AppData\Roaming\Python\Python312\site-packages\instaloader\structures.py", line 1662, in from_name
hashtag._obtain_metadata()
File "C:\Users\P\AppData\Roaming\Python\Python312\site-packages\instaloader\structures.py", line 1676, in _obtain_metadata
self._node = self._query({"__a": 1, "__d": "dis"})
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\P\AppData\Roaming\Python\Python312\site-packages\instaloader\structures.py", line 1671, in _query
json_response = self._context.get_json("explore/tags/{0}/".format(self.name), params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\P\AppData\Roaming\Python\Python312\site-packages\instaloader\instaloadercontext.py", line 435, in get_json
return self.get_json(path=path, params=params, host=host, session=sess, _attempt=_attempt + 1,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\P\AppData\Roaming\Python\Python312\site-packages\instaloader\instaloadercontext.py", line 435, in get_json
return self.get_json(path=path, params=params, host=host, session=sess, _attempt=_attempt + 1,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\P\AppData\Roaming\Python\Python312\site-packages\instaloader\instaloadercontext.py", line 423, in get_json
raise QueryReturnedNotFoundException(error_string) from err
instaloader.exceptions.QueryReturnedNotFoundException: JSON Query to explore/tags/slayallday/: 404 Not Found
The prompt length is too long after like 10 posts - need to only pass the first section of prompt.txt (everything before the first post). Otherwise, the bot fails after ~10 posts due to token length exceeding ~4k. Also, the posts get increasingly more expensive on each post until it fails.
get_post_metrics
function call within update_metrics
seems to be returning this error message. Runtime continues, but would be nice to clean this up if possible by catching the right exceptions in get_post_metrics()
, or more specifically, in lines 6 or 7 I suspect, something is happening in the client that is related to the type of each input?
int() argument must be a string, a bytes-like object or a real number, not 'NoneType'
Traceback (most recent call last):
File "/Users/blaine/Code/AutoGPT-Social/venv/lib/python3.11/site-packages/instagrapi/mixins/user.py", line 189, in user_info_by_username
user = self.user_info_by_username_gql(username)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/blaine/Code/AutoGPT-Social/venv/lib/python3.11/site-packages/instagrapi/mixins/user.py", line 142, in user_info_by_username_gql
return extract_user_gql(self.public_a1_request(f"/{username!s}/")["user"])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/blaine/Code/AutoGPT-Social/venv/lib/python3.11/site-packages/instagrapi/mixins/public.py", line 173, in public_a1_request
response = self.public_request(
^^^^^^^^^^^^^^^^^^^^
File "/Users/blaine/Code/AutoGPT-Social/venv/lib/python3.11/site-packages/instagrapi/mixins/public.py", line 72, in public_request
return self._send_public_request(url, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/blaine/Code/AutoGPT-Social/venv/lib/python3.11/site-packages/instagrapi/mixins/public.py", line 106, in _send_public_request
expected_length = int(response.headers.get("Content-Length"))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: int() argument must be a string, a bytes-like object or a real number, not 'NoneType'
Hello,
I run initialize_bot.py
with <api_key>
and instagram acount about and enter <acount_summary>
and hashtag and have error in this part:
JSON Query to explore/tags/design/: 404 Not Found [retrying; skip with ^C]
JSON Query to explore/tags/design/: 404 Not Found [retrying; skip with ^C]
Traceback (most recent call last):
File "/home/taha/gpt/lib/python3.11/site-packages/instaloader/instaloadercontext.py", line 405, in get_json
raise QueryReturnedNotFoundException("404 Not Found")
instaloader.exceptions.QueryReturnedNotFoundException: 404 Not Found
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/taha/gpt/lib/python3.11/site-packages/instaloader/instaloadercontext.py", line 405, in get_json
raise QueryReturnedNotFoundException("404 Not Found")
instaloader.exceptions.QueryReturnedNotFoundException: 404 Not Found
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/taha/gpt/lib/python3.11/site-packages/instaloader/instaloadercontext.py", line 405, in get_json
raise QueryReturnedNotFoundException("404 Not Found")
instaloader.exceptions.QueryReturnedNotFoundException: 404 Not Found
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/taha/gpt/AutoGPT-Social/initialize_bot.py", line 66, in <module>
main()
File "/home/taha/gpt/AutoGPT-Social/initialize_bot.py", line 59, in main
hashtags = get_related_hashtags([hashtag.strip().replace('#', '') for hashtag in hashtags_input.split(',')])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/taha/gpt/AutoGPT-Social/instagram_util/hashtags.py", line 11, in get_related_hashtags
posts = L.get_hashtag_posts(hashtag)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/taha/gpt/lib/python3.11/site-packages/instaloader/instaloader.py", line 1204, in get_hashtag_posts
return Hashtag.from_name(self.context, hashtag).get_posts_resumable()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/taha/gpt/lib/python3.11/site-packages/instaloader/structures.py", line 1662, in from_name
hashtag._obtain_metadata()
File "/home/taha/gpt/lib/python3.11/site-packages/instaloader/structures.py", line 1676, in _obtain_metadata
self._node = self._query({"__a": 1, "__d": "dis"})
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/taha/gpt/lib/python3.11/site-packages/instaloader/structures.py", line 1671, in _query
json_response = self._context.get_json("explore/tags/{0}/".format(self.name), params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/taha/gpt/lib/python3.11/site-packages/instaloader/instaloadercontext.py", line 435, in get_json
return self.get_json(path=path, params=params, host=host, session=sess, _attempt=_attempt + 1,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/taha/gpt/lib/python3.11/site-packages/instaloader/instaloadercontext.py", line 435, in get_json
return self.get_json(path=path, params=params, host=host, session=sess, _attempt=_attempt + 1,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/taha/gpt/lib/python3.11/site-packages/instaloader/instaloadercontext.py", line 423, in get_json
raise QueryReturnedNotFoundException(error_string) from err
instaloader.exceptions.QueryReturnedNotFoundException: JSON Query to explore/tags/design/: 404 Not Found
In your readme, you mention specific libraries to include via pip, but the versions have some conflicts that are leading to errors.
I have tuned some of the versions for these and came up with the following requirements.txt:
aiohttp==3.8.4 aiosignal==1.3.1 async-timeout==4.0.2 attrs==23.1.0 certifi==2022.12.7 charset-normalizer==3.1.0 frozenlist==1.3.3 idna==3.4 instagrapi==1.16.1 instaloader==4.9.6 multidict==6.0.4 openai==0.27.6 Pillow==9.5.0 pycryptodomex==3.9.9 pydantic==1.8.2 PySocks==1.7.1 requests==2.30.0 tqdm==4.65.0 typing_extensions==4.5.0 urllib3==2.0.2 yarl==1.9.2
Please add a requirements.txt, and replace pip install openai instagrapi instaloader Pillow
with pip install -r requirements.txt
note: requirements.txt can be generated via pip freeze > requirements.txt
. This will take all libraries in your venv and list their versions. You may need to trim down to include only the libraries in the above list with the versions that you have in your environment.
It seems like the photos already used but I checked and nothing use it.
Here is a error message.
C:\Users\ciril\Desktop\AutoGPT-Social>python start_bot.py vectus.dc 20
Posting - vectus.dc
Traceback (most recent call last):
File "C:\Users\ciril\Desktop\AutoGPT-Social\instagram_util\convert_jpg.py", line 13, in convert_to_jpg
os.remove(input_file_path)
PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: 'accounts\\vectus.dc\\queue\\modern_design.jpg'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\ciril\Desktop\AutoGPT-Social\start_bot.py", line 164, in <module>
main_job(project_name, post_count)
File "C:\Users\ciril\Desktop\AutoGPT-Social\start_bot.py", line 125, in main_job
prompt, post_content, image_path = start_post(prompt, project_name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\ciril\Desktop\AutoGPT-Social\start_bot.py", line 38, in start_post
image_path, description = get_image(project_name)
^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\ciril\Desktop\AutoGPT-Social\start_bot.py", line 54, in get_image
image_path = convert_to_jpg(os.path.join("accounts", project_name, "queue", image_fn))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\ciril\Desktop\AutoGPT-Social\instagram_util\convert_jpg.py", line 17, in convert_to_jpg
raise IOError(f"Error converting {input_file_path} to JPEG")
OSError: Error converting accounts\vectus.dc\queue\modern_design.jpg to JPEG
C:\Users\ciril\Desktop\AutoGPT-Social>
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.