File size: 1,951 Bytes
b65eda7 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | """
Basic Chat Example with Apertus Swiss AI
Simple conversation interface demonstrating core functionality
"""
import sys
import os
# Add src directory to path
sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'src'))
from apertus_core import ApertusCore
def main():
"""Main chat interface"""
print("π¨π Apertus Swiss AI - Basic Chat Example")
print("=" * 50)
print("Loading model... (this may take a few minutes)")
try:
# Initialize Apertus
apertus = ApertusCore()
print(f"β
Model loaded successfully!")
print(f"π Model info: {apertus.get_model_info()['total_parameters']:,} parameters")
print("\nType 'quit' to exit, 'clear' to clear history")
print("Try different languages: German, French, Italian, English")
print("-" * 50)
while True:
# Get user input
user_input = input("\nπ You: ").strip()
if not user_input:
continue
if user_input.lower() == 'quit':
print("π Auf Wiedersehen! Au revoir! Goodbye!")
break
if user_input.lower() == 'clear':
apertus.clear_history()
print("ποΈ Conversation history cleared!")
continue
# Generate response
print("π€ Thinking...")
try:
response = apertus.chat(user_input)
print(f"π¨π Apertus: {response}")
except Exception as e:
print(f"β Error generating response: {str(e)}")
except Exception as e:
print(f"β Failed to initialize Apertus: {str(e)}")
print("Make sure you have the required dependencies installed:")
print("pip install -r requirements.txt")
if __name__ == "__main__":
main()
|