gpt-3.5-turbo-1106· OpenAI
Arena Human Preference 55K
Code in python a simple vector database
- User
Code in python a simple vector database
- Assistant
Certainly! Below is a simple implementation of a vector database in Python using a dictionary to store vectors.
class VectorDatabase: def __init__(self): self.database = {} def add_vector(self, name, vector): self.database[name] = vector def get_vector(self, name): return self.database.get(name) def delete_vector(self, name): if name in self.database: del self.database[name] else: print("Vector not found in the database") # Example usage db = VectorDatabase() db.add_vector("vector1", [1, 2, 3]) db.add_vector("vector2", [4, 5, 6]) print(db.get_vector("vector1")) # Output: [1, 2, 3] db.delete_vector("vector2") print(db.get_vector("vector2")) # Output: NoneIn this implementation, the
VectorDatabaseclass provides methods to add, get, and delete vectors in the database using the dictionaryself.database.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.