{"id":29111531,"url":"https://github.com/Hayashi-Yudai/aichat","last_synced_at":"2025-06-29T10:01:53.560Z","repository":{"id":288901551,"uuid":"944877200","full_name":"Hayashi-Yudai/aichat","owner":"Hayashi-Yudai","description":"A customizable AI chat application powered by Flet.","archived":false,"fork":false,"pushed_at":"2025-06-04T00:32:04.000Z","size":2071,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-22T18:13:58.248Z","etag":null,"topics":["claude","gemini","llm","localllm","mcp","mcp-client","openai"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Hayashi-Yudai.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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-03-08T06:21:53.000Z","updated_at":"2025-06-04T00:30:47.000Z","dependencies_parsed_at":"2025-05-06T15:47:01.694Z","dependency_job_id":null,"html_url":"https://github.com/Hayashi-Yudai/aichat","commit_stats":null,"previous_names":["hayashi-yudai/aichat"],"tags_count":21,"template":false,"template_full_name":null,"purl":"pkg:github/Hayashi-Yudai/aichat","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Hayashi-Yudai%2Faichat","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Hayashi-Yudai%2Faichat/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Hayashi-Yudai%2Faichat/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Hayashi-Yudai%2Faichat/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Hayashi-Yudai","download_url":"https://codeload.github.com/Hayashi-Yudai/aichat/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Hayashi-Yudai%2Faichat/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262574091,"owners_count":23330775,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["claude","gemini","llm","localllm","mcp","mcp-client","openai"],"created_at":"2025-06-29T10:01:26.914Z","updated_at":"2025-06-29T10:01:53.488Z","avatar_url":"https://github.com/Hayashi-Yudai.png","language":"Python","funding_links":[],"categories":["Uncategorized"],"sub_categories":["Uncategorized"],"readme":"# AIChat\n\nA customizable AI chat application powered by Flet.\n\n![](images/app_view.png)\n\n## Features\n\n*   **Supports Diverse Models**: Compatible with major LLM providers like OpenAI, Anthropic (Claude), Google (Gemini), and DeepSeek.\n*   **Local Model Support**: Run local models using the `transformers` library (e.g., Phi-4-mini) or models optimized for Apple Silicon using `mlx-lm` (e.g., Gemma 3, DeepSeek-R1).\n*   **MCP (Model Context Protocol) Ready**: Integrate with MCP servers to utilize external tools and resources.\n*   **Easy Customization**: Easily add new models and agents.\n*   **Desktop \u0026 Web**: Run as both a desktop application and a web application.\n\n## Setup\n\n1.  **Install Dependencies**:\n    ```bash\n    uv sync\n    ```\n    *   This command installs all necessary dependencies, including those for local models (`transformers`, `mlx-lm` based).\n\n2.  **Configure API Keys**:\n    Set the following environment variables according to the models you want to use. You can also manage these in a `.env` file.\n\n    ```bash\n    # Example .env file\n    OPENAI_API_KEY=\"your_openai_api_key\"\n    ANTHROPIC_API_KEY=\"your_anthropic_api_key\"\n    GEMINI_API_KEY=\"your_gemini_api_key\"\n    DEEPSEEK_API_KEY=\"your_deepseek_api_key\"\n    MISTRAL_API_KEY=\"your_mistral_api_key\" # Required if USE_MISTRAL_OCR is True\n    ```\n\n## Configuration\n\nYou can adjust various application settings directly within the `aichat/config.py` file:\n\n*   `IS_DEBUG` (bool): Enable or disable debug mode. This affects things like the database file used (`DEBUG_DB_NAME` vs `DB_NAME`).\n*   `USE_MISTRAL_OCR` (bool): Enable or disable OCR functionality using Mistral. Requires a Mistral API key configured in your environment.\n*   `DB_NAME` (str): The filename for the main application database.\n*   `DEBUG_DB_NAME` (str): The filename for the database used when `IS_DEBUG` is `True`.\n*   `USER_NAME` (str), `USER_AVATAR_COLOR` (ft.Colors): Customize the display name and avatar color for the user.\n*   `AGENT_NAME` (str), `AGENT_AVATAR_COLOR` (ft.Colors): Customize the base display name and avatar color for the AI agent. The specific model name is usually appended to this.\n*   `APP_ROLE_NAME` (str), `APP_ROLE_AVATAR_COLOR` (ft.Colors): Customize the display name and avatar color for application messages (e.g., errors).\n*   `MAX_REQUEST_COUNT` (int): The maximum number of chained requests allowed during tool use interactions before stopping.\n\n## How to Run\n\nLaunch the application using the following commands:\n\n```bash\n# Run as a desktop app\nuv run flet run -d aichat/main.py\n\n# Run as a web app\nuv run flet run -w aichat/main.py\n```\n\n## Supported Models\n\nThe following models are supported by default (Model names are the Enum names defined in the Agent files):\n\n*   **OpenAI** (Requires `OPENAI_API_KEY`):\n    *   `GPT4OMINI` (`gpt-4o-mini`)\n    *   `GPT4O` (`gpt-4o`)\n    *   `O1` (`o1`)\n    *   `O3MINI` (`o3-mini`)\n    *   `GPT45PREVIEW` (`gpt-4.5-preview`)\n*   **Anthropic** (Requires `ANTHROPIC_API_KEY`):\n    *   `CALUDE35HAIKU` (`claude-3-5-haiku-latest`)\n    *   `CLAUDE37SONNET` (`claude-3-7-sonnet-latest`)\n*   **Google** (Requires `GEMINI_API_KEY`):\n    *   `GEMINI2FLASHLITE` (`gemini-2.0-flash-lite`)\n    *   `GEMINI2FLASH` (`gemini-2.0-flash`)\n    *   `GEMINI25PRO` (`gemini-2.5-pro-exp-03-25`)\n*   **DeepSeek** (Requires `DEEPSEEK_API_KEY`):\n    *   `DEEPSEEKCHAT` (`deepseek-chat`)\n    *   `DEEPSEEKREASONER` (`deepseek-reasoner`)\n*   **Local (Transformers)**:\n    *   `PHI4MINI` (`microsoft/Phi-4-mini-instruct`)\n*   **Local (MLX)** (Apple Silicon Mac):\n    *   `GEMMA3_27B_4BIT` (`mlx-community/gemma-3-27b-it-4bit`)\n    *   `DEEPSEEK_R1_32B_4BIT` (`mlx-community/DeepSeek-R1-Distill-Qwen-32B-4bit`)\n    *   `QWEN3_30B_4BIT` (`mlx-community/Qwen3-30B-A3B-4bit`)\n*   **Dummy**: A dummy model for testing purposes.\n\n## How to Add New Models\n\nTo add a new model, you primarily need to modify two files:\n\n1.  **Create an Agent**:\n    Create an Agent class for the model you want to use. Refer to existing Agent files (e.g., `aichat/agents/openai_agent.py`) for examples. Use `McpHandler` if you need to utilize MCP tools.\n\n    ```python\n    # Example: aichat/agents/your_agent.py\n    from enum import StrEnum\n    from typing import Any, AsyncGenerator\n    from .agent import Agent\n    from .mcp_handler import McpHandler # If using MCP\n    import config\n    from models.role import Role\n    from models.message import Message\n\n    class YourModel(StrEnum):\n        MODEL_A = \"model-a\"\n        MODEL_B = \"model-b\"\n\n    class YourAgent(Agent): # Inherit from Agent\n        def __init__(self, model: YourModel, mcp_handler: McpHandler | None = None): # Accept MCP handler (optional)\n            super().__init__(model, mcp_handler) # Initialize parent class\n            self.model = model\n            self.role = Role(f\"{config.AGENT_NAME} ({self.model})\", config.AGENT_AVATAR_COLOR)\n            self.streamable = True # Streaming support flag\n            # self.client = ... # Initialize API client, etc.\n\n        def _construct_request(self, message: Message) -\u003e dict[str, Any]:\n            # Convert to model-specific request format\n            # ...\n            pass\n\n        async def request(self, messages: list[Message]) -\u003e list[str]:\n            # Handle standard request\n            # ...\n            pass\n\n        async def request_streaming(self, messages: list[Message]) -\u003e AsyncGenerator[str, None]:\n            # Handle streaming request (if self.streamable is True)\n            # ...\n            pass\n    ```\n\n2.  **Register the Agent**:\n    Register the created Model and Agent in `aichat/agents/__init__.py`.\n\n    ```python\n    # aichat/agents/__init__.py\n\n    # ... (other imports)\n    from .your_agent import YourAgent, YourModel # Import your created Agent and Model\n\n    all_models = list(\n        itertools.chain.from_iterable(\n            [\n                OpenAIModel,\n                GeminiModel,\n                ClaudeModel,\n                DeepSeekModel,\n                LocalModel,\n                MLXModel,\n                YourModel, # Add your model\n                DummyModel,\n            ]\n        )\n    )\n\n    # ... (definition of _mcp_handler_instance)\n\n    def get_agent_by_model(model: StrEnum) -\u003e Agent:\n        \"\"\"Gets an agent instance based on the model enum.\"\"\"\n        if model in OpenAIModel:\n            return OpenAIAgent(model, mcp_handler=_mcp_handler_instance)\n        # ... (branches for other models)\n        elif model in YourModel: # Add your model\n            return YourAgent(model, mcp_handler=_mcp_handler_instance) # Pass handler if using MCP\n        elif model in DummyModel:\n            return DummyAgent(model)\n        else:\n            raise ValueError(f\"Invalid model: {model}\")\n\n    ```\n\n## MCP (Model Context Protocol)\n\nUtilize MCP servers to integrate with external functionalities like file operations or web browsing.\n\n*   **Configuration**: Create `aichat/agents/servers.json` based on `aichat/agents/servers.json.sample` and describe the MCP servers you want to use.\n*   **Usage**: Call `self.mcp_handler.use_tool(...)` within an Agent to use MCP server functionalities. Refer to `aichat/agents/mcp_handler.py` for details.\n\n## Contributing\n\nPlease report bugs or suggest features via Issues, and submit code improvements via Pull Requests.\n\n## License\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FHayashi-Yudai%2Faichat","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FHayashi-Yudai%2Faichat","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FHayashi-Yudai%2Faichat/lists"}