Spaces:
Runtime error
Runtime error
File size: 5,161 Bytes
af0c8b5 |
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 |
import json
region_list = {
'Auvergne-Rhône-Alpes': ['01', '03', '07', '15', '26', '38', '42', '43', '63', '69', '73', '74'],
'Bourgogne-Franche-Comté': ['21', '25', '39', '58', '70', '71', '89', '90'],
'Bretagne': ['35', '22', '56', '29'],
'Centre-Val de Loire': ['18', '28', '36', '37', '41', '45'],
'Corse': ['2A', '2B'],
'Grand Est': ['08', '10', '51', '52', '54', '55', '57', '67', '68', '88'],
'Guadeloupe': ['971'],
'Guyane': ['973'],
'Hauts-de-France': ['02', '59', '60', '62', '80'],
'Île-de-France': ['75', '77', '78', '91', '92', '93', '94', '95'],
'La Réunion': ['974'],
'Martinique': ['972'],
'Normandie': ['14', '27', '50', '61', '76'],
'Nouvelle-Aquitaine': ['16', '17', '19', '23', '24', '33', '40', '47', '64', '79', '86', '87'],
'Occitanie': ['09', '11', '12', '30', '31', '32', '34', '46', '48', '65', '66', '81', '82'],
'Pays de la Loire': ['44', '49', '53', '72', '85'],
'Provence-Alpes-Côte d\'Azur': ['04', '05', '06', '13', '83', '84'],
}
departments_list = {
'01': 'Ain',
'02': 'Aisne',
'03': 'Allier',
'04': 'Alpes-de-Haute-Provence',
'05': 'Hautes-Alpes',
'06': 'Alpes-Maritimes',
'07': 'Ardèche',
'08': 'Ardennes',
'09': 'Ariège',
'10': 'Aube',
'11': 'Aude',
'12': 'Aveyron',
'13': 'Bouches-du-Rhône',
'14': 'Calvados',
'15': 'Cantal',
'16': 'Charente',
'17': 'Charente-Maritime',
'18': 'Cher',
'19': 'Corrèze',
'2A': 'Corse-du-Sud',
'2B': 'Haute-Corse',
'21': 'Côte-d\'Or',
'22': 'Côtes-d\'Armor',
'23': 'Creuse',
'24': 'Dordogne',
'25': 'Doubs',
'26': 'Drôme',
'27': 'Eure',
'28': 'Eure-et-Loir',
'29': 'Finistère',
'30': 'Gard',
'31': 'Haute-Garonne',
'32': 'Gers',
'33': 'Gironde',
'34': 'Hérault',
'35': 'Ille-et-Vilaine',
'36': 'Indre',
'37': 'Indre-et-Loire',
'38': 'Isère',
'39': 'Jura',
'40': 'Landes',
'41': 'Loir-et-Cher',
'42': 'Loire',
'43': 'Haute-Loire',
'44': 'Loire-Atlantique',
'45': 'Loiret',
'46': 'Lot',
'47': 'Lot-et-Garonne',
'48': 'Lozère',
'49': 'Maine-et-Loire',
'50': 'Manche',
'51': 'Marne',
'52': 'Haute-Marne',
'53': 'Mayenne',
'54': 'Meurthe-et-Moselle',
'55': 'Meuse',
'56': 'Morbihan',
'57': 'Moselle',
'58': 'Nièvre',
'59': 'Nord',
'60': 'Oise',
'61': 'Orne',
'62': 'Pas-de-Calais',
'63': 'Puy-de-Dôme',
'64': 'Pyrénées-Atlantiques',
'65': 'Hautes-Pyrénées',
'66': 'Pyrénées-Orientales',
'67': 'Bas-Rhin',
'68': 'Haut-Rhin',
'69': 'Rhône',
'70': 'Haute-Saône',
'71': 'Saône-et-Loire',
'72': 'Sarthe',
'73': 'Savoie',
'74': 'Haute-Savoie',
'75': 'Paris',
'76': 'Seine-Maritime',
'77': 'Seine-et-Marne',
'78': 'Yvelines',
'79': 'Deux-Sèvres',
'80': 'Somme',
'81': 'Tarn',
'82': 'Tarn-et-Garonne',
'83': 'Var',
'84': 'Vaucluse',
'85': 'Vendée',
'86': 'Vienne',
'87': 'Haute-Vienne',
'88': 'Vosges',
'89': 'Yonne',
'90': 'Territoire de Belfort',
'91': 'Essonne',
'92': 'Hauts-de-Seine',
'93': 'Seine-Saint-Denis',
'94': 'Val-de-Marne',
'95': 'Val-d\'Oise',
'971': 'Guadeloupe',
'972': 'Martinique',
'973': 'Guyane',
'974': 'La Réunion',
'976': 'Mayotte',
}
json_data = '''
{
"department": "10",
"farmSize": 200,
"benefitsFromCommonAgriculturalPolicy": true,
"cultures": ["Blé", "Colza", "Carottes"],
"yields": {"Blé": 50, "Colza": 150, "Carottes": 11}
}
'''
def generate_question(json_data):
data = json.loads(json_data)
department_number = data['department']
farm_size = data['farmSize']
benefits_from_common_agricultural_policy = data['benefitsFromCommonAgriculturalPolicy']
cultures = data['cultures']
yields = data['yields']
department_name = departments_list.get(department_number)
number_fields = str(len(yields))
for region, department_codes in region_list.items():
if department_number in department_codes:
region_name = region
question = '''You are an agronomical advisor. Your task is to provide an advice to the farmer what to seed in the next year and for each field in a table format. You will be given the historical information about the farmer. Consider agronomical limitations, maximize his profit for 2024 based on the price information, avoid the repetition of the crop from 2023 for the same field and give a justification
#facts
The farmer is located in the region Charente-Maritime, departament ''' + department_name + ''' in region ''' + region_name
'''The farm area is ''' + str(farm_size) + '''
It has ''' + number_fields +''' fields '''
print(question)
for field_number, (crop, yield_value) in enumerate(yields.items(), start=1):
print(f"Field {field_number} in 2023 was seeded with {crop} with a yield of {yield_value}.")
generate_question(json_data) |