File size: 2,479 Bytes
66c8843 a61ba58 66c8843 a61ba58 d2f193a a61ba58 d2f193a a61ba58 d2f193a a61ba58 d2f193a a61ba58 d2f193a a61ba58 d2f193a a61ba58 d2f193a a61ba58 d2f193a a61ba58 d2f193a a61ba58 d2f193a a61ba58 d2f193a a61ba58 d2f193a ede321f d2f193a ede321f d2f193a a61ba58 d2f193a a61ba58 d2f193a a61ba58 66c8843 a61ba58 d2f193a a61ba58 d2f193a a61ba58 d2f193a a61ba58 d2f193a a61ba58 d2f193a a61ba58 d2f193a a61ba58 d2f193a a61ba58 d2f193a a61ba58 d2f193a a61ba58 d2f193a a61ba58 d2f193a a61ba58 d2f193a a61ba58 d2f193a a61ba58 d2f193a a61ba58 d2f193a a61ba58 d2f193a a61ba58 d2f193a |
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 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 |
# Comic Book Generator - Server
Backend for the Comic Book Generator, powered by Mistral AI for story generation.
## π§ Architecture
The server is built around several specialized AI generators:
### Generators
- `UniverseGenerator`: Creates the universe and initial context
- `StorySegmentGenerator`: Generates narrative segments
- `MetadataGenerator`: Handles metadata (time, location, choices)
- `ImagePromptGenerator`: Creates prompts for images
### Services
- `MistralService`: Interface with Mistral API
- `GameStateManager`: Game state management
- `AudioService`: Narration management
## π οΈ Installation
1. Prerequisites:
```bash
python 3.10+
poetry
```
2. Installation:
```bash
cd server
poetry install
```
3. Configuration:
```bash
cp .env.example .env
# Add your Mistral API key to .env
# Add your Hugging Face endpoint URL to .env
```
Required environment variables:
```env
MISTRAL_API_KEY=your_mistral_api_key
HF_API_ENDPOINT=your_huggingface_endpoint_url
```
## π Usage
### Start the Server
```bash
poetry run dev
```
### Game Testing
```bash
# Interactive mode
poetry run test-game
# Automatic mode
poetry run test-game --auto
# Automatic mode with parameters
poetry run test-game --auto --max-turns 20 --show-context
```
## π Project Structure
```
server/
βββ api/ # FastAPI routes and models
β βββ models.py # Pydantic models
β βββ routes.py # API endpoints
βββ core/ # Business logic
β βββ generators/ # AI generators
β βββ prompts/ # Prompt templates
βββ services/ # External services
βββ scripts/ # Utility scripts
```
## π Generation Workflow
1. **Initialization**
- Universe creation
- Initial context definition
- Base story generation
2. **Game Loop**
- Narrative segment generation
- Choice creation
- Metadata updates
- Image prompt generation
3. **State Management**
- Progress tracking
- Choice history
- World state
## π API Endpoints
- `POST /game/start`: Start a new game
- `POST /game/choice`: Submit a choice
- `GET /game/state`: Get current state
- `POST /game/generate-image`: Generate an image
- `POST /game/narrate`: Generate audio narration
## π§ͺ Testing
```bash
# Unit tests
poetry run pytest
# Coverage tests
poetry run pytest --cov
# Integration tests
poetry run pytest tests/integration
```
|