File size: 21,407 Bytes
bb84260 |
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 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 |
"""Ingest examples into Weaviate."""
import os
from pathlib import Path
import weaviate
os.environ["OPENAI_API_KEY"] = "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"
WEAVIATE_URL = "https://tro.weaviate.network/"
client = weaviate.Client(
url=WEAVIATE_URL,
additional_headers={"X-OpenAI-Api-Key": os.environ["OPENAI_API_KEY"]},
)
client.schema.get()
schema = {
"classes": [
{
"class": "Rephrase",
"description": "Rephrased Examples",
"vectorizer": "text2vec-openai",
"moduleConfig": {
"text2vec-openai": {
"model": "ada",
"modelVersion": "002",
"type": "text",
}
},
"properties": [
{
"dataType": ["text"],
"moduleConfig": {
"text2vec-openai": {
"skip": False,
"vectorizePropertyName": False,
}
},
"name": "content",
},
{
"dataType": ["text"],
"description": "The link",
"moduleConfig": {
"text2vec-openai": {
"skip": True,
"vectorizePropertyName": False,
}
},
"name": "game_description",
},
{
"dataType": ["text"],
"description": "The link",
"moduleConfig": {
"text2vec-openai": {
"skip": True,
"vectorizePropertyName": False,
}
},
"name": "game_environment",
},
{
"dataType": ["text"],
"description": "The link",
"moduleConfig": {
"text2vec-openai": {
"skip": True,
"vectorizePropertyName": False,
}
},
"name": "chat_history",
},
],
},
]
}
client.schema.create(schema)
documents = [
{
"game_description": "A James Bond like game where a secret agent attempts to prevent a criminal syndicate from using a satellite weapon. \
There are a series of levels, in each level the player must complete a set of objectives like defeating enemies and \
rescuing hostages, or even using high-tech gadgets. There are no health-recovery items but body armour can be aquired, along with 20 different weapons.",
"chat_history":"",
"game_environment": "Based on your input, I have created a game entitled, 'The Secret Agent: Satellite Strike'. \
This game follows a secret agent as they attempt to prevent a criminal syndicate from using a satellite weapon. You will \
control the secret agent as they traverse a series of levels, accomplishing different objectives such as defeating enemies, \
rescuing hostages, and using high-tech gadgets. To challenge the player, there are no health-recovery items, but there is \
body armour and 20 different weapons to be collected. \
The main characters of your game are the secret agent, their adversaries in the criminal syndicate, and their allies.\
The enemies will be fierce and unrelenting, but the rewards of completing a successful mission will be great. As the secret agent,\
your goal is to thwart the criminal syndicate's efforts and protect the world from the satellite weapon."
},
{
"game_description":"ok, how about jiu jitsu?",
"chat_history": "The player can use Jiu Jitsu as a defensive technique against the Cyberwolves. \
This martial art form allows the player to dodge, block, and counterattack the Cyberwolves, allowing them to escape from danger and progress through the game.",\
"game_environment": " In Cyberwolves: Escape from Danger, players take on the role of a hero who must\
traverse a dangerous cyberpunk world, avoiding and fighting off Cyberwolves. They will have access to Jiu Jitsu \
as a defensive martial art, allowing them to dodge and counterattack the Cyberwolves. Along the way, they will face \
a variety of challenges, enemies, and puzzles while progressing towards the ultimate goal.\
Question: What type of rewards will the player gain by completing the game?"
},
{
"game_description": "A game set in hell where you are a fallen angel that needs to redeem herself to reach the promised land once more.\
The enemies are scattered across the 7 circles of hell and grow increasingly challenging as you try to escape. \
The enemies are warped forms of everyday creatures that inspire fear and hatred to everyday observers. But there's a twist. \
There's a creature in hell who wants you to stay and they tempt you with various sidequests that entice you to give up on your goal of reaching heaven again.",
"chat_history": "",
"game_environment": "The game title is: 'The Forsaken Redemption'. You must battle your way through the seven circles \
of hell and defeat the warped enemies in your quest to redeem yourself and reach the promised land once more.\
But beware, a mysterious creature lurks in the shadows, intent on tempting you with side quests to make you lose your way. Will you succumb to its influence or stay the course?"
},
{
"game_description": "Grandma Phyllis and Grandpa Jim are hosting a family reunion with their grandchildren when it is crashed by two bikers.\
what are some quests in this game with grandma phyllis?",
"chat_history":"What quests or challenges can the player's granddaughter, Nell, complete in the game 'Grandma Phyllis and Grandpa Jim's Family Reunion'?",
"game_environment": "In Grandma Phyllis and Grandpa Jim's Family Reunion, Nell can complete a variety of challenges that relate to the family reunion. Nell can explore the family history, interact with family members, find family heirlooms and special items, and much more. Nell can also complete tasks to help Grandma Phyllis and Grandpa Jim prepare for the reunion. She can make decorations, help plan the menu, and make sure everyone is ready for the big event. Each challenge \
completed will be rewarded with a special family heirloom, and at the end of the game, Nell will have earned enough to restore the family home"
},
{
"game_description":"add a baby",
"chat_history": "What kind of quests would involve a baby in Grandma Phyllis and Grandpa Jim's Family Reunion?",\
"game_environment": " You could have a quest where the player has to reunite the baby with their parent.\
This quest could be difficult as the baby's parent could be anywhere in the world. The player could start off \
by visiting Grandma Phyllis and Grandpa Jim, who can provide clues as to their whereabouts. The player could \
also talk to other family members to gain more information. Throughout the quest, the player can collect items that \
can help in their search for the baby's parent.\
Upon successful completion of the quest, the player is rewarded with Grandma Phyllis and Grandpa Jim's appreciation."
},
{
"game_description": "who is the enemy and give me a dangerous plot point",
"chat_history": "The enemy in Grandma Phyllis and Grandpa Jim's Family Reunion is the two bikers who crashed the family reunion. \
They threaten the safety of the family and must be stopped. A dangerous plot point could be when the bikers take the baby away,\
leaving the player to find and reunite the baby with their parent. This would add an element of suspense and danger to the game.",
"game_environment": "For Grandma Phyllis and Grandpa Jim's Family Reunion, the enemy of the game \
are the two bikers who crashed the family reunion. They threaten the safety of the family and must be stopped. \
As for a dangerous plot point, how about when the bikers take the baby away and the player must reunite the baby with\
their parent. This would add an element of suspense and urgency to the game,\
as the player is tasked with rescuing the baby before the bikers hurt them. Do you have any other ideas or suggestions for the game?"
},
{
"game_description": "For the underwater game, what game objects can we add? ",
"chat_history":"",
"game_environment": "Ancient Underwater Tablet - A collectible that can be found throughout the ancient underwater civilization and provides information and clues about the \
civilization's history and secrets. Can be examined and studied in the player's inventory, place_object('collectible', '50'). Cursed Fish \
- An enemy that inhabits the deep waters of the ancient underwater civilization. It attacks the player if they get too close. Can be defeated \
by using weapons or magic. place_object('enemy', '40')], and Underwater Creature, an NPC that the player can talk to for advice and information \
about the ancient underwater civilization, place_object('NPC', '100')]"
},
{
"game_description":"'a soccer game where the player attempts to win a match against their childhood rival , taking place in Argentina during an abnormal period of strife",
"chat_history": "",
"game_environment": "Game Title: Rivalry On The Field \
Game Genre: Sports \
Story/Emotional Motivation of Player Character: The player character is a passionate soccer player who grew up in Argentina. \
This player has a long-standing rivalry with their childhood rival, and this game will give them the chance to finally prove who's the best on the field. \
Game Objects: \
NPCs: Player Character's Childhood Rival - The opponent in the game whose competitiveness fuels the rivalry. \
Enemies: Soccer defender - An aggressive defender who will attempt to stop the player from scoring goals. \
Collectibles: Soccer Ball - A special soccer ball that the player must use in order to win the game. \
Do you have any details you'd like to add or questions about the game?"
},
{
"game_description": "does the mother love the player or the soccer rival ",
"chat_history":"The Mother collectible is a special item with a story associated with it. The player will discover \
the details of the collectible's story as they progress in the game and they will learn the answer to your question when they find the collectible.",
"game_environment": "In the game, the relationship between the Mother collectible and the player character and their childhood rival\
is unclear. Does the Mother love the player, the soccer rival, or both?\
combined The Mother collectible represents love for both the player character and their childhood soccer rival. \
The Mother provides the player a quest, which is to resolve the conflict between them\
and their rival, ultimately bringing the two closer together. The Mother collectible symbolizes the importance of love and family in the player's life"
},
{
"game_description":"'The Nightmare's Lair' is a first-person survival horror game set in a haunted mansion where the player uncovers",
"chat_history": "Human: provide game details Assistant: Title:'The Nightmare's Lair', Theme: is a first-person survival horror \
game set in a haunted mansion where the player uncovers the truth behind\
terrifying nightmares with dark and realistic art style, Artistic Style: Dark and realistic, View: first-person, Genre: Survival horror",\
"game_environment": "the player will interact with NPCs in order to progress \
through the game. Each NPC has their own unique personality and behavior, as well as an agenda that the player \
must discover in order to complete the game. Some NPCs may offer advice or assistance, while others may prove\
hostile or deceptive. The player will need to be strategic in order to navigate these relationships and work towards their ultimate goal."
},
] # all of this
# documents = [
# {
# "game_description": "a thrilling underwater game with where players discover artifacts",
# "chat_history": "Human: what is the game environment? Assistant:: Title: Shadow of the abyss,\
# Theme: ancient underwater civilization, \
# Artistic Style: Anime, View: isometric-view, Genre: Action-Adventure",\
# "game_environment": "In Shadow of the Abyss, you will encounter a variety of obstacles, enemies, \
# NPCs, and collectibles. For this underwater game, sea obstacles include ancient ruins, coral reefs, and underwater caves.\
# Enemies include sea monsters, sharks, and other aquatic creatures. NPCs include friendly merpeople, lost divers, \
# and mysterious sea creatures. Collectibles include artifacts, gems, and other hidden treasures.\
# Ancient ruins can be explored to find hidden secrets and clues, while coral reefs and underwater \
# caves can be navigated to discover new areas. Monsters and sharks can be fought off while creatures \
# and NPCs can be interacted with to gain information or items. \
# Collectibles can be gathered to power up the player’s abilities or used to craft new items."
# },
# {
# "game_description": "For the underwater game, what game objects can we add? ",
# "chat_history":"":,
# "game_environment": "Ancient Underwater Tablet - A collectible that can be found throughout the ancient underwater civilization and provides information and clues about the \
# civilization's history and secrets. Can be examined and studied in the player's inventory, place_object('collectible', '50'). Cursed Fish \
# - An enemy that inhabits the deep waters of the ancient underwater civilization. It attacks the player if they get too close. Can be defeated \
# by using weapons or magic. place_object('enemy', '40')], and Underwater Creature, an NPC that the player can talk to for advice and information \
# about the ancient underwater civilization, place_object('NPC', '100')]"
# },
# {
# "game_description":"'The Nightmare's Lair' is a first-person survival horror game set in a haunted mansion where the player uncovers",
# "chat_history": "Human: provide game details Assistant: Title:'The Nightmare's Lair', Theme: is a first-person survival horror \
# game set in a haunted mansion where the player uncovers the truth behind\
# terrifying nightmares with dark and realistic art style, Artistic Style: Dark and realistic, View: first-person, Genre: Survival horror",\
# "game_environment": "In 'The Nightmare's Lair', the player will interact with NPCs in order to progress \
# through the game. Each NPC has their own unique personality and behavior, as well as an agenda that the player \
# must discover in order to complete the game. Some NPCs may offer advice or assistance, while others may prove\
# hostile or deceptive. The player will need to be strategic in order to navigate these relationships and work towards their ultimate goal."
# },
# ] # all of this is in the {'Rephrase': chat history --weaviate.
from langchain.prompts.example_selector.semantic_similarity import \
sorted_values
for d in documents:
d["content"] = " ".join(sorted_values(d))
print(d["content"])
with client.batch as batch:
for text in documents:
# print(text)
batch.add_data_object(
text,
"Rephrase",
)
client.schema.get()
schema = {
"classes": [
{
"class": "QAs",
"description": "Rephrased Examples",
"vectorizer": "text2vec-openai",
"moduleConfig": {
"text2vec-openai": {
"model": "ada",
"modelVersion": "002",
"type": "text",
}
},
"properties": [
{
"dataType": ["text"],
"moduleConfig": {
"text2vec-openai": {
"skip": False,
"vectorizePropertyName": False,
}
},
"name": "content",
},
{
"dataType": ["text"],
"description": "The link",
"moduleConfig": {
"text2vec-openai": {
"skip": True, # can try setting to false ?
"vectorizePropertyName": False,
}
},
"name": "game_description", # question
},
{
"dataType": ["text"],
"description": "The link",
"moduleConfig": {
"text2vec-openai": {
"skip": True,
"vectorizePropertyName": False,
}
},
"name": "game_quest", # summaries
},
{
"dataType": ["text"],
"description": "The link",
"moduleConfig": {
"text2vec-openai": {
"skip": True,
"vectorizePropertyName": False,
}
},
"name": "sources",
},
],
},
]
}
client.schema.create(schema)
documents = [
{
"game_description": "a thrilling underwater game with where players discover artifacts",
"game_environment": "underwater theme",
"game_quest": ">Example:\nContent:\n---------\nThe inhabitants of an ancient underwater civilization known as 'Shadow of the Abyss' \
are in dire need of help. A mysterious force has been corrupting and consuming the artifacts that are essential to the civilization’s \
history and culture. An intrepid adventurer has been summoned to undertake a daring quest to save the artifacts.\
The player must explore the depths of 'Shadow of the Abyss' and battle against various underwater enemies, such as the \
cursed fish, as well as collect ancient underwater tablets. The player must also search for and speak to the mysterious underwater creature in order\
to gain information and advice about the ancient underwater civilization. As the player progresses on the quest, they will be met with greater and more \
difficult challenges. This includes navigating the treacherous and complicated underwater world, avoiding the deadly cursed fish, \
and finding and deciphering the ancient underwater tablets. Eventually, the player will reach the climax of the quest and battle \
against a powerful enemy in order to save the artifacts and preserve the ancient civilization.The reward for completing this quest is the \
knowledge that the artifacts have been saved, as well as access to the secrets of the ancient civilization.\
Sample character dialogue:\
Player: 'I have been summoned to save the artifacts of this ancient civilization'",
"sources": "foo.html"
},
# {
# "game_description": "'The Nightmare's Lair' is a first-person survival horror game set in a haunted mansion where the player uncovers the truth behind terrifying nightmares with dark and realistic art style",
# "game_environment": "The Nightmare's Lair', is a first-person survival horror game set in a haunted mansion where the player uncovers the truth behind\
# terrifying nightmares with dark and realistic art style', 'Dark and realistic', 'first-person', 'Survival horror'",
# "game_quest": ">Example:\nContent:\n---------\nShadow of the Abyss is an action-adventure game with a theme of uncovering secrets of an ancient underwater civilization, featuring stylized graphics, survival and exploration elements",
# "sources": "bar.html"
# },
]
from langchain.prompts.example_selector.semantic_similarity import \
sorted_values
for d in documents:
d["content"] = " ".join(sorted_values(d))
with client.batch as batch:
for text in documents:
batch.add_data_object(
text,
"QAs",
)
|