{"id":25243147,"url":"https://github.com/macabdul9/anygen","last_synced_at":"2026-03-04T14:32:31.240Z","repository":{"id":268951129,"uuid":"905961144","full_name":"macabdul9/AnyGen","owner":"macabdul9","description":"A Unified and Minimalist Pipeline for Generating Outputs with LLMs (HuggingFace, OpenAI, Gemini).","archived":false,"fork":false,"pushed_at":"2025-01-19T20:48:49.000Z","size":26,"stargazers_count":3,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-12-22T06:34:37.143Z","etag":null,"topics":["chatgpt","gemini-api","huggingface","huggingface-transformers","language-model","large-language-models","llms","machine-learning","openai","openai-api","python","text-generation","transformers","unified-framework"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/anygen/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/macabdul9.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":"CITATION.cff","codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-12-19T21:33:10.000Z","updated_at":"2025-02-20T03:06:13.000Z","dependencies_parsed_at":"2024-12-19T23:07:50.719Z","dependency_job_id":"c948a1c9-1496-4470-b2a9-df928343a24f","html_url":"https://github.com/macabdul9/AnyGen","commit_stats":null,"previous_names":["macabdul9/anygen"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/macabdul9/AnyGen","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/macabdul9%2FAnyGen","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/macabdul9%2FAnyGen/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/macabdul9%2FAnyGen/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/macabdul9%2FAnyGen/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/macabdul9","download_url":"https://codeload.github.com/macabdul9/AnyGen/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/macabdul9%2FAnyGen/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30083762,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-04T13:22:36.021Z","status":"ssl_error","status_checked_at":"2026-03-04T13:20:45.750Z","response_time":59,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["chatgpt","gemini-api","huggingface","huggingface-transformers","language-model","large-language-models","llms","machine-learning","openai","openai-api","python","text-generation","transformers","unified-framework"],"created_at":"2025-02-12T00:45:48.361Z","updated_at":"2026-03-04T14:32:31.210Z","avatar_url":"https://github.com/macabdul9.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# AnyGen: A Unified Interface for Text Generation\n\n`AnyGen` is a minimal Python library that unifies text generation tasks using Hugging Face, OpenAI, and Gemini models. It offers a minimalistic and unified pipeline for loading models and generating outputs with ease and efficiency.\n\n## Features\n- Support for Hugging Face models\n- Support for OpenAI's GPT models\n- Support for Gemini models\n- Easy-to-use interface for text generation\n\n## Installation\n### Using `pip`\nYou can install `AnyGen` from PyPI:\n```bash\npip install -U anygen\n```\n\n### From Source\nClone the repository and install it manually:\n```bash\ngit clone https://github.com/macabdul9/AnyGen.git\ncd AnyGen\npip install .\n```\n\n### Requirements\nEnsure the following libraries are installed:\n```bash\npip install transformers google-generativeai requests openai\n```\n\n## Usage\nBelow are step-by-step instructions to generate text using each model type.\n\n### 1. Hugging Face Model\n```python\nfrom anygen import AnyGen\n\n# Initialize the generator\nmodel_name_or_path = \"meta-llama/Llama-3.2-1B-Instruct\"  # Replace with your Hugging Face model name\ndevice = \"cuda\"  # Use \"cpu\" if GPU is not available\nhf_generator = AnyGen(model_type=\"huggingface\", model_name_or_path=model_name_or_path, device=device)\n\n# Generate text\nprompt = \"Write python code for binary search\"\ngenerated_text = hf_generator.generate(prompt)\nprint(generated_text)\n```\n\n### 2. OpenAI Model\n```python\nfrom anygen import AnyGen\n\n# Initialize the generator\napi_key_fp = \"openai_keys.json\"  # Path to your OpenAI credentials file\nopenai_generator = AnyGen(model_type=\"openai\", api_key_fp=api_key_fp)\n\n# Generate text\nprompt = \"Write python code for binary search\"\ngenerated_text = openai_generator.generate(prompt)\nprint(generated_text)\n```\n\n### 3. Gemini Model\n```python\nfrom anygen import AnyGen\n\n# Initialize the generator\napi_key_fp = \"gemini_keys.json\"  # Path to your Gemini credentials file\ngemini_generator = AnyGen(model_type=\"gemini\", api_key_fp=api_key_fp)\n\n# Generate text\nprompt = \"Write python code for binary search\"\ngenerated_text = gemini_generator.generate(prompt)\nprint(generated_text)\n```\n\n### Example with Parameters\n```python\nfrom anygen import AnyGen\n\n# Initialize the generator\napi_key_fp = \"openai_keys.json\"  # Example for OpenAI\nopenai_generator = AnyGen(model_type=\"openai\", api_key_fp=api_key_fp)\n\n# Generate text with parameters\nprompt = \"Write python code for binary search\"\nparameters = {\"temperature\": 0.7, \"max_tokens\": 512}\ngenerated_text = openai_generator.generate(prompt, parameters)\nprint(generated_text)\n```\n\n## API Key File Format\nBoth OpenAI and Gemini models require an API key stored in a JSON file. Below is an example format:\n\n`openai_keys.json`:\n```json\n{\n    \"openai_model_name\": {\n        \"api_key\": \"your_openai_api_key\",\n        \"endpoint\": \"your_endpoint\"\n    }\n}\n```\nReplace `openai_model_name` with the OpenAI model name (e.g., `gpt-4o-mini`), `api_key` with your API key, and `your_endpoint` with the provided endpoint URL.\n\n`gemini_keys.json`:\n```json\n{\n    \"gemini_model_name\": {\n        \"api_key\": \"your_gemini_api_key\"\n    }\n}\n```\nReplace `gemini_model_name` with the [Gemini](https://aistudio.google.com/) model name (e.g., `gemini-2.0-flash-exp`), `api_key` with your Gemini API key.\n\n## Parameters\n- `temperature`: Controls the randomness of the output. Higher values produce more random results.\n- `max_tokens`: The maximum number of tokens to generate.\n- `top_p`: The cumulative probability of the top tokens to sample from.\n- `top_k`: The number of highest probability vocabulary tokens to keep for top-k-filtering.\n- `beam_size`: The number of beams to use for beam search.\n\n## Running Tests\nYou can run the tests using the following commands. \n1. Clone the repository:\n```bash\ngit clone git@github.com:macabdul9/AnyGen.git\ncd AnyGen\n```\n2. Install the requirements:\n```bash\npip install -r requirements.txt\n```\n3. Run the tests:\n```bash\npython -m tests.test_anygen\n```\n\n\n## Contributions\nFeel free to submit issues and/or contribute to this repository!\n\n## License\nThis project is licensed under the MIT License.\n\n\n## Cite this Work\n\nIf you use `AnyGen` in your research or work, please cite it using the following BibTeX entry:\n\n```bibtex\n@software{anygen,\n  author = {Abdul Waheed},\n  title = {AnyGen: A Unified Interface for Text Generation},\n  year = {2024},\n  publisher = {GitHub},\n  url = {https://github.com/macabdul9/AnyGen},\n  doi = {https://doi.org/10.5281/zenodo.14533072}\n}\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmacabdul9%2Fanygen","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmacabdul9%2Fanygen","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmacabdul9%2Fanygen/lists"}