|
"""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." |
|
}, |
|
] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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: |
|
|
|
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, |
|
"vectorizePropertyName": False, |
|
} |
|
}, |
|
"name": "game_description", |
|
}, |
|
{ |
|
"dataType": ["text"], |
|
"description": "The link", |
|
"moduleConfig": { |
|
"text2vec-openai": { |
|
"skip": True, |
|
"vectorizePropertyName": False, |
|
} |
|
}, |
|
"name": "game_quest", |
|
}, |
|
{ |
|
"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" |
|
}, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
] |
|
|
|
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", |
|
) |
|
|