pro-craft 0.1.11__py3-none-any.whl → 0.1.12__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.

Potentially problematic release.


This version of pro-craft might be problematic. Click here for more details.

@@ -68,9 +68,8 @@ class AsyncIntel():
68
68
  ):
69
69
  database_url = database_url or os.getenv("database_url")
70
70
  assert database_url
71
-
72
- # async_engine
73
- self.async_engine = create_async_engine(database_url, echo=True,
71
+
72
+ self.engine = create_async_engine(database_url, echo=True,
74
73
  pool_size=10, # 连接池中保持的连接数
75
74
  max_overflow=20, # 当pool_size不够时,允许临时创建的额外连接数
76
75
  pool_recycle=3600, # 每小时回收一次连接
@@ -87,10 +86,10 @@ class AsyncIntel():
87
86
  self.llm = BianXieAdapter()
88
87
 
89
88
  async def create_database(self):
90
- async with self.async_engine.begin() as conn:
89
+ async with self.engine.begin() as conn:
91
90
  await conn.run_sync(PromptBase.metadata.create_all)
92
91
 
93
- async def _aget_latest_prompt_version(self,target_prompt_id,session):
92
+ async def _get_latest_prompt_version(self,target_prompt_id,session):
94
93
  """
95
94
  获取指定 prompt_id 的最新版本数据,通过创建时间判断。
96
95
  """
@@ -113,7 +112,7 @@ class AsyncIntel():
113
112
  editing_log(f"未找到 prompt_id '{target_prompt_id}' 的任何版本。")
114
113
  return result
115
114
 
116
- async def _aget_specific_prompt_version(self,target_prompt_id, target_version,session):
115
+ async def _get_specific_prompt_version(self,target_prompt_id, target_version,session):
117
116
  """
118
117
  获取指定 prompt_id 和特定版本的数据。
119
118
 
@@ -141,7 +140,7 @@ class AsyncIntel():
141
140
  editing_log(f"未找到 prompt_id '{target_prompt_id}', 版本 '{target_version}' 的提示词数据。")
142
141
  return specific_prompt
143
142
 
144
- async def aget_prompts_from_sql(self,
143
+ async def get_prompts_from_sql(self,
145
144
  prompt_id: str,
146
145
  version = None,
147
146
  session = None) -> Prompt:
@@ -150,15 +149,15 @@ class AsyncIntel():
150
149
  """
151
150
  # 查看是否已经存在
152
151
  if version:
153
- prompts_obj = await self._aget_specific_prompt_version(prompt_id,version,session=session)
152
+ prompts_obj = await self._get_specific_prompt_version(prompt_id,version,session=session)
154
153
  if not prompts_obj:
155
- prompts_obj = await self._aget_latest_prompt_version(prompt_id,session = session)
154
+ prompts_obj = await self._get_latest_prompt_version(prompt_id,session = session)
156
155
  else:
157
- prompts_obj = await self._aget_latest_prompt_version(prompt_id,session = session)
156
+ prompts_obj = await self._get_latest_prompt_version(prompt_id,session = session)
158
157
  return prompts_obj
159
158
 
160
159
 
161
- async def asave_prompt_increment_version(self,
160
+ async def save_prompt_increment_version(self,
162
161
  prompt_id: str,
163
162
  new_prompt: str,
164
163
  use_case:str = "",
@@ -171,7 +170,7 @@ class AsyncIntel():
171
170
  input_data 指的是输入用例, 可以为空
172
171
  """
173
172
  # 查看是否已经存在
174
- prompts_obj = await self.aget_prompts_from_sql(prompt_id=prompt_id,session=session)
173
+ prompts_obj = await self.get_prompts_from_sql(prompt_id=prompt_id,session=session)
175
174
 
176
175
  if prompts_obj:
177
176
  # 如果存在版本加1
@@ -198,7 +197,7 @@ class AsyncIntel():
198
197
  session.add(prompt1)
199
198
  await session.commit() # 提交事务,将数据写入数据库
200
199
 
201
- async def asave_use_case_by_sql(self,
200
+ async def save_use_case_by_sql(self,
202
201
  prompt_id: str,
203
202
  use_case:str = "",
204
203
  output = "",
@@ -237,7 +236,7 @@ class AsyncIntel():
237
236
 
238
237
  s_prompt = extract_(system_result,pattern_key=r"prompt")
239
238
  chat_history = s_prompt or system_result
240
- await self.asave_prompt_increment_version(prompt_id,
239
+ await self.save_prompt_increment_version(prompt_id,
241
240
  new_prompt = chat_history,
242
241
  input_data = " summary ",
243
242
  session = session)
@@ -279,20 +278,20 @@ class AsyncIntel():
279
278
  {opinion}
280
279
  """
281
280
 
282
- prompt, _ = await self.aget_prompts_from_sql(prompt_id = prompt_id,version = version)
281
+ prompt, _ = await self.get_prompts_from_sql(prompt_id = prompt_id,version = version)
283
282
  if demand:
284
283
  new_prompt = await self.llm.aproduct(
285
284
  change_by_opinion_prompt.format(old_system_prompt=prompt, opinion=demand)
286
285
  )
287
286
  else:
288
287
  new_prompt = prompt
289
- await self.asave_prompt_increment_version(prompt_id = prompt_id,
288
+ await self.save_prompt_increment_version(prompt_id = prompt_id,
290
289
  new_prompt = new_prompt,
291
290
  input_data = " finetune ",
292
291
  session = session)
293
292
 
294
293
 
295
- async def apush_action_order(self,demand : str,prompt_id: str,
294
+ async def push_action_order(self,demand : str,prompt_id: str,
296
295
  action_type = 'train'):
297
296
 
298
297
  """
@@ -302,11 +301,11 @@ class AsyncIntel():
302
301
  将打算修改的状态推上数据库 # 1
303
302
  """
304
303
  # 查看是否已经存在
305
- async with create_async_session(self.async_engine) as session:
304
+ async with create_async_session(self.engine) as session:
306
305
 
307
- latest_prompt = await self.aget_prompts_from_sql(prompt_id=prompt_id,session=session)
306
+ latest_prompt = await self.get_prompts_from_sql(prompt_id=prompt_id,session=session)
308
307
 
309
- await self.asave_prompt_increment_version(prompt_id=latest_prompt.prompt_id,
308
+ await self.save_prompt_increment_version(prompt_id=latest_prompt.prompt_id,
310
309
  new_prompt = latest_prompt.prompt,
311
310
  use_case = latest_prompt.use_case,
312
311
  action_type=action_type,
@@ -319,7 +318,7 @@ class AsyncIntel():
319
318
 
320
319
 
321
320
 
322
- async def aintellect_remove(self,
321
+ async def intellect_remove(self,
323
322
  input_data: dict | str,
324
323
  output_format: str,
325
324
  prompt_id: str,
@@ -333,18 +332,18 @@ class AsyncIntel():
333
332
  input_ = input_data
334
333
 
335
334
  # 查数据库, 获取最新提示词对象
336
- async with create_async_session(self.async_engine) as session:
337
- result_obj = await self.aget_prompts_from_sql(prompt_id=prompt_id,session=session)
335
+ async with create_async_session(self.engine) as session:
336
+ result_obj = await self.get_prompts_from_sql(prompt_id=prompt_id,session=session)
338
337
 
339
338
 
340
339
  if result_obj is None:
341
- await self.asave_prompt_increment_version(
340
+ await self.save_prompt_increment_version(
342
341
  prompt_id = prompt_id,
343
342
  new_prompt = "做一些处理",
344
343
  use_case = input_,
345
344
  session = session
346
345
  )
347
- ai_result = await self.aintellect_remove(input_data = input_data,
346
+ ai_result = await self.intellect_remove(input_data = input_data,
348
347
  output_format = output_format,
349
348
  prompt_id = prompt_id,
350
349
  version = version,
@@ -357,7 +356,7 @@ class AsyncIntel():
357
356
  # 直接推理即可
358
357
  ai_result = await self.llm.aproduct(prompt + output_format + "\n-----input----\n" + input_)
359
358
  if inference_save_case:
360
- await self.asave_use_case_by_sql(prompt_id,
359
+ await self.save_use_case_by_sql(prompt_id,
361
360
  use_case = input_,
362
361
  output = ai_result,
363
362
  solution = "备注/理想回复",
@@ -386,7 +385,7 @@ class AsyncIntel():
386
385
 
387
386
  ai_result = await self.llm.aproduct(input_prompt)
388
387
  chat_history = input_prompt + "\nassistant:\n" + ai_result # 用聊天记录作为完整提示词
389
- await self.asave_prompt_increment_version(prompt_id, chat_history,
388
+ await self.save_prompt_increment_version(prompt_id, chat_history,
390
389
  use_case = input_,
391
390
  session = session)
392
391
 
@@ -426,7 +425,7 @@ class AsyncIntel():
426
425
 
427
426
  return ai_result
428
427
 
429
- async def aintellect_stream_remove(self,
428
+ async def intellect_stream_remove(self,
430
429
  input_data: dict | str,
431
430
  output_format: str,
432
431
  prompt_id: str,
@@ -441,18 +440,18 @@ class AsyncIntel():
441
440
 
442
441
 
443
442
  # 查数据库, 获取最新提示词对象
444
- with create_session(self.async_engine) as session:
445
- result_obj = await self.aget_prompts_from_sql(prompt_id=prompt_id,session=session)
443
+ with create_session(self.engine) as session:
444
+ result_obj = await self.get_prompts_from_sql(prompt_id=prompt_id,session=session)
446
445
 
447
446
  '''
448
447
  if result_obj is None:
449
- await self.asave_prompt_increment_version(
448
+ await self.save_prompt_increment_version(
450
449
  prompt_id = prompt_id,
451
450
  new_prompt = "做一些处理",
452
451
  use_case = input_,
453
452
  session = session
454
453
  )
455
- ai_result = await self.aintellect_stream_remove(input_data = input_data,
454
+ ai_result = await self.intellect_stream_remove(input_data = input_data,
456
455
  output_format = output_format,
457
456
  prompt_id = prompt_id,
458
457
  version = version,
@@ -470,7 +469,7 @@ class AsyncIntel():
470
469
  ai_result += word
471
470
  yield word
472
471
  if inference_save_case:
473
- await self.asave_use_case_by_sql(prompt_id,
472
+ await self.save_use_case_by_sql(prompt_id,
474
473
  use_case = input_,
475
474
  output = ai_result,
476
475
  solution = "备注/理想回复",
@@ -504,7 +503,7 @@ class AsyncIntel():
504
503
  yield word
505
504
 
506
505
  chat_history = input_prompt + "\nassistant:\n" + ai_result # 用聊天记录作为完整提示词
507
- await self.asave_prompt_increment_version(prompt_id, chat_history,
506
+ await self.save_prompt_increment_version(prompt_id, chat_history,
508
507
  use_case = input_,
509
508
  session = session)
510
509
 
@@ -555,7 +554,7 @@ class AsyncIntel():
555
554
  else:
556
555
  raise
557
556
 
558
- async def aintellect_remove_format(self,
557
+ async def intellect_remove_format(self,
559
558
  input_data: dict | str,
560
559
  OutputFormat: object,
561
560
  prompt_id: str,
@@ -573,7 +572,7 @@ class AsyncIntel():
573
572
  """
574
573
  output_format = base_format_prompt + "\n".join([inspect.getsource(outputformat) for outputformat in ExtraFormats]) + inspect.getsource(OutputFormat)
575
574
 
576
- ai_result = await self.aintellect_remove(
575
+ ai_result = await self.intellect_remove(
577
576
  input_data=input_data,
578
577
  output_format=output_format,
579
578
  prompt_id=prompt_id,
@@ -606,7 +605,7 @@ class AsyncIntel():
606
605
  return ai_result
607
606
 
608
607
 
609
- def aintellect_remove_warp(self,prompt_id: str):
608
+ def intellect_remove_warp(self,prompt_id: str):
610
609
  def outer_packing(func):
611
610
  @functools.wraps(func)
612
611
  async def wrapper(*args, **kwargs):
@@ -621,7 +620,7 @@ class AsyncIntel():
621
620
  elif isinstance(input_data,str):
622
621
  input_ = output_ = input_data
623
622
 
624
- output_ = await self.aintellect_remove_format(
623
+ output_ = await self.intellect_remove_format(
625
624
  input_data = input_data,
626
625
  prompt_id = prompt_id,
627
626
  OutputFormat = OutputFormat,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pro-craft
3
- Version: 0.1.11
3
+ Version: 0.1.12
4
4
  Summary: Add your description here
5
5
  Requires-Python: >=3.12
6
6
  Description-Content-Type: text/markdown
@@ -5,7 +5,7 @@ pro_craft/evals.py,sha256=1T86jur4k3cLk43j1GyAW4JS0nPNfl6P0ZOQmu-SgpA,1928
5
5
  pro_craft/file_manager.py,sha256=2j7lCt9L4mtvAy8_76ibTthXLwKKmVatWIB3DSvQM7U,3805
6
6
  pro_craft/log.py,sha256=MZf9jCZsiRoAq8v4FxVnJqeSXxgzAiiKf7mxz6bFtwM,4263
7
7
  pro_craft/prompt_helper.py,sha256=GClPsomdGdo6FXlp8VdiQy8GaBtj3oLeq2oFw0RiM3k,26592
8
- pro_craft/prompt_helper_async.py,sha256=Ej0JXwev0FmPSoOE5iEXtZxQ3pXoqcaulyyUuC7WyC4,27859
8
+ pro_craft/prompt_helper_async.py,sha256=-EtwjDUL2Xoi4qjZpzgnUyAVBkt-WCocGgVl5PgA4Js,27771
9
9
  pro_craft/prompt_helper_new.py,sha256=DV871XElJmHDO2xis1mC1f3QFvq3ll81VGGD9aj0Eiw,23542
10
10
  pro_craft/server.py,sha256=fPAosQIU0d7gxICiALl8u6QwbLI4cawVFyoRYebRES0,2827
11
11
  pro_craft/utils.py,sha256=cpvwk68mD9hYY8WCq2JXzfrrXqpshiscz_OSav4tC7U,5687
@@ -18,7 +18,7 @@ pro_craft/server/mcp/math.py,sha256=OOzGXx64nK4bOVlu33PtVddcCQ9ilqA3Em9yxjSX9cg,
18
18
  pro_craft/server/mcp/resource.py,sha256=z94jP3qZofO-1lZCM3TuOfLajw41HARs1ojXab1ymas,776
19
19
  pro_craft/server/mcp/weather.py,sha256=RAGuf4sgjlTQSfRRZ1Fo18JnuMQRS_Db9p6AqBQrl8E,455
20
20
  pro_craft/server/router/recommended.py,sha256=IAZFdmb8HSl2_TOJeuv5uOKIX47XyX4p4sEwxG-0vt0,9968
21
- pro_craft-0.1.11.dist-info/METADATA,sha256=Delq6mCu7BWJGL6LhC5054iGNkXnRGsiLaD6apL6m1w,1800
22
- pro_craft-0.1.11.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
23
- pro_craft-0.1.11.dist-info/top_level.txt,sha256=yqYDHArnYMWpeCxkmGRwlL6sJtxiOUnYylLDx9EOgFg,10
24
- pro_craft-0.1.11.dist-info/RECORD,,
21
+ pro_craft-0.1.12.dist-info/METADATA,sha256=VKEqBoEWYaOP0Ue2BSZ3iKZ1W_MYqsaRS7f3lQ-bscs,1800
22
+ pro_craft-0.1.12.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
23
+ pro_craft-0.1.12.dist-info/top_level.txt,sha256=yqYDHArnYMWpeCxkmGRwlL6sJtxiOUnYylLDx9EOgFg,10
24
+ pro_craft-0.1.12.dist-info/RECORD,,