From 68da6681f5f7c97dfc43f2f49c644590af12ff5d Mon Sep 17 00:00:00 2001 From: Anton Romanov Date: Tue, 13 Aug 2024 16:17:36 +0400 Subject: [PATCH] add python client --- client example.py | 78 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 client example.py diff --git a/client example.py b/client example.py new file mode 100644 index 0000000..b910fdd --- /dev/null +++ b/client example.py @@ -0,0 +1,78 @@ +import json +import requests + +url = 'http://plans.athene.tech/rest/get-inference' +headers = { + 'Content-type': 'application/json', + 'Accept': 'application/json' +} + +age = 65 +income = 20000 + +data = { + "inputVariables": [ + { + "name": "возраст", + "values": [ + { + "fuzzyTerm": "молодой", + "value": 35 + }, + { + "fuzzyTerm": "средний", + "value": 45 + }, + { + "fuzzyTerm": "старый", + "value": 65 + }] + }, + { + "name": "доход", + "values": [ + { + "fuzzyTerm": "низкий", + "value": 50000 + }, + { + "fuzzyTerm": "средний", + "value": 100000 + }, + { + "fuzzyTerm": "высокий", + "value": 500000 + }] + }], + "outputVariable": + { + "name": "кредит", + "values": [ + { + "fuzzyTerm": "небольшой", + "value": 50000 + }, + { + "fuzzyTerm": "средний", + "value": 100000 + }, + { + "fuzzyTerm": "большой", + "value": 200000 + }] + }, + "rules": [ + "if доход is высокий and возраст is молодой then кредит is большой", + "if доход is высокий and возраст is средний then кредит is средний", + "if доход is высокий and возраст is старый then кредит is средний", + "if доход is низкий and возраст is молодой then кредит is небольшой" + ], + "values": + { + "доход": income, + "возраст": age + } +} + +response = requests.post(url, data=json.dumps(data), headers=headers) +print(response.json())