ciyidogan commited on
Commit
637f803
·
verified ·
1 Parent(s): 80b4159

Upload 2 files

Browse files
Files changed (2) hide show
  1. service_config.json +78 -0
  2. session.py +26 -0
service_config.json ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "config": {
3
+ "work_mode": "hfcloud",
4
+ "cloud_token": "",
5
+ "data_formats": {
6
+ "currency_format": {
7
+ "valid_options": ["dolar", "euro", "TL"],
8
+ "error_message": "Geçerli bir döviz cinsi belirtmelisiniz."
9
+ },
10
+ "client_no_format": {
11
+ "pattern": "^[0-9]{6}$",
12
+ "error_message": "Müşteri numaranız 6 haneli olmalıdır."
13
+ }
14
+ },
15
+ "apis": {
16
+ "currency_api": {
17
+ "url": "https://api.ex.com/doviz",
18
+ "method": "POST",
19
+ "headers": [
20
+ { "key": "Authorization", "value": "Bearer {auth_tokens.currency_api.token}" }
21
+ ],
22
+ "body": {
23
+ "currency": "{variables.currency}"
24
+ },
25
+ "timeout": 5,
26
+ "retry_count": 1,
27
+ "tls": {
28
+ "verify": true,
29
+ "ca_bundle": "/app/certs/my-ca.pem"
30
+ },
31
+ "auth": {
32
+ "auth_endpoint": "https://api.ex.com/auth",
33
+ "auth_body": { "username": "user", "password": "pass" },
34
+ "auth_token_path": "token",
35
+ "auth_refresh_endpoint": "https://api.ex.com/refresh",
36
+ "refresh_body": { "refresh_token": "{auth_tokens.currency_api.token}" }
37
+ },
38
+ "response_parser": {
39
+ "field": "rate",
40
+ "format": "{variables.currency} kuru: {rate} TL"
41
+ },
42
+ "reply_template": "{variables.currency} kuru şu an {rate} TL."
43
+ }
44
+ }
45
+ },
46
+ "projects": {
47
+ "project1": {
48
+ "llm": {
49
+ "model_base": "TURKCELL/Turkcell-LLM-7b-v1",
50
+ "use_fine_tune": false,
51
+ "fine_tune_repo": "UcsTurkey/trained-zips",
52
+ "fine_tune_zip": "trained_model_000_009.zip",
53
+ "use_sampling": false,
54
+ "intent_confidence_treshold": 0.5,
55
+ "llm_confidence_treshold": 0.2,
56
+ "train_confidence_treshold": 0.7,
57
+ "fallback_answers": [
58
+ "Bu konuda maalesef bilgim yok.",
59
+ "Ne demek istediğinizi tam anlayamadım.",
60
+ "Bu soruya şu an yanıt veremiyorum."
61
+ ],
62
+ "intent_model_path": "intent_model",
63
+ "intent_model_id": "dbmdz/bert-base-turkish-cased"
64
+ },
65
+ "intents": [
66
+ {
67
+ "name": "doviz-kuru-intent",
68
+ "examples": ["dolar kuru nedir?"],
69
+ "variables": ["currency:{dolar} kuru nedir?"],
70
+ "variable_formats": {
71
+ "currency": "currency_format"
72
+ },
73
+ "action": "currency_api"
74
+ }
75
+ ]
76
+ }
77
+ }
78
+ }
session.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import uuid
2
+
3
+ class Session:
4
+ def __init__(self, project_name):
5
+ self.session_id = str(uuid.uuid4())
6
+ self.project_name = project_name
7
+ self.variables = {}
8
+ self.auth_tokens = {}
9
+ self.last_intent = None
10
+ self.awaiting_variable = None
11
+
12
+ class SessionStore:
13
+ def __init__(self):
14
+ self.sessions = {}
15
+
16
+ def create_session(self, project_name):
17
+ session = Session(project_name)
18
+ self.sessions[session.session_id] = session
19
+ return session
20
+
21
+ def get_session(self, session_id):
22
+ return self.sessions.get(session_id)
23
+
24
+ def remove_session(self, session_id):
25
+ if session_id in self.sessions:
26
+ del self.sessions[session_id]