Created
March 3, 2024 20:03
-
-
Save fsndzomga/04b47bc2163a030726671f036bbb7107 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pydantic import BaseModel, Field | |
from typing import Optional | |
import dspy | |
from dspy.experimental import SyntheticDataGenerator | |
llm = dspy.OpenAI(model='gpt-3.5-turbo',api_key=openai_key) | |
dspy.settings.configure(lm=llm) | |
class RPGPlayer(BaseModel): | |
name: str = Field(..., description="The player's character name.", example="Aragon") | |
level: int = Field(..., description="The current level of the player, indicating their progression.", gt=0, example=1) | |
player_class: str = Field(..., description="The class or role of the player, such as Warrior, Mage, etc.", example="Warrior") | |
hp: int = Field(..., description="Hit Points - represents the health of the player. The player dies if this reaches 0.", gt=0, example=100) | |
mp: Optional[int] = Field(None, description="Mana Points - used for casting spells. Not applicable for all classes.", ge=0, example=30) | |
strength: int = Field(..., description="A measure of physical power. Affects damage dealt in combat.", gt=0, example=10) | |
dexterity: int = Field(..., description="A measure of agility and reflexes. Affects evasion and accuracy.", gt=0, example=10) | |
intelligence: int = Field(..., description="A measure of mental acuity. Affects magical power and mana.", gt=0, example=10) | |
wisdom: int = Field(..., description="A measure of experience and knowledge. May affect magical defense and skill learning.", gt=0, example=10) | |
class Config: | |
schema_extra = { | |
"example": { | |
"name": "Aragon", | |
"level": 5, | |
"player_class": "Warrior", | |
"hp": 150, | |
"mp": 50, | |
"strength": 14, | |
"dexterity": 12, | |
"intelligence": 8, | |
"wisdom": 10, | |
} | |
} | |
rpg_generator = SyntheticDataGenerator(schema_class=RPGPlayer) | |
RPG_players = rpg_generator.generate(sample_size=10) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment