![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
story-dialogue-generator
Advanced tools
Librería para generar diálogos e historias utilizando modelos de lenguaje.
story-dialogue-generator
es una librería de Python diseñada para facilitar la generación de diálogos e historias estructuradas. Ideal para proyectos creativos, videojuegos, y aplicaciones que requieran narrativa dinámica o interactiva, esta herramienta permite integrarse con un modelo de lenguaje a través de endpoints personalizados.
Para instalar la librería, utiliza pip
:
pip install story-dialogue-generator
´´´
## **Uso Básico**
### **1. Configuración Inicial**
Agrega tus credenciales al archivo `.env` en el directorio raíz de tu proyecto:
```plaintext
LIBRARY_USERNAME=tu_usuario
LIBRARY_PASSWORD=tu_contraseña
2. Generar un Diálogo
Entrada como Parámetros
python
Copy code
from story_dialogue_generator import UserSession, DialogueService
user_session = UserSession()
story = "A hero embarks on a journey to save the kingdom."
dialogue_context = "The hero confronts the villain in an epic battle."
settings = {
"location": "castle",
"time_of_day": "night",
"number_of_scenes": 3,
"number_of_characters": 2
}
characters = [
{
"name": "Hero",
"role": "protagonist",
"attributes": [{"key": "bravery", "value": "high"}]
},
{
"name": "Villain",
"role": "antagonist",
"attributes": [{"key": "intelligence", "value": "high"}]
}
]
# Generar el diálogo
dialogue_service = DialogueService(user_session, story, dialogue_context, settings, characters)
response = dialogue_service.generate_dialogue()
print(response)
Entrada desde un Archivo JSON
Crea un archivo dialogue.json con el siguiente contenido:
json
Copy code
{
"story": "A knight defends the kingdom.",
"dialogue_context": "The knight meets a mysterious stranger.",
"settings": {
"location": "forest",
"time_of_day": "dusk",
"number_of_scenes": 2,
"number_of_characters": 2
},
"characters": [
{
"name": "Knight",
"role": "protagonist",
"attributes": [{"key": "strength", "value": "high"}]
},
{
"name": "Stranger",
"role": "ally",
"attributes": [{"key": "wisdom", "value": "high"}]
}
]
}
Luego, carga el JSON en Python:
python
Copy code
import json
from story_dialogue_generator import UserSession, DialogueService
# Crear la sesión del usuario
user_session = UserSession()
# Cargar los datos del archivo JSON
with open("dialogue.json", "r") as f:
dialogue_data = json.load(f)
# Crear y usar el servicio de diálogo
dialogue_service = DialogueService(
user_session,
dialogue_data["story"],
dialogue_data["dialogue_context"],
dialogue_data["settings"],
dialogue_data["characters"]
)
response = dialogue_service.generate_dialogue()
print(response)
3. Generar una Historia
Entrada como Parámetros
python
Copy code
from story_dialogue_generator import UserSession, StoryService
# Crear la sesión del usuario
user_session = UserSession()
# Datos para la historia
title = "The Great Adventure"
settings = {
"size": "large",
"attributes": [{"key": "theme", "value": "courage"}]
}
characters = [
{
"name": "Knight",
"attributes": [{"key": "role", "value": "protector"}]
},
{
"name": "Wizard",
"attributes": [{"key": "skill", "value": "magic"}]
}
]
# Generar la historia
story_service = StoryService(user_session, title, settings, characters)
response = story_service.generate_story()
print(response)
Entrada desde un Archivo JSON
Crea un archivo story.json con el siguiente contenido:
json
Copy code
{
"title": "The Great Adventure",
"settings": {
"size": "large",
"attributes": [{"key": "theme", "value": "courage"}]
},
"characters": [
{
"name": "Knight",
"attributes": [{"key": "role", "value": "protector"}]
},
{
"name": "Wizard",
"attributes": [{"key": "skill", "value": "magic"}]
}
]
}
Luego, carga el JSON en Python:
python
Copy code
import json
from story_dialogue_generator import UserSession, StoryService
# Crear la sesión del usuario
user_session = UserSession()
# Cargar los datos del archivo JSON
with open("story.json", "r") as f:
story_data = json.load(f)
# Crear y usar el servicio de historia
story_service = StoryService(
user_session,
story_data["title"],
story_data["settings"],
story_data["characters"]
)
response = story_service.generate_story()
print(response)
Uso de la CLI
Autenticación
Autentica al usuario configurado en el archivo .env:
bash
Copy code
story-dialogue-cli --authenticate
Generar un Diálogo
Proporciona un archivo JSON con los datos del diálogo:
bash
Copy code
story-dialogue-cli --generate-dialogue ./dialogue.json
Generar una Historia
Proporciona un archivo JSON con los datos de la historia:
bash
Copy code
story-dialogue-cli --generate-story ./story.json
Requisitos
Python 3.7 o superior
Dependencias:
requests
python-dotenv
keyring
FAQs
Librería para generar diálogos e historias
We found that story-dialogue-generator demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.