Skip to main content

A collection of useful scripts for AI, scraping, file I/O, and automation.

Project description

🖥️ meyigi_scripts 🎉

Welcome to meyigi_scripts! This repository contains a collection of useful and versatile Python scripts designed to help you automate tasks, simplify workflows, and make your life easier. Whether you're a beginner or an experienced developer, you'll find something useful here!

PyPI version


🚀 Features

  • Useful Scripts: A variety of small, helpful scripts for automating common tasks.
  • Easy to Use: Plug-and-play functionality for simple integration into your projects.
  • Well-documented: Clear instructions and examples to get you started quickly.

💻 Installation

You can easily install meyigi_scripts via PyPI! Run the following command:

pip install meyigi-scripts

ChatGPT Response Fetcher Documentation

This script provides a function chatgpt_get_response() to interact with OpenAI's GPT models and fetch responses.

🔑 Important: API Key Setup

If you're using scripts that interact with OpenAI's ChatGPT, you must set your API key before running them. Otherwise, the chatgpt_get_response function will not work.

Set your API key using the following command:

export OPENAI_API_KEY="your_api_key_here"

Make sure to replace your_api_key_here with your actual OpenAI API key.

Usage

Function Signature

def chatgpt_get_response(promt, model="gpt-4o", role="user") -> str:

Parameters

  • promt (str): The user input prompt for the AI model.
  • model (str, optional): The model version to use. Default is gpt-4o.
  • role (str, optional): The role of the message sender (e.g., "user", "system"). Default is user.

Example Usage

from script import chatgpt_get_response

response = chatgpt_get_response("Tell me a joke.")
print(response)

Error Handling

  • Ensure that your OpenAI API key is set up in your environment.
  • If an invalid model name is provided, OpenAI may return an error.

Execution as a Script

This function is meant to be used as an importable module but can be integrated into a standalone application.

For more details, refer to the official OpenAI API Documentation.


Gemini Generate Function Documentation

This script provides a function generate() that interacts with Google Gemini AI to generate text, JSON, or HTML responses based on user prompts. It supports customization of the model's behavior using various parameters such as temperature, top_p, and max_output_tokens.

pip install google-generativeai

Environment Variables

Set your Gemini API key before running the script:

export GEMINI_API_KEY="your_api_key_here"

Usage

Function Signature

def generate(
    promt: str = "ask from user promt",
    GEMINI_API_KEY: str = None,
    return_type: Literal["text", "json", "html"] = "text",
    model: str = "gemini-2.0-flash",
    top_k: float = 40,
    max_output_tokens: int = 8192,
    temperature: float = 1,
    top_p: float = 0.95,
) -> Union[str, dict]:

Parameters

  • promt (str): The input prompt for the AI model.
  • GEMINI_API_KEY (str, optional): API key for authentication. If not provided, it attempts to retrieve from environment variables.
  • return_type (Literal["text", "json", "html"]): Specifies the format of the response.
  • model (str): The model variant to use. Default is gemini-2.0-flash.
  • top_k (float): Sampling parameter controlling token selection.
  • max_output_tokens (int): Maximum number of output tokens.
  • temperature (float): Controls randomness in output.
  • top_p (float): Nucleus sampling parameter.

Example Usage

from script import generate

response = generate(
    "Give me the capital and population of France in json format.",
    return_type="json"
)
print(response)

Error Handling

  • Raises ValueError if the API key is missing.
  • Raises ValueError if the return_type is not one of ["text", "json", "html"].
  • Raises ValueError if JSON decoding fails.

Execution as a Script

Run the script directly:

python script.py

This will execute the function with a predefined test prompt.

License

This script is provided under the MIT License.

For more details, refer to the official Google Gemini AI documentation.


Web Scraping Utility Documentation

This script provides a function get_requests() for making HTTP GET requests and parsing HTML responses using BeautifulSoup. It includes error handling for various request failures.

Function Signature

def get_requests(url: str, timeout: int = 10, headers: dict = None) -> BeautifulSoup:

Parameters

  • url (str): The target URL for the GET request.
  • timeout (int, optional): Timeout in seconds for the request. Default is 10 seconds.
  • headers (dict, optional): Optional headers for the request.

Example Usage

from script import get_requests

url = "https://example.com"
soup = get_requests(url)
print(soup.prettify())

🔑 Important: Network Access

Ensure you have a stable internet connection before running the script. If network issues occur, the script will raise an appropriate error.

Error Handling

  • Raises HTTPError if the request fails due to an HTTP issue.
  • Raises ReadTimeout if the request exceeds the timeout.
  • Raises ConnectionError for network issues.
  • Raises RequestException for general request failures.

Execution as a Script

This function is intended to be used as an importable module but can be integrated into a standalone script.

License

This script is provided under the MIT License.

For more details, refer to the official Requests Documentation and BeautifulSoup Documentation.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

meyigi_scripts-2.0.0.tar.gz (23.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

meyigi_scripts-2.0.0-py3-none-any.whl (29.8 kB view details)

Uploaded Python 3

File details

Details for the file meyigi_scripts-2.0.0.tar.gz.

File metadata

  • Download URL: meyigi_scripts-2.0.0.tar.gz
  • Upload date:
  • Size: 23.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for meyigi_scripts-2.0.0.tar.gz
Algorithm Hash digest
SHA256 3864913ede2ac1736d76bf72941179f123c484ec3f1c4a277e54845a7a847a09
MD5 d2d91b0d86b5da9dc7d83c20390f62aa
BLAKE2b-256 480307d23784a01f97d88dfda6d13bdcd4a5ff1ea15037e43e94f227f31d8f1b

See more details on using hashes here.

File details

Details for the file meyigi_scripts-2.0.0-py3-none-any.whl.

File metadata

  • Download URL: meyigi_scripts-2.0.0-py3-none-any.whl
  • Upload date:
  • Size: 29.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for meyigi_scripts-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d25606f3376969a4d67b8d8fa270dd29c5dc80fdf867fec1c6847d765f81e557
MD5 25e0d603f66e75c51b9a7502c90f7ec4
BLAKE2b-256 f86aae1544c98a52fabf54b6984d9f038c19b6a271f5dfbeb1b2a52b149af901

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page