Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ericmaddox/neurollama-ai
Interactive AI Chat with Memory and Sentiment Analysis. Features text-to-speech, conversation history retention, and customizable sentiment-aware responses using Ollama 3.2 and TextBlob.
https://github.com/ericmaddox/neurollama-ai
ai artificial-intelligence artificial-intelligence-projects artificialintelligence json ollama ollama-api pyttsx3 text-to-speech textblob textblob-sentiment-analysis
Last synced: 10 days ago
JSON representation
Interactive AI Chat with Memory and Sentiment Analysis. Features text-to-speech, conversation history retention, and customizable sentiment-aware responses using Ollama 3.2 and TextBlob.
- Host: GitHub
- URL: https://github.com/ericmaddox/neurollama-ai
- Owner: ericmaddox
- License: mit
- Created: 2024-12-22T22:40:01.000Z (11 days ago)
- Default Branch: main
- Last Pushed: 2024-12-23T05:16:16.000Z (11 days ago)
- Last Synced: 2024-12-23T06:23:50.755Z (11 days ago)
- Topics: ai, artificial-intelligence, artificial-intelligence-projects, artificialintelligence, json, ollama, ollama-api, pyttsx3, text-to-speech, textblob, textblob-sentiment-analysis
- Homepage:
- Size: 380 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# NeurOllama AI
## Ollama 3.2 - AI Chat with Memories and Sentiment Analysis
[![Powered by Ollama](https://img.shields.io/badge/Powered%20by-Ollama-blue)](https://ollama.com)
![License](https://img.shields.io/badge/license-MIT-green)
![GitHub Issues](https://img.shields.io/github/issues/ericmaddox/neurollama-ai)
![GitHub Last Commit](https://img.shields.io/github/last-commit/ericmaddox/neurollama-ai)
![GitHub Forks](https://img.shields.io/github/forks/ericmaddox/neurollama-ai?style=social)
![GitHub Stars](https://img.shields.io/github/stars/ericmaddox/neurollama-ai?style=social)This Python script enables an interactive chat with an AI that adjusts its responses based on the sentiment of the user's input. It uses text-to-speech (TTS) to speak the AI's responses and maintains conversation history in a file for continuity. The conversation history is saved, allowing the AI to recall memories from previous sessions and maintain context across interactions. The AI's responses are generated using **Ollama 3.2**, and sentiment analysis is performed with **TextBlob** to gauge the emotional tone of user input, allowing the AI to respond appropriately to frustration or positivity.
## Table of Contents
- [Introduction](#introduction)
- [Features](#features)
- [Requirements](#requirements)
- [Configuration](#configuration)
- [How It Works](#how-it-works)
- [Example](#example)
- [Notes](#notes)
- [Contributing](#contributing)
- [License](#license)## Features
- **Text-to-Speech**: The AI's responses are read aloud using `pyttsx3`.
- **Conversation History**: The script keeps track of the last few exchanges for more context in responses.
- **Sentiment Analysis**: User input is analyzed for sentiment to guide the AI's tone in replies.
- **File Persistence**: Conversation history is saved to and loaded from a JSON file (`conversation_history.json`).
- **Customizable Configuration**: Configuration options like voice selection, interaction memory size, and timeout duration can be set in a `config.json` file.## Requirements
- Python 3.x
- Required Python libraries:
- `pyttsx3`
- `subprocess`
- `json`
- `textblob`You can install the necessary dependencies by running:
```bash
pip install pyttsx3 textblob
```## Configuration
The script loads configuration from a `config.json` file. If the file is not found, default settings are used. The configuration file can specify the following settings:
```json
{
"voice": "com.apple.voice.compact.en-US.Samantha",
"history_file": "conversation_history.json",
"interaction_memory": 10,
"timeout": 30
}
```- **voice**: The voice to use for text-to-speech (default: `com.apple.voice.compact.en-US.Samantha`).
- **history_file**: The file where conversation history is saved (default: `conversation_history.json`).
- **interaction_memory**: The number of past exchanges the AI remembers to use as context (default: `10`).
- **timeout**: Time in seconds to wait before considering the conversation as timed out (default: `30`).## How It Works
1. **Initialization**: The script initializes the TTS engine (`pyttsx3`) and loads the configuration and conversation history.
2. **Chat Loop**:
- The script prompts the user for input.
- It analyzes the sentiment of the input using TextBlob.
- If the sentiment is negative, the AI offers a reassuring response. If positive, the AI responds with encouragement. Otherwise, it generates a normal response using Ollama 3.2.
- The conversation history is updated and saved after every interaction.
- The AI’s response is printed to the console and spoken aloud using TTS.
3. **Exit**: The conversation can be ended by typing `exit`.## Example
Chat with AI. Type 'exit' to end the conversation.
```plaintext
You: Hello, AI!
AI: I'm glad to hear your positivity! Let's continue.
You: I'm frustrated with this project.
AI: I sense some frustration. I'm here to assist you.
You: exit
```## Notes
- **Ollama**: This script assumes you have the ollama CLI tool installed and accessible from the terminal. The AI’s responses are generated by running `ollama run llama3.2`. You can download Ollama from [here](https://ollama.com/download).
- **TextBlob**: The sentiment analysis uses TextBlob’s polarity, with values ranging from -1 (negative) to 1 (positive).## Contributing
Contributions are welcome! Please open an issue or submit a pull request.
## License
This script is open-source and has an MIT license. Feel free to use and modify it for your personal or professional projects.