Skip to content

Mariomedhat899/AiMemory

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

13 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🧠 AiMemory β€” AI Chat with Persistent Memory

.NET Groq License

A full-featured AI chat application built with C# .NET 8 and the Groq API. Features a modern dark-themed Windows Forms UI, persistent conversation history, and support for multiple AI models including Qwen, Llama 3, Mixtral, and more.

AiMemory WinForms App


✨ Features

πŸ–₯️ Windows Forms App

  • Modern dark UI β€” sleek navy/charcoal theme with blue accent colors
  • Chat bubbles β€” rounded message bubbles (blue for user, dark gray for AI)
  • Typing indicator β€” animated dots while waiting for AI response
  • Sidebar β€” quick access to new chats and conversation history
  • Settings dialog β€” configure API key and model without restarting
  • Auto-resize input β€” input box grows as you type
  • Persistent history β€” conversations saved to %AppData%\AiMemoryWinForms\
  • Keyboard shortcuts β€” Enter to send, Shift+Enter for new line

πŸ’¬ Console App

  • Color-coded output β€” cyan for user, green for AI, red for errors
  • Lightweight β€” runs in any terminal
  • Same core engine β€” shared library with the WinForms app

πŸ”§ Shared Engine

  • Persistent memory β€” conversation history saved to JSON
  • Secure by default β€” API key via environment variable (never hardcoded)
  • Multi-model support β€” switch between Groq models at runtime
  • Rate limit handling β€” automatic retry with user feedback
  • Error resilience β€” graceful handling of network/API errors

πŸš€ Quick Start

Prerequisites

1. Clone & Build

git clone https://github.com/Mariomedhat899/AiMemory.git
cd AiMemory
dotnet build

2. Set Your API Key

Windows PowerShell (permanent, user-level):

[Environment]::SetEnvironmentVariable("GROQ_API_KEY", "gsk_YOUR_KEY_HERE", "User")

⚠️ Restart your terminal/IDE after setting.

Linux / macOS (add to ~/.bashrc or ~/.zshrc):

export GROQ_API_KEY="gsk_YOUR_KEY_HERE"

Temporary (current session only):

# PowerShell
$env:GROQ_API_KEY = "gsk_YOUR_KEY_HERE"

# Linux/macOS
export GROQ_API_KEY="gsk_YOUR_KEY_HERE"

3. Run the Windows Forms App

dotnet run --project AiMemoryWinForms

4. Run the Console App

dotnet run --project MemoryManagment

5. Choose a Model

When prompted (console) or in Settings (WinForms), pick a model:

Model Speed Best For
llama-3.1-8b-instant ⚑⚑⚑ Fast chat, testing
qwen/qwen3-32b ⚑ Multilingual, coding
llama-3.3-70b-versatile ⚑ Complex reasoning
mixtral-8x7b-32768 ⚑⚑ Long context (32K)
gemma2-9b-it ⚑⚑ Lightweight tasks

Full model list: Groq Console


πŸ’¬ Usage

Windows Forms

  1. Launch the app
  2. Click βš™ Settings β†’ enter your Groq API key
  3. Type a message and press Enter or click Send
  4. Click πŸ—‘ Clear to wipe the current conversation
  5. Click βž• New Chat to start fresh

Console

--- Using qwen/qwen3-32b on Groq | Type '/exit' to quit | '/clear' to reset ---

You: Hello! What can you do?
AI: Hello! I can help with coding, writing, analysis, and more...

You: /clear
--- System: Memory wiped. ---

You: /exit
πŸ‘‹ Goodbye!

Commands

Command Action
/exit Quit the application
/clear Wipe conversation memory

πŸ“ Project Structure

AiMemory/
β”œβ”€β”€ AiMemoryManagment/              # Shared class library (.NET 8)
β”‚   β”œβ”€β”€ Classes/
β”‚   β”‚   β”œβ”€β”€ Message.cs              # Message model for JSON serialization
β”‚   β”‚   └── ChatRequest.cs          # Chat request model
β”‚   └── AiMemoryManagment.csproj
β”‚
β”œβ”€β”€ MemoryManagment/                # Console app (.NET 8)
β”‚   β”œβ”€β”€ Program.cs                  # Console chat loop & API logic
β”‚   └── MemoryManagment.csproj
β”‚
β”œβ”€β”€ AiMemoryWinForms/               # Windows Forms app (.NET 8)
β”‚   β”œβ”€β”€ MainForm.cs                 # Full chat UI with dark theme
β”‚   β”œβ”€β”€ Program.cs                  # Application entry point
β”‚   └── AiMemoryWinForms.csproj
β”‚
β”œβ”€β”€ AiMemoryManagment.slnx          # Solution file
β”œβ”€β”€ .gitignore                      # Excludes secrets, build artifacts, etc.
└── README.md                       # This file

Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   MemoryManagment   β”‚     β”‚   AiMemoryWinForms   β”‚
β”‚   (Console App)     β”‚     β”‚   (Windows Forms)    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
         β”‚                           β”‚
         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                     β”‚
         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
         β”‚   AiMemoryManagment       β”‚
         β”‚   (Shared Library)        β”‚
         β”‚   β€’ Message.cs            β”‚
         β”‚   β€’ ChatRequest.cs        β”‚
         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                     β”‚
         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
         β”‚      Groq API             β”‚
         β”‚   api.groq.com            β”‚
         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ” Security Notes

  • βœ… API key is read from environment variable (GROQ_API_KEY) β€” never hardcoded
  • βœ… chat_history.json is stored in %AppData% (not in the repo)
  • βœ… .gitignore excludes build artifacts, secrets, and local files
  • ❌ Never commit your API key or real conversation logs
  • πŸ” Regenerate keys if accidentally exposed

πŸ› οΈ Development

Add a New Model

Just type the model ID when prompted β€” no code changes needed! The app supports any model available on Groq.

Change Memory Save Location

Console app β€” edit historyPath in MemoryManagment/Program.cs:

string historyPath = "chat_history.json";

WinForms app β€” history is saved to:

%AppData%\AiMemoryWinForms\chat_history.json

Add Streaming Support

Groq supports streaming responses. Both apps can be extended to use stream: true in the request body. See Groq API Docs.

Build All Projects

dotnet build

Run Tests

dotnet test

🀝 Contributing

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

πŸ“„ License

This project is licensed under the MIT License.


πŸ™ Acknowledgments

  • Groq β€” ultra-low-latency AI inference
  • .NET β€” cross-platform development framework
  • All open-source contributors

Releases

Packages

Contributors

Languages