Skip to main content

A simple Python library for Google Gemini with memory support.

Project description

Dracula 🧛

A simple, elegant Python library for Google Gemini with powerful features.

Installation

pip install dracula-ai

Quick Start

from dracula import Dracula
from dotenv import load_dotenv
import os

load_dotenv()

ai = Dracula(api_key=os.getenv("GEMINI_API_KEY"))
response = ai.chat("Hello, who are you?")
print(response)

Parameters

Parameter Type Default Description
api_key str required Your Google Gemini API key
model str gemini-2.0-flash Gemini model name
max_messages int 10 Maximum number of messages to remember
prompt str "You are a helpful assistant." System prompt
temperature float 1.0 Response creativity (0.0 - 2.0)
max_output_tokens int 8192 Maximum response length
stats_filepath str "dracula_stats.json" Path to save usage stats
language str "English" Language for responses

Features

💬 Text Chat

ai = Dracula(api_key="your-api-key")
response = ai.chat("What is Python?")
print(response)

🌊 Streaming

for chunk in ai.stream("Tell me a long story."):
    print(chunk, end="", flush=True)

🧠 Conversation Memory

ai.chat("My name is Ahmet.")
response = ai.chat("What is my name?")
print(response)  # It remembers! ✅

ai.clear_memory()  # Wipe memory

💾 Save & Load History

ai.save_history("conversation.json")

# Later:
ai.load_history("conversation.json")

📜 Pretty Print History

ai.print_history()

🎭 System Prompt

ai = Dracula(
    api_key="your-api-key",
    prompt="You are a pirate who answers everything dramatically."
)

🌡️ Temperature Control

ai = Dracula(api_key="your-api-key", temperature=0.2)  # Focused
ai = Dracula(api_key="your-api-key", temperature=1.8)  # Creative

🌍 Response Language

ai = Dracula(api_key="your-api-key", language="Turkish")
response = ai.chat("Hello!")
print(response)  # Merhaba! ✅

📊 Usage Stats

print(ai.get_stats())
# {
#   "total_messages": 5,
#   "total_responses": 5,
#   "total_characters_sent": 120,
#   "total_characters_received": 3400
# }

ai.reset_stats()

🔗 Chainable Methods

ai.set_prompt("You are a chef.").set_temperature(0.9).set_language("Turkish")

🧹 Context Manager

with Dracula(api_key="your-api-key") as ai:
    ai.chat("Hello!")
    ai.print_history()
# Memory and stats automatically reset here ✅

Error Handling

from dracula import ValidationException, ChatException, InvalidAPIKeyException

try:
    ai = Dracula(api_key="", temperature=5.0)
except ValidationException as e:
    print(f"Validation error: {e}")
except InvalidAPIKeyException as e:
    print(f"API key error: {e}")
except ChatException as e:
    print(f"Chat error: {e}")

Getting Your API Key

  1. Go to https://aistudio.google.com
  2. Sign in with your Google account
  3. Click "Get API Key"
  4. Copy your key and store it safely in a .env file

License

MIT License — feel free to use this in your own projects!

Author

Suleyman Ibis

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dracula_ai-0.3.6.tar.gz (7.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dracula_ai-0.3.6-py3-none-any.whl (7.3 kB view details)

Uploaded Python 3

File details

Details for the file dracula_ai-0.3.6.tar.gz.

File metadata

  • Download URL: dracula_ai-0.3.6.tar.gz
  • Upload date:
  • Size: 7.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.7

File hashes

Hashes for dracula_ai-0.3.6.tar.gz
Algorithm Hash digest
SHA256 046dc4e5aa369033e35e167f71acfe2bba83242bb5e22e6685c09ed018ab39b9
MD5 b3981d01e941d58228cda41fde4eb03a
BLAKE2b-256 5458b92049a8dcc7ecd9b9258a09bd6709b23cbaa7f0ef2a66be73657ddfb694

See more details on using hashes here.

File details

Details for the file dracula_ai-0.3.6-py3-none-any.whl.

File metadata

  • Download URL: dracula_ai-0.3.6-py3-none-any.whl
  • Upload date:
  • Size: 7.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.7

File hashes

Hashes for dracula_ai-0.3.6-py3-none-any.whl
Algorithm Hash digest
SHA256 f34c6fdd9024f17098ac82a2ddaa0e17b73f9116342b47d0644751f6bdb2d15f
MD5 e9b0f448fac52cf1122a38906cc47081
BLAKE2b-256 aa795307bf578b116dbbab2e768ef0d596d87b61313541c4a3f46782e629d795

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page