| """ |
| Basic Chat Example with Apertus Swiss AI |
| Simple conversation interface demonstrating core functionality |
| """ |
|
|
| import sys |
| import os |
|
|
| |
| 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: |
| |
| 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: |
| |
| 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 |
| |
| |
| 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() |
|
|