Phase 2 complete
This commit is contained in:
@@ -954,6 +954,16 @@ body {
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
|
||||
.public-message-character-header {
|
||||
background: #2d3748;
|
||||
padding: 1.5rem;
|
||||
border-radius: 8px 8px 0 0;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: flex-start;
|
||||
gap: 1rem;
|
||||
}
|
||||
|
||||
.public-msg-content {
|
||||
flex: 1;
|
||||
color: #2d3748;
|
||||
@@ -1223,6 +1233,75 @@ body {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
/* Character Profile Display */
|
||||
.character-profile-summary {
|
||||
display: flex;
|
||||
gap: 0.5rem;
|
||||
margin-top: 0.5rem;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.profile-badge {
|
||||
background: rgba(102, 126, 234, 0.2);
|
||||
color: #667eea;
|
||||
padding: 0.25rem 0.75rem;
|
||||
border-radius: 12px;
|
||||
font-size: 0.85rem;
|
||||
font-weight: 500;
|
||||
border: 1px solid rgba(102, 126, 234, 0.3);
|
||||
}
|
||||
|
||||
.character-actions {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.75rem;
|
||||
align-items: flex-end;
|
||||
}
|
||||
|
||||
.btn-export {
|
||||
background: rgba(102, 126, 234, 0.2);
|
||||
color: #fff;
|
||||
border: 1px solid rgba(102, 126, 234, 0.5);
|
||||
padding: 0.5rem 1rem;
|
||||
border-radius: 6px;
|
||||
cursor: pointer;
|
||||
font-size: 0.9rem;
|
||||
transition: all 0.2s ease;
|
||||
}
|
||||
|
||||
.btn-export:hover {
|
||||
background: rgba(102, 126, 234, 0.3);
|
||||
border-color: #667eea;
|
||||
transform: translateY(-1px);
|
||||
}
|
||||
|
||||
/* Character Creation Options */
|
||||
.character-creation-options {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 1rem;
|
||||
margin-top: 1.5rem;
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
.btn-wizard {
|
||||
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||
border: none;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.btn-wizard:hover {
|
||||
background: linear-gradient(135deg, #5568d3 0%, #65408b 100%);
|
||||
transform: translateY(-2px);
|
||||
box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
|
||||
}
|
||||
|
||||
.option-divider {
|
||||
color: #718096;
|
||||
font-size: 0.9rem;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.storyteller-content {
|
||||
grid-template-columns: 1fr;
|
||||
@@ -1235,4 +1314,12 @@ body {
|
||||
.message {
|
||||
max-width: 85%;
|
||||
}
|
||||
|
||||
.character-creation-options {
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.option-divider {
|
||||
margin: 0.5rem 0;
|
||||
}
|
||||
}
|
||||
|
||||
321
frontend/src/components/CharacterCreationWizard.css
Normal file
321
frontend/src/components/CharacterCreationWizard.css
Normal file
@@ -0,0 +1,321 @@
|
||||
.wizard-overlay {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
background-color: rgba(0, 0, 0, 0.8);
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
z-index: 1000;
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.wizard-container {
|
||||
background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
|
||||
border-radius: 15px;
|
||||
max-width: 800px;
|
||||
width: 100%;
|
||||
max-height: 90vh;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
|
||||
border: 1px solid rgba(255, 255, 255, 0.1);
|
||||
}
|
||||
|
||||
.wizard-header {
|
||||
padding: 30px;
|
||||
border-bottom: 1px solid rgba(255, 255, 255, 0.1);
|
||||
}
|
||||
|
||||
.wizard-header h2 {
|
||||
margin: 0 0 20px 0;
|
||||
color: #fff;
|
||||
font-size: 28px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.wizard-progress {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
gap: 10px;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.progress-step {
|
||||
flex: 1;
|
||||
min-width: 100px;
|
||||
padding: 10px;
|
||||
background: rgba(255, 255, 255, 0.05);
|
||||
border-radius: 8px;
|
||||
text-align: center;
|
||||
font-size: 12px;
|
||||
color: #888;
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
|
||||
.progress-step.active {
|
||||
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||
color: #fff;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.wizard-content {
|
||||
flex: 1;
|
||||
overflow-y: auto;
|
||||
padding: 30px;
|
||||
}
|
||||
|
||||
.wizard-step {
|
||||
animation: fadeIn 0.3s ease;
|
||||
}
|
||||
|
||||
@keyframes fadeIn {
|
||||
from { opacity: 0; transform: translateY(10px); }
|
||||
to { opacity: 1; transform: translateY(0); }
|
||||
}
|
||||
|
||||
.wizard-step h3 {
|
||||
margin: 0 0 25px 0;
|
||||
color: #fff;
|
||||
font-size: 22px;
|
||||
}
|
||||
|
||||
.form-group {
|
||||
margin-bottom: 25px;
|
||||
}
|
||||
|
||||
.form-group label {
|
||||
display: block;
|
||||
margin-bottom: 8px;
|
||||
color: #aaa;
|
||||
font-weight: 500;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.form-group input[type="text"],
|
||||
.form-group textarea,
|
||||
.form-group select {
|
||||
width: 100%;
|
||||
padding: 12px;
|
||||
background: rgba(255, 255, 255, 0.05);
|
||||
border: 1px solid rgba(255, 255, 255, 0.1);
|
||||
border-radius: 8px;
|
||||
color: #fff;
|
||||
font-size: 14px;
|
||||
font-family: inherit;
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
|
||||
.form-group input[type="text"]:focus,
|
||||
.form-group textarea:focus,
|
||||
.form-group select:focus {
|
||||
outline: none;
|
||||
border-color: #667eea;
|
||||
background: rgba(102, 126, 234, 0.1);
|
||||
}
|
||||
|
||||
.form-group textarea {
|
||||
resize: vertical;
|
||||
min-height: 80px;
|
||||
}
|
||||
|
||||
.selection-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
|
||||
gap: 15px;
|
||||
margin-top: 15px;
|
||||
}
|
||||
|
||||
.selection-card {
|
||||
padding: 20px;
|
||||
background: rgba(255, 255, 255, 0.05);
|
||||
border: 2px solid rgba(255, 255, 255, 0.1);
|
||||
border-radius: 10px;
|
||||
cursor: pointer;
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
|
||||
.selection-card:hover {
|
||||
background: rgba(255, 255, 255, 0.08);
|
||||
border-color: rgba(102, 126, 234, 0.5);
|
||||
transform: translateY(-2px);
|
||||
}
|
||||
|
||||
.selection-card.selected {
|
||||
background: linear-gradient(135deg, rgba(102, 126, 234, 0.2) 0%, rgba(118, 75, 162, 0.2) 100%);
|
||||
border-color: #667eea;
|
||||
box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
|
||||
}
|
||||
|
||||
.selection-name {
|
||||
font-size: 16px;
|
||||
font-weight: bold;
|
||||
color: #fff;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.selection-desc {
|
||||
font-size: 13px;
|
||||
color: #aaa;
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
.import-section {
|
||||
margin-top: 30px;
|
||||
padding: 20px;
|
||||
background: rgba(102, 126, 234, 0.1);
|
||||
border: 1px dashed rgba(102, 126, 234, 0.3);
|
||||
border-radius: 10px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.import-hint {
|
||||
margin: 0 0 10px 0;
|
||||
color: #aaa;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.btn-import {
|
||||
display: inline-block;
|
||||
padding: 10px 20px;
|
||||
background: rgba(102, 126, 234, 0.2);
|
||||
border: 1px solid #667eea;
|
||||
border-radius: 8px;
|
||||
color: #fff;
|
||||
cursor: pointer;
|
||||
transition: all 0.3s ease;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.btn-import:hover {
|
||||
background: rgba(102, 126, 234, 0.3);
|
||||
transform: translateY(-1px);
|
||||
}
|
||||
|
||||
.model-select-large {
|
||||
padding: 15px !important;
|
||||
font-size: 15px !important;
|
||||
}
|
||||
|
||||
.model-hint {
|
||||
margin-top: 10px;
|
||||
font-size: 13px;
|
||||
color: #aaa;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.character-preview {
|
||||
background: rgba(255, 255, 255, 0.03);
|
||||
border-radius: 10px;
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.preview-section {
|
||||
margin-bottom: 20px;
|
||||
padding-bottom: 20px;
|
||||
border-bottom: 1px solid rgba(255, 255, 255, 0.1);
|
||||
}
|
||||
|
||||
.preview-section:last-child {
|
||||
border-bottom: none;
|
||||
margin-bottom: 0;
|
||||
padding-bottom: 0;
|
||||
}
|
||||
|
||||
.preview-section h4 {
|
||||
margin: 0 0 10px 0;
|
||||
color: #667eea;
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
.preview-section p {
|
||||
margin: 5px 0;
|
||||
color: #ccc;
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
.preview-section strong {
|
||||
color: #fff;
|
||||
margin-right: 5px;
|
||||
}
|
||||
|
||||
.preview-summary {
|
||||
margin-top: 20px;
|
||||
padding: 20px;
|
||||
background: linear-gradient(135deg, rgba(102, 126, 234, 0.2) 0%, rgba(118, 75, 162, 0.2) 100%);
|
||||
border-radius: 10px;
|
||||
border: 1px solid rgba(102, 126, 234, 0.3);
|
||||
}
|
||||
|
||||
.preview-summary h4 {
|
||||
margin: 0 0 10px 0;
|
||||
color: #fff;
|
||||
font-size: 18px;
|
||||
}
|
||||
|
||||
.summary-text {
|
||||
font-size: 16px;
|
||||
color: #fff;
|
||||
line-height: 1.6;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.wizard-footer {
|
||||
padding: 20px 30px;
|
||||
border-top: 1px solid rgba(255, 255, 255, 0.1);
|
||||
}
|
||||
|
||||
.wizard-actions {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.wizard-navigation {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.wizard-loading {
|
||||
padding: 50px;
|
||||
text-align: center;
|
||||
color: #aaa;
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
/* Responsive */
|
||||
@media (max-width: 768px) {
|
||||
.wizard-container {
|
||||
max-width: 100%;
|
||||
max-height: 100vh;
|
||||
border-radius: 0;
|
||||
}
|
||||
|
||||
.wizard-progress {
|
||||
gap: 5px;
|
||||
}
|
||||
|
||||
.progress-step {
|
||||
min-width: 60px;
|
||||
padding: 8px 5px;
|
||||
font-size: 10px;
|
||||
}
|
||||
|
||||
.selection-grid {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.wizard-content {
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.wizard-header {
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.wizard-header h2 {
|
||||
font-size: 22px;
|
||||
}
|
||||
}
|
||||
389
frontend/src/components/CharacterCreationWizard.js
Normal file
389
frontend/src/components/CharacterCreationWizard.js
Normal file
@@ -0,0 +1,389 @@
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import './CharacterCreationWizard.css';
|
||||
|
||||
const API_URL = 'http://localhost:8000';
|
||||
|
||||
function CharacterCreationWizard({ sessionId, onCharacterCreated, onCancel }) {
|
||||
const [step, setStep] = useState(1);
|
||||
const [profileOptions, setProfileOptions] = useState(null);
|
||||
const [availableModels, setAvailableModels] = useState({ openai: [], openrouter: [] });
|
||||
|
||||
// Character data
|
||||
const [characterData, setCharacterData] = useState({
|
||||
name: '',
|
||||
description: '',
|
||||
personality: '',
|
||||
llm_model: 'gpt-3.5-turbo',
|
||||
profile: {
|
||||
gender: 'Male',
|
||||
race: 'Human',
|
||||
character_class: 'Warrior',
|
||||
personality_type: 'Friendly',
|
||||
background: '',
|
||||
avatar_data: null
|
||||
}
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
// Fetch profile options
|
||||
fetch(`${API_URL}/profile/options`)
|
||||
.then(res => res.json())
|
||||
.then(data => setProfileOptions(data))
|
||||
.catch(err => console.error('Error fetching profile options:', err));
|
||||
|
||||
// Fetch available models
|
||||
fetch(`${API_URL}/models`)
|
||||
.then(res => res.json())
|
||||
.then(data => {
|
||||
setAvailableModels(data);
|
||||
if (data.openai.length > 0) {
|
||||
updateCharacterData('llm_model', data.openai[0].id);
|
||||
} else if (data.openrouter.length > 0) {
|
||||
updateCharacterData('llm_model', data.openrouter[0].id);
|
||||
}
|
||||
})
|
||||
.catch(err => console.error('Error fetching models:', err));
|
||||
}, []);
|
||||
|
||||
const updateCharacterData = (field, value) => {
|
||||
setCharacterData(prev => ({ ...prev, [field]: value }));
|
||||
};
|
||||
|
||||
const updateProfile = (field, value) => {
|
||||
setCharacterData(prev => ({
|
||||
...prev,
|
||||
profile: { ...prev.profile, [field]: value }
|
||||
}));
|
||||
};
|
||||
|
||||
const handleNext = () => {
|
||||
if (step === 1 && !characterData.name.trim()) {
|
||||
alert('Please enter a character name');
|
||||
return;
|
||||
}
|
||||
if (step === 2 && !characterData.description.trim()) {
|
||||
alert('Please enter a character description');
|
||||
return;
|
||||
}
|
||||
setStep(step + 1);
|
||||
};
|
||||
|
||||
const handleBack = () => {
|
||||
setStep(step - 1);
|
||||
};
|
||||
|
||||
const handleCreate = async () => {
|
||||
try {
|
||||
const response = await fetch(`${API_URL}/sessions/${sessionId}/characters/`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify(characterData),
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error('Failed to create character');
|
||||
}
|
||||
|
||||
const character = await response.json();
|
||||
onCharacterCreated(character);
|
||||
} catch (error) {
|
||||
console.error('Error creating character:', error);
|
||||
alert('Failed to create character: ' + error.message);
|
||||
}
|
||||
};
|
||||
|
||||
const handleImport = async (event) => {
|
||||
const file = event.target.files[0];
|
||||
if (!file) return;
|
||||
|
||||
try {
|
||||
const text = await file.text();
|
||||
const importedData = JSON.parse(text);
|
||||
|
||||
// Extract character data
|
||||
const charData = importedData.character || importedData;
|
||||
|
||||
// Update form with imported data
|
||||
setCharacterData({
|
||||
name: charData.name || '',
|
||||
description: charData.description || '',
|
||||
personality: charData.personality || '',
|
||||
llm_model: charData.llm_model || 'gpt-3.5-turbo',
|
||||
profile: charData.profile || characterData.profile
|
||||
});
|
||||
|
||||
setStep(1); // Go to first step to review
|
||||
alert('Character imported! Review and modify as needed.');
|
||||
} catch (error) {
|
||||
console.error('Error importing character:', error);
|
||||
alert('Failed to import character. Please check the file format.');
|
||||
}
|
||||
};
|
||||
|
||||
if (!profileOptions) {
|
||||
return <div className="wizard-loading">Loading character creation wizard...</div>;
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="wizard-overlay">
|
||||
<div className="wizard-container">
|
||||
<div className="wizard-header">
|
||||
<h2>Create Your Character</h2>
|
||||
<div className="wizard-progress">
|
||||
<div className={`progress-step ${step >= 1 ? 'active' : ''}`}>1. Basic Info</div>
|
||||
<div className={`progress-step ${step >= 2 ? 'active' : ''}`}>2. Description</div>
|
||||
<div className={`progress-step ${step >= 3 ? 'active' : ''}`}>3. Race & Class</div>
|
||||
<div className={`progress-step ${step >= 4 ? 'active' : ''}`}>4. Personality</div>
|
||||
<div className={`progress-step ${step >= 5 ? 'active' : ''}`}>5. AI Model</div>
|
||||
<div className={`progress-step ${step >= 6 ? 'active' : ''}`}>6. Review</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="wizard-content">
|
||||
{/* Step 1: Basic Info */}
|
||||
{step === 1 && (
|
||||
<div className="wizard-step">
|
||||
<h3>Basic Information</h3>
|
||||
<div className="form-group">
|
||||
<label>Character Name *</label>
|
||||
<input
|
||||
type="text"
|
||||
value={characterData.name}
|
||||
onChange={(e) => updateCharacterData('name', e.target.value)}
|
||||
placeholder="Enter your character's name"
|
||||
autoFocus
|
||||
/>
|
||||
</div>
|
||||
<div className="form-group">
|
||||
<label>Gender</label>
|
||||
<select
|
||||
value={characterData.profile.gender}
|
||||
onChange={(e) => updateProfile('gender', e.target.value)}
|
||||
>
|
||||
{profileOptions.genders.map(gender => (
|
||||
<option key={gender} value={gender}>{gender}</option>
|
||||
))}
|
||||
</select>
|
||||
</div>
|
||||
<div className="import-section">
|
||||
<p className="import-hint">💡 Have an existing character?</p>
|
||||
<label className="btn-import">
|
||||
📥 Import from JSON
|
||||
<input
|
||||
type="file"
|
||||
accept=".json"
|
||||
onChange={handleImport}
|
||||
style={{ display: 'none' }}
|
||||
/>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Step 2: Description */}
|
||||
{step === 2 && (
|
||||
<div className="wizard-step">
|
||||
<h3>Character Description</h3>
|
||||
<div className="form-group">
|
||||
<label>Description *</label>
|
||||
<textarea
|
||||
value={characterData.description}
|
||||
onChange={(e) => updateCharacterData('description', e.target.value)}
|
||||
placeholder="Describe your character (e.g., A brave knight seeking redemption)"
|
||||
rows="4"
|
||||
autoFocus
|
||||
/>
|
||||
</div>
|
||||
<div className="form-group">
|
||||
<label>Background Story (Optional)</label>
|
||||
<textarea
|
||||
value={characterData.profile.background}
|
||||
onChange={(e) => updateProfile('background', e.target.value)}
|
||||
placeholder="Additional background or backstory"
|
||||
rows="3"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Step 3: Race & Class */}
|
||||
{step === 3 && (
|
||||
<div className="wizard-step">
|
||||
<h3>Race & Class</h3>
|
||||
<div className="form-group">
|
||||
<label>Race</label>
|
||||
<div className="selection-grid">
|
||||
{profileOptions.races.map(race => (
|
||||
<div
|
||||
key={race}
|
||||
className={`selection-card ${characterData.profile.race === race ? 'selected' : ''}`}
|
||||
onClick={() => updateProfile('race', race)}
|
||||
>
|
||||
<div className="selection-name">{race}</div>
|
||||
<div className="selection-desc">{profileOptions.race_descriptions[race]}</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
<div className="form-group">
|
||||
<label>Class</label>
|
||||
<div className="selection-grid">
|
||||
{profileOptions.classes.map(cls => (
|
||||
<div
|
||||
key={cls}
|
||||
className={`selection-card ${characterData.profile.character_class === cls ? 'selected' : ''}`}
|
||||
onClick={() => updateProfile('character_class', cls)}
|
||||
>
|
||||
<div className="selection-name">{cls}</div>
|
||||
<div className="selection-desc">{profileOptions.class_descriptions[cls]}</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Step 4: Personality */}
|
||||
{step === 4 && (
|
||||
<div className="wizard-step">
|
||||
<h3>Personality Type</h3>
|
||||
<div className="form-group">
|
||||
<label>Choose a personality that defines your character's behavior</label>
|
||||
<div className="selection-grid">
|
||||
{profileOptions.personality_types.map(personality => (
|
||||
<div
|
||||
key={personality}
|
||||
className={`selection-card ${characterData.profile.personality_type === personality ? 'selected' : ''}`}
|
||||
onClick={() => updateProfile('personality_type', personality)}
|
||||
>
|
||||
<div className="selection-name">{personality}</div>
|
||||
<div className="selection-desc">{profileOptions.personality_descriptions[personality]}</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
<div className="form-group">
|
||||
<label>Additional Personality Traits (Optional)</label>
|
||||
<textarea
|
||||
value={characterData.personality}
|
||||
onChange={(e) => updateCharacterData('personality', e.target.value)}
|
||||
placeholder="Any additional personality traits or quirks"
|
||||
rows="3"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Step 5: AI Model */}
|
||||
{step === 5 && (
|
||||
<div className="wizard-step">
|
||||
<h3>AI Model Selection</h3>
|
||||
<div className="form-group">
|
||||
<label>Choose the AI model for this character</label>
|
||||
<select
|
||||
value={characterData.llm_model}
|
||||
onChange={(e) => updateCharacterData('llm_model', e.target.value)}
|
||||
className="model-select-large"
|
||||
>
|
||||
{availableModels.openai.length > 0 && (
|
||||
<optgroup label="OpenAI Models">
|
||||
{availableModels.openai.map(model => (
|
||||
<option key={model.id} value={model.id}>
|
||||
{model.name}
|
||||
</option>
|
||||
))}
|
||||
</optgroup>
|
||||
)}
|
||||
{availableModels.openrouter.length > 0 && (
|
||||
<optgroup label="OpenRouter Models">
|
||||
{availableModels.openrouter.map(model => (
|
||||
<option key={model.id} value={model.id}>
|
||||
{model.name} ({model.provider})
|
||||
</option>
|
||||
))}
|
||||
</optgroup>
|
||||
)}
|
||||
</select>
|
||||
<p className="model-hint">
|
||||
💡 Different models give different personalities! Try Claude for creative responses,
|
||||
GPT-4 for detailed reasoning, or Llama for faster interactions.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Step 6: Review */}
|
||||
{step === 6 && (
|
||||
<div className="wizard-step">
|
||||
<h3>Review Your Character</h3>
|
||||
<div className="character-preview">
|
||||
<div className="preview-section">
|
||||
<h4>Basic Information</h4>
|
||||
<p><strong>Name:</strong> {characterData.name}</p>
|
||||
<p><strong>Gender:</strong> {characterData.profile.gender}</p>
|
||||
<p><strong>Race:</strong> {characterData.profile.race}</p>
|
||||
<p><strong>Class:</strong> {characterData.profile.character_class}</p>
|
||||
<p><strong>Personality:</strong> {characterData.profile.personality_type}</p>
|
||||
</div>
|
||||
<div className="preview-section">
|
||||
<h4>Description</h4>
|
||||
<p>{characterData.description}</p>
|
||||
</div>
|
||||
{characterData.profile.background && (
|
||||
<div className="preview-section">
|
||||
<h4>Background</h4>
|
||||
<p>{characterData.profile.background}</p>
|
||||
</div>
|
||||
)}
|
||||
{characterData.personality && (
|
||||
<div className="preview-section">
|
||||
<h4>Additional Traits</h4>
|
||||
<p>{characterData.personality}</p>
|
||||
</div>
|
||||
)}
|
||||
<div className="preview-section">
|
||||
<h4>AI Model</h4>
|
||||
<p>{characterData.llm_model}</p>
|
||||
</div>
|
||||
<div className="preview-summary">
|
||||
<h4>Character Summary</h4>
|
||||
<p className="summary-text">
|
||||
{characterData.name} is a {characterData.profile.gender.toLowerCase()} {characterData.profile.race} {characterData.profile.character_class} with a {characterData.profile.personality_type.toLowerCase()} personality.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className="wizard-footer">
|
||||
<div className="wizard-actions">
|
||||
<button className="btn-secondary" onClick={onCancel}>
|
||||
Cancel
|
||||
</button>
|
||||
<div className="wizard-navigation">
|
||||
{step > 1 && (
|
||||
<button className="btn-secondary" onClick={handleBack}>
|
||||
← Back
|
||||
</button>
|
||||
)}
|
||||
{step < 6 ? (
|
||||
<button className="btn-primary" onClick={handleNext}>
|
||||
Next →
|
||||
</button>
|
||||
) : (
|
||||
<button className="btn-primary" onClick={handleCreate}>
|
||||
✨ Create Character
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default CharacterCreationWizard;
|
||||
@@ -16,6 +16,30 @@ function CharacterView({ sessionId, characterId }) {
|
||||
const wsRef = useRef(null);
|
||||
const messagesEndRef = useRef(null);
|
||||
|
||||
const handleExportCharacter = async () => {
|
||||
try {
|
||||
const response = await fetch(`${API_URL}/sessions/${sessionId}/characters/${characterId}/export`);
|
||||
const data = await response.json();
|
||||
|
||||
// Create download link
|
||||
const dataStr = JSON.stringify(data, null, 2);
|
||||
const dataBlob = new Blob([dataStr], { type: 'application/json' });
|
||||
const url = URL.createObjectURL(dataBlob);
|
||||
const link = document.createElement('a');
|
||||
link.href = url;
|
||||
link.download = `${characterInfo?.name || 'character'}_${new Date().toISOString().split('T')[0]}.json`;
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
document.body.removeChild(link);
|
||||
URL.revokeObjectURL(url);
|
||||
|
||||
alert('Character exported successfully!');
|
||||
} catch (error) {
|
||||
console.error('Error exporting character:', error);
|
||||
alert('Failed to export character');
|
||||
}
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
// Fetch character info
|
||||
fetch(`${API_URL}/sessions/${sessionId}/characters/${characterId}/conversation`)
|
||||
@@ -109,8 +133,18 @@ function CharacterView({ sessionId, characterId }) {
|
||||
{characterInfo?.personality && (
|
||||
<p className="character-personality">🎭 {characterInfo.personality}</p>
|
||||
)}
|
||||
{characterInfo?.profile && (
|
||||
<div className="character-profile-summary">
|
||||
<span className="profile-badge">{characterInfo.profile.race}</span>
|
||||
<span className="profile-badge">{characterInfo.profile.character_class}</span>
|
||||
<span className="profile-badge">{characterInfo.profile.personality_type}</span>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
<div className="connection-status">
|
||||
<div className="character-actions">
|
||||
<button className="btn-export" onClick={handleExportCharacter} title="Export character">
|
||||
📥 Export
|
||||
</button>
|
||||
<span className={`status-indicator ${isConnected ? 'connected' : 'disconnected'}`}>
|
||||
{isConnected ? '● Connected' : '○ Disconnected'}
|
||||
</span>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import CharacterCreationWizard from './CharacterCreationWizard';
|
||||
|
||||
const API_URL = 'http://localhost:8000';
|
||||
|
||||
@@ -10,6 +11,8 @@ function SessionSetup({ onCreateSession, onJoinSession }) {
|
||||
const [characterPersonality, setCharacterPersonality] = useState('');
|
||||
const [selectedModel, setSelectedModel] = useState('gpt-3.5-turbo');
|
||||
const [availableModels, setAvailableModels] = useState({ openai: [], openrouter: [] });
|
||||
const [showWizard, setShowWizard] = useState(false);
|
||||
const [useSimpleMode, setUseSimpleMode] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
// Fetch available models
|
||||
@@ -66,7 +69,7 @@ function SessionSetup({ onCreateSession, onJoinSession }) {
|
||||
llm_model: selectedModel,
|
||||
});
|
||||
|
||||
const charResponse = await fetch(`${API_URL}/sessions/${joinSessionId}/characters/?${params}`, {
|
||||
const charResponse = await fetch(`${API_URL}/sessions/${joinSessionId}/characters/legacy/?${params}`, {
|
||||
method: 'POST',
|
||||
});
|
||||
|
||||
@@ -78,6 +81,19 @@ function SessionSetup({ onCreateSession, onJoinSession }) {
|
||||
}
|
||||
};
|
||||
|
||||
const handleCharacterCreated = (character) => {
|
||||
setShowWizard(false);
|
||||
onJoinSession(joinSessionId, character.id);
|
||||
};
|
||||
|
||||
const openWizard = () => {
|
||||
if (!joinSessionId.trim()) {
|
||||
alert('Please enter a Session ID first');
|
||||
return;
|
||||
}
|
||||
setShowWizard(true);
|
||||
};
|
||||
|
||||
// Quick join demo session functions
|
||||
const joinDemoStoryteller = () => {
|
||||
onCreateSession("demo-session-001");
|
||||
@@ -144,6 +160,15 @@ function SessionSetup({ onCreateSession, onJoinSession }) {
|
||||
<div className="setup-section">
|
||||
<h2>Join Existing Session</h2>
|
||||
<p className="section-description">Play as a character in an ongoing game</p>
|
||||
|
||||
{showWizard && (
|
||||
<CharacterCreationWizard
|
||||
sessionId={joinSessionId}
|
||||
onCharacterCreated={handleCharacterCreated}
|
||||
onCancel={() => setShowWizard(false)}
|
||||
/>
|
||||
)}
|
||||
|
||||
<div className="input-group">
|
||||
<input
|
||||
type="text"
|
||||
@@ -202,9 +227,21 @@ function SessionSetup({ onCreateSession, onJoinSession }) {
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<button className="btn-primary" onClick={joinSession}>
|
||||
Join Session
|
||||
</button>
|
||||
<div className="character-creation-options">
|
||||
<button className="btn-primary btn-wizard" onClick={openWizard}>
|
||||
✨ Create Character (Wizard)
|
||||
</button>
|
||||
<span className="option-divider">or</span>
|
||||
<button className="btn-secondary" onClick={() => setUseSimpleMode(!useSimpleMode)}>
|
||||
{useSimpleMode ? '↑ Hide' : '↓ Quick Create'}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{useSimpleMode && (
|
||||
<button className="btn-primary" onClick={joinSession}>
|
||||
Join Session (Simple)
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user