modelsensor


Namemodelsensor JSON
Version 1.1.1 PyPI version JSON
download
home_pageNone
SummaryLet LLM sense the world - System information detection for AI models
upload_time2025-08-18 02:56:26
maintainerNone
docs_urlNone
authorNone
requires_python>=3.7
licenseMIT License Copyright (c) 2024 ModelSensor Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords system monitoring ai llm ollama system-information sensors
VCS
bugtrack_url
requirements psutil requests
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # ModelSensor 🌍

**Let LLM sense the world** - A Python library for detecting system information, location, time, and environment to enhance AI model awareness.

[![PyPI version](https://badge.fury.io/py/modelsensor.svg)](https://badge.fury.io/py/modelsensor)
[![Python 3.7+](https://img.shields.io/badge/python-3.7+-blue.svg)](https://www.python.org/downloads/)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

## 🚀 Features

- **🕒 Time Detection**: Current time, timezone, UTC time, and formatted timestamps
- **🌍 Location Information**: IP-based geolocation with country, city, coordinates
- **💻 System Information**: OS, hardware, processor, Python environment details
- **📊 Resource Monitoring**: CPU usage, memory, disk space, network statistics
- **🔧 Environment Detection**: Working directory, virtual environments, runtime context
- **🌐 Network Information**: Network interfaces, default gateway, connection details
- **📄 Multiple Output Formats**: JSON, Markdown, and summary formats
- **🔌 Easy Integration**: Perfect for Ollama and other LLM applications

## 📦 Installation

### From PyPI (Recommended)

```bash
pip install modelsensor
```

### From Source

```bash
git clone https://github.com/EasyCam/modelsensor.git
cd modelsensor
pip install -e .
```

## 🛠️ Usage

### Command Line Interface

```bash
# Basic usage - JSON output
modelsensor

# Include location information
modelsensor --location

# Markdown format
modelsensor --format markdown

# Save to file
modelsensor --output system_info.json

# Compact JSON
modelsensor --compact

# Quick summary
modelsensor --format summary
```

### Python API

```python
from modelsensor import ModelSensor

# Create sensor instance
sensor = ModelSensor()

# Collect all system information
data = sensor.collect_all_data(include_location=True)

# Get JSON output
json_output = sensor.to_json(indent=2)
print(json_output)

# Get specific information
time_info = sensor.get_time_info()
system_info = sensor.get_system_info()
resource_info = sensor.get_resource_info()
```

### With Formatters

```python
from modelsensor import ModelSensor, MarkdownFormatter, JSONFormatter

sensor = ModelSensor()
data = sensor.collect_all_data()

# Markdown output
markdown_report = MarkdownFormatter.format(data)
print(markdown_report)

# Compact JSON
compact_json = JSONFormatter.format_compact(data)
print(compact_json)

# Summary
summary = MarkdownFormatter.format_summary(data)
print(summary)
```

## 🤖 Integration with Ollama

Perfect for providing system context to your local LLM:

```python
import ollama
from modelsensor import ModelSensor

# Get system information
sensor = ModelSensor()
system_context = sensor.to_json(include_location=True, mode="full")

# Create enhanced prompt
prompt = f"""
System Context:
{system_context}

User Question: What can you tell me about my current system?
"""

# Send to Ollama
response = ollama.chat(model='qwen3:0.6b', messages=[
    {'role': 'user', 'content': prompt}
])

print(response['message']['content'])
```

## 📊 Example Output

### JSON Format
```json
{
  "sensor_info": {
    "library": "modelsensor",
    "version": "1.1.1",
    "collection_time": "2024-01-15T10:30:45.123456"
  },
  "time": {
    "current_time": "2024-01-15T10:30:45.123456",
    "utc_time": "2024-01-15T15:30:45.123456",
    "timezone": "EST",
    "weekday": "Monday",
    "formatted_time": "2024-01-15 10:30:45"
  },
  "system": {
    "system": "Darwin",
    "platform": "macOS-12.6-x86_64-i386-64bit",
    "machine": "x86_64",
    "processor": "i386",
    "python_version": "3.9.16"
  },
  "resources": {
    "cpu": {
      "usage_percent": 15.2,
      "count": 8,
      "physical_cores": 4
    },
    "memory": {
      "total_gb": 16.0,
      "used_gb": 8.5,
      "available_gb": 7.5,
      "percentage": 53.1
    }
  }
}
```

### Markdown Format
```markdown
# System Information Report
*Generated by ModelSensor at 2024-01-15T10:30:45.123456*

## 🕒 Time Information
- **Current Time**: 2024-01-15 10:30:45
- **UTC Time**: 2024-01-15T15:30:45.123456
- **Timezone**: EST
- **Day of Week**: Monday

## 💻 System Information
- **Operating System**: Darwin 21.6.0
- **Platform**: macOS-12.6-x86_64-i386-64bit
- **Machine**: x86_64
- **Python Version**: 3.9.16
```

## 🎯 Use Cases

- **🤖 AI/LLM Context**: Provide real-world awareness to language models
- **📊 System Monitoring**: Track system resources and performance
- **🔍 Environment Detection**: Identify runtime environments and configurations
- **📋 System Reporting**: Generate comprehensive system reports
- **🛠️ DevOps Tools**: System information for deployment and monitoring scripts

## 🔧 API Reference

### ModelSensor Class
- `collect_all_data(include_location=False)` - Gather all available information
- `to_json(indent=2, include_location=False, mode="brief")` - JSON string output(mode 可选 "brief" 或 "full",默认 "brief")
- `to_dict(include_location=False, mode="brief")` - Dictionary output(mode 可选 "brief" 或 "full",默认 "brief")

### Formatters

- `JSONFormatter.format(data, indent=2)` - Pretty JSON formatting
- `JSONFormatter.format_compact(data)` - Compact JSON formatting
- `MarkdownFormatter.format(data)` - Full Markdown report
- `MarkdownFormatter.format_summary(data)` - Brief summary


## Screenshots

![Use Directly](./images/use_directly.png)

![Use in Python](./images/use_in_python.png)

![Use with Ollama](./images/use_with_ollama.png)

## 🚨 Privacy Notice

- **Location data** is optional and only collected when explicitly requested
- **No data is transmitted** except for optional IP geolocation lookup
- **Environment variables** are included but can be filtered in your application
- All data collection is **local and transparent**

## 🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

1. Fork the repository
2. Create your feature branch (`git checkout -b feature/AmazingFeature`)
3. Commit your changes (`git commit -m 'Add some AmazingFeature'`)
4. Push to the branch (`git push origin feature/AmazingFeature`)
5. Open a Pull Request

## 📄 License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

## 🔗 Links

- **GitHub**: https://github.com/EasyCam/modelsensor
- **Issues**: https://github.com/EasyCam/modelsensor/issues
- **Documentation**: https://github.com/EasyCam/modelsensor#readme

## 📝 Changelog

### Version 1.1.1
- Initial release
- Core system information detection
- JSON and Markdown formatters
- Command line interface
- Location detection support
- Ollama integration examples

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "modelsensor",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": null,
    "keywords": "system, monitoring, AI, LLM, ollama, system-information, sensors",
    "author": null,
    "author_email": "Frederick <wedonotuse@outlook.com>",
    "download_url": "https://files.pythonhosted.org/packages/55/89/808e6f465be07bcab4073014c37b8944d955231b2d500e5bf0bbba2bbda3/modelsensor-1.1.1.tar.gz",
    "platform": null,
    "description": "# ModelSensor \ud83c\udf0d\r\n\r\n**Let LLM sense the world** - A Python library for detecting system information, location, time, and environment to enhance AI model awareness.\r\n\r\n[![PyPI version](https://badge.fury.io/py/modelsensor.svg)](https://badge.fury.io/py/modelsensor)\r\n[![Python 3.7+](https://img.shields.io/badge/python-3.7+-blue.svg)](https://www.python.org/downloads/)\r\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\r\n\r\n## \ud83d\ude80 Features\r\n\r\n- **\ud83d\udd52 Time Detection**: Current time, timezone, UTC time, and formatted timestamps\r\n- **\ud83c\udf0d Location Information**: IP-based geolocation with country, city, coordinates\r\n- **\ud83d\udcbb System Information**: OS, hardware, processor, Python environment details\r\n- **\ud83d\udcca Resource Monitoring**: CPU usage, memory, disk space, network statistics\r\n- **\ud83d\udd27 Environment Detection**: Working directory, virtual environments, runtime context\r\n- **\ud83c\udf10 Network Information**: Network interfaces, default gateway, connection details\r\n- **\ud83d\udcc4 Multiple Output Formats**: JSON, Markdown, and summary formats\r\n- **\ud83d\udd0c Easy Integration**: Perfect for Ollama and other LLM applications\r\n\r\n## \ud83d\udce6 Installation\r\n\r\n### From PyPI (Recommended)\r\n\r\n```bash\r\npip install modelsensor\r\n```\r\n\r\n### From Source\r\n\r\n```bash\r\ngit clone https://github.com/EasyCam/modelsensor.git\r\ncd modelsensor\r\npip install -e .\r\n```\r\n\r\n## \ud83d\udee0\ufe0f Usage\r\n\r\n### Command Line Interface\r\n\r\n```bash\r\n# Basic usage - JSON output\r\nmodelsensor\r\n\r\n# Include location information\r\nmodelsensor --location\r\n\r\n# Markdown format\r\nmodelsensor --format markdown\r\n\r\n# Save to file\r\nmodelsensor --output system_info.json\r\n\r\n# Compact JSON\r\nmodelsensor --compact\r\n\r\n# Quick summary\r\nmodelsensor --format summary\r\n```\r\n\r\n### Python API\r\n\r\n```python\r\nfrom modelsensor import ModelSensor\r\n\r\n# Create sensor instance\r\nsensor = ModelSensor()\r\n\r\n# Collect all system information\r\ndata = sensor.collect_all_data(include_location=True)\r\n\r\n# Get JSON output\r\njson_output = sensor.to_json(indent=2)\r\nprint(json_output)\r\n\r\n# Get specific information\r\ntime_info = sensor.get_time_info()\r\nsystem_info = sensor.get_system_info()\r\nresource_info = sensor.get_resource_info()\r\n```\r\n\r\n### With Formatters\r\n\r\n```python\r\nfrom modelsensor import ModelSensor, MarkdownFormatter, JSONFormatter\r\n\r\nsensor = ModelSensor()\r\ndata = sensor.collect_all_data()\r\n\r\n# Markdown output\r\nmarkdown_report = MarkdownFormatter.format(data)\r\nprint(markdown_report)\r\n\r\n# Compact JSON\r\ncompact_json = JSONFormatter.format_compact(data)\r\nprint(compact_json)\r\n\r\n# Summary\r\nsummary = MarkdownFormatter.format_summary(data)\r\nprint(summary)\r\n```\r\n\r\n## \ud83e\udd16 Integration with Ollama\r\n\r\nPerfect for providing system context to your local LLM:\r\n\r\n```python\r\nimport ollama\r\nfrom modelsensor import ModelSensor\r\n\r\n# Get system information\r\nsensor = ModelSensor()\r\nsystem_context = sensor.to_json(include_location=True, mode=\"full\")\r\n\r\n# Create enhanced prompt\r\nprompt = f\"\"\"\r\nSystem Context:\r\n{system_context}\r\n\r\nUser Question: What can you tell me about my current system?\r\n\"\"\"\r\n\r\n# Send to Ollama\r\nresponse = ollama.chat(model='qwen3:0.6b', messages=[\r\n    {'role': 'user', 'content': prompt}\r\n])\r\n\r\nprint(response['message']['content'])\r\n```\r\n\r\n## \ud83d\udcca Example Output\r\n\r\n### JSON Format\r\n```json\r\n{\r\n  \"sensor_info\": {\r\n    \"library\": \"modelsensor\",\r\n    \"version\": \"1.1.1\",\r\n    \"collection_time\": \"2024-01-15T10:30:45.123456\"\r\n  },\r\n  \"time\": {\r\n    \"current_time\": \"2024-01-15T10:30:45.123456\",\r\n    \"utc_time\": \"2024-01-15T15:30:45.123456\",\r\n    \"timezone\": \"EST\",\r\n    \"weekday\": \"Monday\",\r\n    \"formatted_time\": \"2024-01-15 10:30:45\"\r\n  },\r\n  \"system\": {\r\n    \"system\": \"Darwin\",\r\n    \"platform\": \"macOS-12.6-x86_64-i386-64bit\",\r\n    \"machine\": \"x86_64\",\r\n    \"processor\": \"i386\",\r\n    \"python_version\": \"3.9.16\"\r\n  },\r\n  \"resources\": {\r\n    \"cpu\": {\r\n      \"usage_percent\": 15.2,\r\n      \"count\": 8,\r\n      \"physical_cores\": 4\r\n    },\r\n    \"memory\": {\r\n      \"total_gb\": 16.0,\r\n      \"used_gb\": 8.5,\r\n      \"available_gb\": 7.5,\r\n      \"percentage\": 53.1\r\n    }\r\n  }\r\n}\r\n```\r\n\r\n### Markdown Format\r\n```markdown\r\n# System Information Report\r\n*Generated by ModelSensor at 2024-01-15T10:30:45.123456*\r\n\r\n## \ud83d\udd52 Time Information\r\n- **Current Time**: 2024-01-15 10:30:45\r\n- **UTC Time**: 2024-01-15T15:30:45.123456\r\n- **Timezone**: EST\r\n- **Day of Week**: Monday\r\n\r\n## \ud83d\udcbb System Information\r\n- **Operating System**: Darwin 21.6.0\r\n- **Platform**: macOS-12.6-x86_64-i386-64bit\r\n- **Machine**: x86_64\r\n- **Python Version**: 3.9.16\r\n```\r\n\r\n## \ud83c\udfaf Use Cases\r\n\r\n- **\ud83e\udd16 AI/LLM Context**: Provide real-world awareness to language models\r\n- **\ud83d\udcca System Monitoring**: Track system resources and performance\r\n- **\ud83d\udd0d Environment Detection**: Identify runtime environments and configurations\r\n- **\ud83d\udccb System Reporting**: Generate comprehensive system reports\r\n- **\ud83d\udee0\ufe0f DevOps Tools**: System information for deployment and monitoring scripts\r\n\r\n## \ud83d\udd27 API Reference\r\n\r\n### ModelSensor Class\r\n- `collect_all_data(include_location=False)` - Gather all available information\r\n- `to_json(indent=2, include_location=False, mode=\"brief\")` - JSON string output\uff08mode \u53ef\u9009 \"brief\" \u6216 \"full\"\uff0c\u9ed8\u8ba4 \"brief\"\uff09\r\n- `to_dict(include_location=False, mode=\"brief\")` - Dictionary output\uff08mode \u53ef\u9009 \"brief\" \u6216 \"full\"\uff0c\u9ed8\u8ba4 \"brief\"\uff09\r\n\r\n### Formatters\r\n\r\n- `JSONFormatter.format(data, indent=2)` - Pretty JSON formatting\r\n- `JSONFormatter.format_compact(data)` - Compact JSON formatting\r\n- `MarkdownFormatter.format(data)` - Full Markdown report\r\n- `MarkdownFormatter.format_summary(data)` - Brief summary\r\n\r\n\r\n## Screenshots\r\n\r\n![Use Directly](./images/use_directly.png)\r\n\r\n![Use in Python](./images/use_in_python.png)\r\n\r\n![Use with Ollama](./images/use_with_ollama.png)\r\n\r\n## \ud83d\udea8 Privacy Notice\r\n\r\n- **Location data** is optional and only collected when explicitly requested\r\n- **No data is transmitted** except for optional IP geolocation lookup\r\n- **Environment variables** are included but can be filtered in your application\r\n- All data collection is **local and transparent**\r\n\r\n## \ud83e\udd1d Contributing\r\n\r\nContributions are welcome! Please feel free to submit a Pull Request.\r\n\r\n1. Fork the repository\r\n2. Create your feature branch (`git checkout -b feature/AmazingFeature`)\r\n3. Commit your changes (`git commit -m 'Add some AmazingFeature'`)\r\n4. Push to the branch (`git push origin feature/AmazingFeature`)\r\n5. Open a Pull Request\r\n\r\n## \ud83d\udcc4 License\r\n\r\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\r\n\r\n## \ud83d\udd17 Links\r\n\r\n- **GitHub**: https://github.com/EasyCam/modelsensor\r\n- **Issues**: https://github.com/EasyCam/modelsensor/issues\r\n- **Documentation**: https://github.com/EasyCam/modelsensor#readme\r\n\r\n## \ud83d\udcdd Changelog\r\n\r\n### Version 1.1.1\r\n- Initial release\r\n- Core system information detection\r\n- JSON and Markdown formatters\r\n- Command line interface\r\n- Location detection support\r\n- Ollama integration examples\r\n",
    "bugtrack_url": null,
    "license": "MIT License\r\n        \r\n        Copyright (c) 2024 ModelSensor\r\n        \r\n        Permission is hereby granted, free of charge, to any person obtaining a copy\r\n        of this software and associated documentation files (the \"Software\"), to deal\r\n        in the Software without restriction, including without limitation the rights\r\n        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\n        copies of the Software, and to permit persons to whom the Software is\r\n        furnished to do so, subject to the following conditions:\r\n        \r\n        The above copyright notice and this permission notice shall be included in all\r\n        copies or substantial portions of the Software.\r\n        \r\n        THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\n        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\n        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\n        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\n        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\n        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r\n        SOFTWARE. ",
    "summary": "Let LLM sense the world - System information detection for AI models",
    "version": "1.1.1",
    "project_urls": {
        "Documentation": "https://github.com/EasyCam/modelsensor#readme",
        "Homepage": "https://github.com/EasyCam/modelsensor",
        "Issues": "https://github.com/EasyCam/modelsensor/issues",
        "Repository": "https://github.com/EasyCam/modelsensor"
    },
    "split_keywords": [
        "system",
        " monitoring",
        " ai",
        " llm",
        " ollama",
        " system-information",
        " sensors"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "eeefe58a3e5247bc6d19eccba4747fbeb1f7a93473df8c9e4f192ab89525a4e7",
                "md5": "a6620d9afaa145f69871364fcc10f1dc",
                "sha256": "4648b9b7149199e2175dc7ddfeac7fbc93903c1155102e409d39b3963a4113b0"
            },
            "downloads": -1,
            "filename": "modelsensor-1.1.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "a6620d9afaa145f69871364fcc10f1dc",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 12341,
            "upload_time": "2025-08-18T02:56:25",
            "upload_time_iso_8601": "2025-08-18T02:56:25.163682Z",
            "url": "https://files.pythonhosted.org/packages/ee/ef/e58a3e5247bc6d19eccba4747fbeb1f7a93473df8c9e4f192ab89525a4e7/modelsensor-1.1.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "5589808e6f465be07bcab4073014c37b8944d955231b2d500e5bf0bbba2bbda3",
                "md5": "5174805481d26e2fb0e5deebcfd4c681",
                "sha256": "219c1899d40fbbea97175d74d5ff97bb5cb1180d5311fc554b4c249f72cbae56"
            },
            "downloads": -1,
            "filename": "modelsensor-1.1.1.tar.gz",
            "has_sig": false,
            "md5_digest": "5174805481d26e2fb0e5deebcfd4c681",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 15338,
            "upload_time": "2025-08-18T02:56:26",
            "upload_time_iso_8601": "2025-08-18T02:56:26.632829Z",
            "url": "https://files.pythonhosted.org/packages/55/89/808e6f465be07bcab4073014c37b8944d955231b2d500e5bf0bbba2bbda3/modelsensor-1.1.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-08-18 02:56:26",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "EasyCam",
    "github_project": "modelsensor#readme",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [
        {
            "name": "psutil",
            "specs": [
                [
                    ">=",
                    "5.8.0"
                ]
            ]
        },
        {
            "name": "requests",
            "specs": [
                [
                    ">=",
                    "2.25.0"
                ]
            ]
        }
    ],
    "lcname": "modelsensor"
}
        
Elapsed time: 1.03758s