01-ai
/
yi-6b-chat
The Yi series models are large language models trained from scratch by developers at 01.AI.
Prediction
01-ai/yi-6b-chat:14efadfaf772f45ee74c14973007cbafab3ccac90169ec96a9fc7a804253535dIDon2vwstbuqjeqnqxhjgxnvfohuStatusSucceededSourceWebHardwareA40 (Large)Total durationCreatedby @naterawInput
- top_k
- 50
- top_p
- 0.8
- prompt
- Write a script to download the images for the top 10 posts of all time from /r/pics using the PRAW library
- temperature
- 0.3
- max_new_tokens
- 1024
- prompt_template
- <|im_start|>system You are a helpful assistant<|im_end|> <|im_start|>user {prompt}<|im_end|> <|im_start|>assistant
- repetition_penalty
- 1.2
Output
Certainly! Below is a Python script that uses the `praw` (Python Reddit API Wrapper) library to fetch the top 10 posts with images from the `/r/pics` subreddit. Please replace `API_KEY` and `SUBREDDIT` with your own API key and subdomain respectively before running this code: ```python import praw from tqdm import tqdm # For progress bars def get_top_posts(subreddit, limit=10): """Fetches the latest 'limit' number of submissions from a reddit subscription or search query. """ client = praw.Reddit('your-api-key') search_result = client.get_submissions(subreddit='YourSubredditNameHere', sort='new', limit=limit) return [submission.url for submission in search_result] if __name__ == "__main__": API_KEY = '' # Replace with your actual api key SUBREDDIT = r'/r/pics' # Replace with your actual subdomain images = [] for post in tqdm(get_top_posts(SUBREDDIT))[:10]: try: image = praw.models.linkpreview.LinkPreview(post['data']['preview']) images.append({ 'title': image.title, 'permalink': post['data']['permalink'], 'thumbnail': image.thumbnail_src, 'source': f'{image.host}{image.display_sources[0]}'}) except KeyError as e: print(f'\n{e} - Skipping Post {post["id"]}') with open('/path/to/output.json', 'w') as outfile: json.dump([{'imgUrl': img['source'], 'altText': img['title']} for img in images], outfile) ``` This script will output an array of dictionaries containing information about each image, including its source URL, title, and thumbnail preview. The file will be saved as JSON format at `/path/to/output.json`. You can adjust the `limit` parameter if you want more than ten results returned. Remember to change `YOUR_API_KEY` and `YOUR_SUBDOMAIN` to match your personal settings.Generated in
Want to make some of these yourself?
Run this model