{"id":49876516,"url":"https://github.com/fresh-milkshake/chat-object","last_synced_at":"2026-05-15T12:38:37.640Z","repository":{"id":307199412,"uuid":"1028688184","full_name":"fresh-milkshake/chat-object","owner":"fresh-milkshake","description":"A simple library for creating and managing chat objects and messages for LLM applications","archived":false,"fork":false,"pushed_at":"2025-08-24T19:57:10.000Z","size":84,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2026-01-05T01:54:01.141Z","etag":null,"topics":["llm","python","small-project"],"latest_commit_sha":null,"homepage":"https://chat-object.readthedocs.io/en/latest/","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/fresh-milkshake.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-07-29T23:11:13.000Z","updated_at":"2025-08-24T19:57:14.000Z","dependencies_parsed_at":"2025-07-30T01:39:22.187Z","dependency_job_id":"db6963bf-2f71-4a64-a052-5f69906ace39","html_url":"https://github.com/fresh-milkshake/chat-object","commit_stats":null,"previous_names":["fresh-milkshake/chat-object"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/fresh-milkshake/chat-object","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fresh-milkshake%2Fchat-object","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fresh-milkshake%2Fchat-object/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fresh-milkshake%2Fchat-object/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fresh-milkshake%2Fchat-object/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fresh-milkshake","download_url":"https://codeload.github.com/fresh-milkshake/chat-object/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fresh-milkshake%2Fchat-object/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33067473,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-15T11:35:32.926Z","status":"ssl_error","status_checked_at":"2026-05-15T11:35:31.362Z","response_time":103,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: 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":["llm","python","small-project"],"created_at":"2026-05-15T12:38:36.939Z","updated_at":"2026-05-15T12:38:37.635Z","avatar_url":"https://github.com/fresh-milkshake.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://github.com/fresh-milkshake/chat-object\"\u003e\n    \u003cimg src=\"assets/logo.svg\" alt=\"chat-object logo\" width=\"180\" /\u003e\n  \u003c/a\u003e\n  \u003cbr /\u003e\n  \u003cb\u003e\u003cspan style=\"font-size:2.2em;\"\u003echat-object\u003c/span\u003e\u003c/b\u003e\n  \u003cbr /\u003e\n  \u003cem\u003eElegant, Pythonic chat/message objects for LLMs\u003c/em\u003e\n\u003c/p\u003e\n\n#\n\n[![doctest coverage](https://img.shields.io/badge/doctest-90%25_coverage-00796b)](https://gist.github.com/fresh-milkshake/48a14bcc9c753a99d0af6935eb96e056)\n[![license](https://img.shields.io/badge/license-MIT-blue)](LICENSE.txt)\n![python](https://img.shields.io/badge/python-3.10%2B-306998)\n[![version](https://img.shields.io/pypi/v/chat-object?color=white\u0026label=version)](https://pypi.org/project/chat-object/)\n[![PyPI Downloads](https://static.pepy.tech/personalized-badge/chat-object?period=total\u0026units=abbreviation\u0026left_color=grey\u0026right_color=blue\u0026left_text=PyPI%20Downloads)](https://pepy.tech/project/chat-object)\n\n\n`chat-object` is a lightweight, intuitive Python library for building, managing, and formatting chat messages for LLM (Large Language Model) applications. Effortlessly create chat histories, prompts, and message objects that work seamlessly with OpenAI, Anthropic, and other LLM APIs.\n\n\n## Features\n\n- **Simple, Pythonic API** for chat and prompt construction\n- **Automatic formatting** for OpenAI/Anthropic message schemas\n- **Convenience utilities** for rapid prototyping and development\n- **Type-safe, explicit roles** (`System`, `User`, `Assistant`)\n- **Flexible prompt composition** with natural string operations\n\n\n\n## Installation\n\nFrom PyPI:\n\n```bash\npip install chat-object\n```\n\nFrom GitHub:\n\n```bash\npip install git+https://github.com/fresh-milkshake/chat-object.git\n```\n\nOr from source:\n\n```bash\ngit clone https://github.com/fresh-milkshake/chat-object.git\ncd chat-object\npip install -e .\n```\n\n## Quick Start\n\n### Basic Chat Usage\n\nCreate a chat object and add messages to it:\n\n```python\nimport openai\nfrom chat_object import Chat, Message, Role\n\nclient = openai.OpenAI()\n\nchat = Chat(\n    Message(Role.System, \"You are a helpful assistant\"),\n    Message(Role.User, \"Hello!\")\n)\n\nresponse = client.chat.completions.create(\n    model=\"gpt-5-nano\",\n    messages=chat.as_dict()\n)\n\nprint(response.choices[0].message.content)\n```\n\n### Using the Prompt Class\n\nThe `Prompt` class automatically handles indentation and formatting:\n\n```python\nfrom chat_object import Prompt\n\n# Clean indentation automatically\nprompt = Prompt(\"\"\"\n    You are a helpful assistant.\n    Please help me with the following task:\n    \n    def example_function():\n        return \"hello world\"\n    \n    Explain what this function does.\n\"\"\")\n\n# Multiple arguments are joined with newlines\nprompt = Prompt(\n    \"You are a helpful assistant.\",\n    \"Please be concise in your responses.\",\n    \"Focus on practical solutions.\"\n)\n\n# String operations work naturally\nprompt += \"\\n\\nAdditional context here\"\n```\n\n### QOL Features for Quick Development\n\nUse convenience functions for faster development:\n\n```python\nfrom chat_object import chat, msg_user, msg_system, msg_assistant, prmt\n\n# Quick chat creation\nchat_obj = chat(\n    msg_system(\"You are a helpful assistant.\"),\n    msg_user(\"Hello!\"),\n    msg_assistant(\"Hi there! How can I help you today?\")\n)\n\n# Quick prompt creation\nprompt = prmt(\"You are a helpful assistant.\")\n\n# Convert to dict for API calls\nmessages = chat_obj.as_dict()\n```\n\n\u003e [!TIP]\n\u003e See [examples](examples) folder for more comprehensive examples.\n\n## Features\n\n- **Well-tested code**: Comprehensive test coverage with doctests throughout the codebase ([90% coverage](https://gist.github.com/fresh-milkshake/48a14bcc9c753a99d0af6935eb96e056))\n- **Type safety**: Full type hints and enum-based roles\n- **Backward compatibility**: seamless integration with existing APIs like OpenAI, Anthropic, Together, Ollama, etc.\n- **QOL features**: Quick and easy message creation with `msg_user`, `msg_assistant`, `msg_system`, `prmt`, `msgs`, `chat` (Recommended, but not required). Pretty rich example usage of qol features is in [examples/openai_use_case.py](examples/openai_use_case.py).\n\n## License\n\nThis project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffresh-milkshake%2Fchat-object","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffresh-milkshake%2Fchat-object","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffresh-milkshake%2Fchat-object/lists"}