pilot.linkstec 0.0.91__py3-none-any.whl → 0.0.92__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pilot/generater/vertexai.py +77 -27
- pilot/job/base/{generate → generater}/generateJsonBaseJob.py +0 -2
- pilot/job/base/{generate → generater}/generateTextBaseJob.py +1 -4
- pilot/job/base/program/__init__.py +0 -0
- pilot/job/base/program/cobol/__init__.py +0 -0
- pilot/job/base/program/cobol/convert/__init__.py +0 -0
- pilot/job/impl/base_job.py +2 -9
- pilot/unit/impl/base_unit.py +1 -1
- {pilot_linkstec-0.0.91.dist-info → pilot_linkstec-0.0.92.dist-info}/METADATA +1 -1
- {pilot_linkstec-0.0.91.dist-info → pilot_linkstec-0.0.92.dist-info}/RECORD +14 -11
- /pilot/job/base/{generate → generater}/__init__.py +0 -0
- {pilot_linkstec-0.0.91.dist-info → pilot_linkstec-0.0.92.dist-info}/WHEEL +0 -0
- {pilot_linkstec-0.0.91.dist-info → pilot_linkstec-0.0.92.dist-info}/licenses/LICENSE +0 -0
- {pilot_linkstec-0.0.91.dist-info → pilot_linkstec-0.0.92.dist-info}/top_level.txt +0 -0
pilot/generater/vertexai.py
CHANGED
|
@@ -1,19 +1,12 @@
|
|
|
1
1
|
import threading
|
|
2
2
|
from typing import Dict, Any, Optional
|
|
3
|
-
|
|
4
|
-
import tiktoken
|
|
5
|
-
from vertexai.generative_models import GenerativeModel, ChatSession
|
|
6
|
-
import os
|
|
3
|
+
import requests
|
|
7
4
|
|
|
8
5
|
class VertexAISingleton:
|
|
9
6
|
_instance: Optional['VertexAISingleton'] = None
|
|
10
|
-
|
|
11
|
-
|
|
12
7
|
_lock = threading.Lock()
|
|
13
|
-
_tokenizer_cache = {}
|
|
14
|
-
encoding = None
|
|
15
8
|
|
|
16
|
-
def __new__(cls, model_name: str = "
|
|
9
|
+
def __new__(cls, model_name: str = "openai/gpt-oss-20b"):
|
|
17
10
|
if cls._instance is None:
|
|
18
11
|
with cls._lock:
|
|
19
12
|
if cls._instance is None:
|
|
@@ -21,24 +14,47 @@ class VertexAISingleton:
|
|
|
21
14
|
cls._instance._initialized = False
|
|
22
15
|
return cls._instance
|
|
23
16
|
|
|
24
|
-
def __init__(self, model_name: str = "
|
|
17
|
+
def __init__(self, model_name: str = "openai/gpt-oss-20b"):
|
|
25
18
|
if not self._initialized:
|
|
26
19
|
with self._lock:
|
|
27
20
|
if not self._initialized:
|
|
28
|
-
self.
|
|
29
|
-
self.
|
|
21
|
+
self.model_name = model_name
|
|
22
|
+
self.base_url = "http://127.0.0.1:3000/v1"
|
|
23
|
+
|
|
24
|
+
#self.encoding = tiktoken.get_encoding("cl100k_base")
|
|
25
|
+
|
|
26
|
+
self._session = requests.Session()
|
|
27
|
+
|
|
30
28
|
self._initialized = True
|
|
31
29
|
|
|
32
30
|
def generate_content(self, prompt: str) -> Dict[str, Any]:
|
|
33
31
|
"""複数スレッドから安全に呼び出し可能"""
|
|
34
32
|
try:
|
|
35
|
-
|
|
33
|
+
payload = {
|
|
34
|
+
"model": self.model_name,
|
|
35
|
+
"messages": [
|
|
36
|
+
{"role": "user", "content": prompt}
|
|
37
|
+
],
|
|
38
|
+
"temperature": 0.7
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
resp = self._session.post(
|
|
42
|
+
f"{self.base_url}/chat/completions",
|
|
43
|
+
json=payload,
|
|
44
|
+
timeout=600
|
|
45
|
+
)
|
|
46
|
+
resp.raise_for_status()
|
|
47
|
+
data = resp.json()
|
|
48
|
+
|
|
49
|
+
content = data["choices"][0]["message"]["content"]
|
|
50
|
+
|
|
36
51
|
return {
|
|
37
52
|
"prompt": prompt,
|
|
38
|
-
"response": self._remove_code_fence(
|
|
53
|
+
"response": self._remove_code_fence(content),
|
|
39
54
|
"success": True,
|
|
40
55
|
"error": None
|
|
41
56
|
}
|
|
57
|
+
|
|
42
58
|
except Exception as e:
|
|
43
59
|
return {
|
|
44
60
|
"prompt": prompt,
|
|
@@ -47,18 +63,20 @@ class VertexAISingleton:
|
|
|
47
63
|
"error": str(e)
|
|
48
64
|
}
|
|
49
65
|
|
|
50
|
-
def start_chat(self)
|
|
51
|
-
"""
|
|
52
|
-
|
|
66
|
+
def start_chat(self):
|
|
67
|
+
"""
|
|
68
|
+
VertexAI の ChatSession と完全互換は不可能だが、
|
|
69
|
+
既存コードを壊さないために「退化実装」を提供
|
|
70
|
+
"""
|
|
71
|
+
return _LMStudioChatSession(self)
|
|
53
72
|
|
|
54
73
|
def count_tokens(self, text: str) -> int:
|
|
55
|
-
|
|
56
|
-
try:
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
return 0
|
|
74
|
+
return 1
|
|
75
|
+
#try:
|
|
76
|
+
# return len(self.encoding.encode(text))
|
|
77
|
+
#except Exception as e:
|
|
78
|
+
# print(f"トークン計算失敗: {e}")
|
|
79
|
+
# return 0
|
|
62
80
|
|
|
63
81
|
def _remove_code_fence(self, text: str) -> str:
|
|
64
82
|
lines = text.splitlines()
|
|
@@ -69,6 +87,38 @@ class VertexAISingleton:
|
|
|
69
87
|
return "\n".join(lines)
|
|
70
88
|
|
|
71
89
|
@classmethod
|
|
72
|
-
def get_instance(cls, model_name: str = "
|
|
73
|
-
|
|
74
|
-
|
|
90
|
+
def get_instance(cls, model_name: str = "openai/gpt-oss-20b") -> 'VertexAISingleton':
|
|
91
|
+
return cls(model_name)
|
|
92
|
+
|
|
93
|
+
class _LMStudioChatSession:
|
|
94
|
+
"""
|
|
95
|
+
VertexAI ChatSession の「最低限互換」
|
|
96
|
+
"""
|
|
97
|
+
def __init__(self, client: VertexAISingleton):
|
|
98
|
+
self._client = client
|
|
99
|
+
self._messages = []
|
|
100
|
+
|
|
101
|
+
def send_message(self, message: str):
|
|
102
|
+
self._messages.append({"role": "user", "content": message})
|
|
103
|
+
|
|
104
|
+
payload = {
|
|
105
|
+
"model": self._client.model_name,
|
|
106
|
+
"messages": self._messages
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
resp = self._client._session.post(
|
|
110
|
+
f"{self._client.base_url}/chat/completions",
|
|
111
|
+
json=payload,
|
|
112
|
+
timeout=60
|
|
113
|
+
)
|
|
114
|
+
resp.raise_for_status()
|
|
115
|
+
data = resp.json()
|
|
116
|
+
|
|
117
|
+
reply = data["choices"][0]["message"]["content"]
|
|
118
|
+
self._messages.append({"role": "assistant", "content": reply})
|
|
119
|
+
|
|
120
|
+
class _Resp:
|
|
121
|
+
def __init__(self, text):
|
|
122
|
+
self.text = text
|
|
123
|
+
|
|
124
|
+
return _Resp(reply)
|
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
import json
|
|
2
|
-
import os
|
|
3
|
-
import threading
|
|
4
1
|
import time
|
|
5
2
|
|
|
6
3
|
from pilot.job.impl.base_job import BaseJob
|
|
7
4
|
|
|
8
5
|
from pilot.generater.vertexai import VertexAISingleton
|
|
9
6
|
|
|
10
|
-
class
|
|
7
|
+
class generateTextBaseJob(BaseJob):
|
|
11
8
|
|
|
12
9
|
prompt_content: str
|
|
13
10
|
result_content: str
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
pilot/job/impl/base_job.py
CHANGED
|
@@ -66,13 +66,6 @@ class BaseJob(JobInterface):
|
|
|
66
66
|
def current_trg_file_path(self, value):
|
|
67
67
|
self._trg_file_path = value
|
|
68
68
|
|
|
69
|
-
|
|
70
|
-
def prerun(self):
|
|
71
|
-
pass
|
|
72
|
-
|
|
73
|
-
def postrun(self):
|
|
74
|
-
self.change_current_trg_to_end()
|
|
75
|
-
|
|
76
69
|
def run(self):
|
|
77
70
|
pass
|
|
78
71
|
|
|
@@ -162,7 +155,7 @@ class BaseJob(JobInterface):
|
|
|
162
155
|
return True
|
|
163
156
|
except Exception:
|
|
164
157
|
# 例外が発生した場合は False を返す
|
|
165
|
-
print("!!!!!!!!!!!!!!!!!!!!change_current_trg_to_end erro")
|
|
158
|
+
#print("!!!!!!!!!!!!!!!!!!!!change_current_trg_to_end erro")
|
|
166
159
|
return False
|
|
167
160
|
# trgファイルが存在しなければ何もしないので、そのままreturn
|
|
168
161
|
return False
|
|
@@ -345,7 +338,7 @@ class BaseJob(JobInterface):
|
|
|
345
338
|
ジョブ実行後の後処理を行うメソッド。
|
|
346
339
|
必要に応じてサブクラスでオーバーライドして使用する。
|
|
347
340
|
"""
|
|
348
|
-
|
|
341
|
+
self.change_current_trg_to_end()
|
|
349
342
|
|
|
350
343
|
def generate_basedir_file(self, ext):
|
|
351
344
|
dir_path = os.path.dirname(self.file_path)
|
pilot/unit/impl/base_unit.py
CHANGED
|
@@ -42,18 +42,21 @@ pilot/file_tool/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
|
42
42
|
pilot/file_tool/create_prompt_file.py,sha256=pvmBm_iRWRvm5Qr8gaZwSAzJ_1vrqG9Xi_UJ-NgdwV8,1994
|
|
43
43
|
pilot/file_tool/json_file_tool.py,sha256=v-qVcyKVhFfwEg4uJWDFMZU0EWvOwkYhrwhm-obMlUU,3637
|
|
44
44
|
pilot/generater/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
45
|
-
pilot/generater/vertexai.py,sha256=
|
|
45
|
+
pilot/generater/vertexai.py,sha256=gkf8ToDVGfD2j7JbR1ZtVurM7D7aZ0HLP6Vx7-Vjy7c,3939
|
|
46
46
|
pilot/job/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
47
47
|
pilot/job/job_interface.py,sha256=EKtuj0IcdolP494aAgTtctgamyQIoFXVwRORwOQck7A,124
|
|
48
48
|
pilot/job/base/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
49
49
|
pilot/job/base/convert/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
50
50
|
pilot/job/base/convert/encodingTransformerJob.py,sha256=tJI2JcBK3869pIgJxf9WFa7D-wCnHHO1aU8vQo7qjds,457
|
|
51
51
|
pilot/job/base/convert/tabReplaceJob.py,sha256=ev5uoPbiwhVCSDPdonvFDnWI-vi4R-4Adoa4eJddL9w,917
|
|
52
|
-
pilot/job/base/
|
|
53
|
-
pilot/job/base/
|
|
54
|
-
pilot/job/base/
|
|
52
|
+
pilot/job/base/generater/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
53
|
+
pilot/job/base/generater/generateJsonBaseJob.py,sha256=Nea0GUvILgYyBiFpMOb3ZctYlxbE0pwGeJfeEWFjveQ,1348
|
|
54
|
+
pilot/job/base/generater/generateTextBaseJob.py,sha256=UCEkoDGN9qdHPSXrP_zpFDOpHtfjse1SskMuS31uOwk,1265
|
|
55
|
+
pilot/job/base/program/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
56
|
+
pilot/job/base/program/cobol/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
57
|
+
pilot/job/base/program/cobol/convert/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
55
58
|
pilot/job/impl/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
56
|
-
pilot/job/impl/base_job.py,sha256=
|
|
59
|
+
pilot/job/impl/base_job.py,sha256=wTrAp9P6AxyQ98cD6kWa22gUTiXJc6TcTv7-cvize9c,14665
|
|
57
60
|
pilot/logging/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
58
61
|
pilot/logging/logger.py,sha256=TF7eGr3w8GK5v4sf71lDt97uVoBtCgqrZuCdbMmeQBU,1815
|
|
59
62
|
pilot/processor/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -65,11 +68,11 @@ pilot/splitters/cobolsplitter.py,sha256=oPwxKRjA7TyXWaWV3jdy59lJZy1mRn6yxD9ivqFY
|
|
|
65
68
|
pilot/unit/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
66
69
|
pilot/unit/unit_interface.py,sha256=fE8N4h_rZU-dWLHy9o0EE3yyErGmRyIuGUDb-zqe7qo,167
|
|
67
70
|
pilot/unit/impl/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
68
|
-
pilot/unit/impl/base_unit.py,sha256=
|
|
71
|
+
pilot/unit/impl/base_unit.py,sha256=pF3R1TxoJtDIt5MCggSPO1H5jFI-wO1gQosz4haYTQo,1308
|
|
69
72
|
pilot/util/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
70
73
|
pilot/util/files.py,sha256=v9uzfzo3Aq4xgnUIASEZeBJoA2nD9Qz_EA3P-FwzGFQ,1896
|
|
71
|
-
pilot_linkstec-0.0.
|
|
72
|
-
pilot_linkstec-0.0.
|
|
73
|
-
pilot_linkstec-0.0.
|
|
74
|
-
pilot_linkstec-0.0.
|
|
75
|
-
pilot_linkstec-0.0.
|
|
74
|
+
pilot_linkstec-0.0.92.dist-info/licenses/LICENSE,sha256=6kbiFSfobTZ7beWiKnHpN902HgBx-Jzgcme0SvKqhKY,1091
|
|
75
|
+
pilot_linkstec-0.0.92.dist-info/METADATA,sha256=wybOFFLfloJoPHK_ZTdcmDl5-PiR-esNp_N1GajX_tM,679
|
|
76
|
+
pilot_linkstec-0.0.92.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
77
|
+
pilot_linkstec-0.0.92.dist-info/top_level.txt,sha256=BijnVJdXnIPxxx3s60M848seL4Z12gNUPod6KPJxK9c,6
|
|
78
|
+
pilot_linkstec-0.0.92.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|