Make a realistic sample dictionary of people in Python. The key should be a random…
- User
Make a realistic sample dictionary of people in Python. The key should be a random 16-character hex string, and the value should be a dictionary of:
names(a tuple),surname,gender(an enum containinggender.FEMALE,gender.MALE, andgender.OTHER), and phone number (all with the 555-01 prefix for fictitious numbers). 5 people should suffice for now. - Assistant
Here is a realistic sample dictionary in Python of 5 people according to your specifications:
from enum import Enum Gender = Enum('Gender', ['FEMALE', 'MALE', 'OTHER']) people = { 'c998939787fc3d5c': { 'names': ('Jordan',), 'surname': 'Peters', 'gender': Gender.MALE, 'phone_number': '555-0183', }, 'b747c9143ac84eb0': { 'names': ('Juniper', 'Junie'), 'surname': 'Richardson', 'gender': Gender.FEMALE, 'phone_number': '555-0118', }, '6747bdc902e73f97': { 'names': ('Mary',), 'surname': 'Windsor', 'gender': Gender.FEMALE, 'phone_number': '555-0180', }, '5e78b599993dd030': { 'names': ('Reyna',), 'surname': 'Keeble', 'gender': Gender.FEMALE, 'phone_number': '555-0193', }, '61fdbfcf69c2f76f': { 'names': ('Leonard', 'Lenny'), 'surname': 'Brown', 'gender': Gender.MALE, 'phone_number': '555-0109', }, }Bear in mind that I gave the key
surnamea type ofstr. - User
create a web server that serves this as json
- Assistant
Here is an example of a simple web server that serves the sample dictionary of people as JSON using the Flask library in Python:
from flask import Flask, jsonify from enum import Enum
app = Flask(name)
Gender = Enum('Gender', ['FEMALE', 'MALE', 'OTHER']) people = { 'c998939787fc3d5c': { 'names': ('Jordan',), 'surname': 'Peters', 'gender': Gender.MALE, 'phone_number': '555-0183', }, 'b747c9143ac84eb0': { 'names': ('Juniper', 'Junie'), 'surname': 'Richardson', 'gender': Gender.FEMALE, 'phone_number': '555-0118', }, '6747bdc902e73f97': { 'names': ('Mary',), 'surname': 'Windsor', 'gender': Gender.FEMALE, 'phone_number': '555-0180', }, '5e78b599993dd030': { 'names': ('Reyna',), 'surname': 'Keeble', 'gender': Gender.FEMALE, 'phone_number': '555-0193', }, '61fdbfcf69c2f76f': { 'names': ('Leonard', 'Lenny'), 'surname': 'Brown', 'gender': Gender.MALE, 'phone_number': '555-0109', }, }
@app.route("/") def index(): return jsonify(people)
if name == "main": app.run()
To run the server, save the code in a file with a .py extension and run it using the command python .py. You can then access the JSON data by visiting in a web browser or using a tool such as curl.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.