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

@@ -1,7 +1,7 @@
1
1
  # 测试1
2
2
  from pro_craft.utils import extract_
3
3
  from pro_craft import logger as pro_craft_logger
4
- from llmada.core import BianXieAdapter, ArkAdapter
4
+ from modusched.core import BianXieAdapter, ArkAdapter
5
5
  from datetime import datetime
6
6
  from enum import Enum
7
7
  import functools
@@ -626,6 +626,8 @@ class AsyncIntel():
626
626
  session = session)
627
627
  ai_result = await self.llm.aproduct(prompt_obj.prompt + output_format + "\nuser:" + input_)
628
628
 
629
+ elif result_obj.action_type == "pass":
630
+ pass
629
631
  else:
630
632
  raise
631
633
 
@@ -640,6 +642,7 @@ class AsyncIntel():
640
642
  inference_save_case = True,
641
643
  ConTent_Function = None,
642
644
  AConTent_Function = None,
645
+ logger = None,
643
646
  ):
644
647
  """
645
648
  这个format 是严格校验模式, 是interllect 的增强版, 会主动校验内容,并及时抛出异常(或者伺机修正)
@@ -647,8 +650,8 @@ class AsyncIntel():
647
650
  AConTent_Function
648
651
  两种方式的传入方式, 内容未通过就抛出异常
649
652
 
650
- """
651
-
653
+ # TODO 增加兜底版本
654
+ """
652
655
  base_format_prompt = """
653
656
  按照一定格式输出, 以便可以通过如下校验
654
657
 
@@ -660,6 +663,11 @@ class AsyncIntel():
660
663
  output_format = base_format_prompt + "\n".join([inspect.getsource(outputformat) for outputformat in ExtraFormats]) + inspect.getsource(OutputFormat)
661
664
  else:
662
665
  output_format = ""
666
+
667
+ if logger:
668
+ logger.info(f'{type(input_data)} $ intellect输入 input_data $ {input_data}')
669
+ logger.info(f'{type(output_format)} $ intellect输入 output_format $ {output_format}')
670
+
663
671
  ai_result = await self.intellect(
664
672
  input_data=input_data,
665
673
  output_format=output_format,
@@ -675,12 +683,13 @@ class AsyncIntel():
675
683
 
676
684
  except JSONDecodeError as e:
677
685
  try:
678
- self.logger.error(f"尝试补救")
686
+ self.logger.error(f'{type(json_str)} $ intellect尝试补救 $ {json_str}')
679
687
  json_str = fix_broken_json_string(json_str)
680
688
  ai_result = json.loads(json_str)
681
689
  OutputFormat(**ai_result)
682
690
 
683
691
  except JSONDecodeError as e:
692
+ self.logger.error(f'{type(json_str)} $ {prompt_id}intellect生成的内容为无法被Json解析 $ {json_str}')
684
693
  raise IntellectRemoveFormatError(f"prompt_id: {prompt_id} 生成的内容为无法被Json解析 {e}") from e
685
694
 
686
695
  except ValidationError as e:
@@ -691,11 +700,13 @@ class AsyncIntel():
691
700
  raise Exception(f"Error {prompt_id} : {e}") from e
692
701
 
693
702
  if ConTent_Function:
694
- ConTent_Function(ai_result)
703
+ ConTent_Function(ai_result,input_data)
695
704
 
696
705
  if AConTent_Function:
697
- await AConTent_Function(ai_result)
706
+ await AConTent_Function(ai_result,input_data)
698
707
 
708
+ if logger:
709
+ logger.info(f'{type(ai_result)} $ intellect输出 ai_result $ {ai_result}')
699
710
  return ai_result
700
711
 
701
712
  async def intellect_formats(self,
@@ -869,7 +880,7 @@ class AsyncIntel():
869
880
  "bad_case":json.dumps(bad_case,ensure_ascii=False)}
870
881
  return "未通过",success_rate, str(total_assertions), json.dumps(bad_case,ensure_ascii=False),
871
882
 
872
- def draw_data(self,save_html_path):
883
+ def draw_data(self,save_html_path = ""):
873
884
  df = self.eval_df
874
885
  # --- 可视化部分 ---
875
886
  fig = go.Figure()
@@ -17,6 +17,7 @@ class PushOrderRequest(BaseModel):
17
17
 
18
18
  class GetPromptRequest(BaseModel):
19
19
  prompt_id: str = Field(..., description="提示词id")
20
+ version: str = Field(None, description="提示词id")
20
21
 
21
22
  class UpdatePromptRequest(BaseModel):
22
23
  prompt_id: str = Field(..., description="提示词id")
@@ -32,4 +33,4 @@ class RollBackPromptRequest(BaseModel):
32
33
 
33
34
  class PromptResponse(BaseModel):
34
35
  msg: str = Field(..., description="信息")
35
- content: str = None
36
+ content: dict| str = None
@@ -5,6 +5,9 @@ from pro_craft import Intel,AsyncIntel
5
5
  from pro_craft.utils import create_async_session
6
6
  from fastapi import FastAPI, HTTPException
7
7
  from .models import *
8
+ from fastapi import APIRouter, Depends, HTTPException, status, Header
9
+ import os
10
+
8
11
 
9
12
  def create_router(database_url: str,
10
13
  slave_database_url: str,
@@ -30,8 +33,22 @@ def create_router(database_url: str,
30
33
  logger=logger
31
34
  )
32
35
 
36
+ async def verify_api_key(authorization: Optional[str] = Header(None)):
37
+ # if not authorization:
38
+ # raise HTTPException(status_code=401, detail="Invalid authorization scheme")
39
+ # if not authorization.startswith("Bearer "):
40
+ # raise HTTPException(status_code=401, detail="Invalid authorization scheme")
41
+
42
+ # token = authorization.split(" ")[1]
43
+
44
+ key = os.getenv("prompt_api_key")
45
+ key_ = "123578"
46
+ if key_ != key:
47
+ raise HTTPException(status_code=401, detail="Error Server Position2")
48
+
33
49
  router = APIRouter(
34
- tags=["prompt"] # 这里使用 Depends 确保每次请求都验证
50
+ tags=["prompt"], # 这里使用 Depends 确保每次请求都验证
51
+ dependencies = [Depends(verify_api_key)]
35
52
  )
36
53
 
37
54
  # 自动修改
@@ -57,7 +74,7 @@ def create_router(database_url: str,
57
74
  @router.get("/registered_prompt",
58
75
  description="获取以注册的提示词",
59
76
  response_model=PromptResponse)
60
- async def get_prompt():
77
+ async def registered_prompt():
61
78
  try:
62
79
  result = ["memorycard-format",
63
80
  "memorycard-polish",
@@ -94,9 +111,10 @@ def create_router(database_url: str,
94
111
  async with create_async_session(intels.engine) as session:
95
112
  result = await intels.get_prompt_safe(
96
113
  prompt_id=request.prompt_id,
114
+ version = request.version,
97
115
  session=session
98
116
  )
99
- return PromptResponse(msg = "success",content=f"prompt: {result.prompt}, version: {result.version}")
117
+ return PromptResponse(msg = "success",content={"prompt": result.prompt, "version": result.version})
100
118
 
101
119
  except Exception as e:
102
120
  raise HTTPException(
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pro-craft
3
- Version: 0.1.52
3
+ Version: 0.1.54
4
4
  Summary: Add your description here
5
5
  Requires-Python: >=3.12
6
6
  Description-Content-Type: text/markdown
@@ -10,6 +10,7 @@ Requires-Dist: db-help>=0.2.2
10
10
  Requires-Dist: fastapi>=0.119.0
11
11
  Requires-Dist: llmada>=1.1.11
12
12
  Requires-Dist: mcp[cli]>=1.19.0
13
+ Requires-Dist: modusched==0.1.5
13
14
  Requires-Dist: plotly>=6.3.1
14
15
  Requires-Dist: pyyaml>=6.0.3
15
16
  Requires-Dist: toml>=0.10.2
@@ -6,16 +6,16 @@ pro_craft/utils.py,sha256=R1DFkS4dsm5dIhg8lLTgBBvItvIYyyojROdh-ykqiYk,5250
6
6
  pro_craft/code_helper/coder.py,sha256=L6pRQr0pYRIHrMFZ4-pO_tZf1koxgGgF3L7Vl-GIyjM,24687
7
7
  pro_craft/code_helper/designer.py,sha256=3gyCqrjcw61sHzDjUPKhL1LOAE8xWLLbNT8NlK2mFLc,4739
8
8
  pro_craft/prompt_craft/__init__.py,sha256=83ruWO1Oci-DWvdVhPqcQrgdZTNfbmK72VQCkWASk7A,80
9
- pro_craft/prompt_craft/async_.py,sha256=bDcXQ3rfLOFOD_d5ImsBkP6FeWj-n69w6KfFIUE-5P4,42529
9
+ pro_craft/prompt_craft/async_.py,sha256=AkHU06zJE0gVLJC1s_5ViQ3htO0hzaqLFkzpIjieh4w,43191
10
10
  pro_craft/prompt_craft/new.py,sha256=ULjGGl95vmHrOs7XECJGlaqj1NE9BypE5WnFYhGugRY,25903
11
11
  pro_craft/prompt_craft/sync.py,sha256=4bms8Qvzq5QqgwHWwiyjrcl7hdkSqE7Kne5s3Ex8bBU,26217
12
12
  pro_craft/server/mcp/__init__.py,sha256=4dbl-lFcm0r2tkOP04OxqiZG2jR-rqF181qi2AfU6UA,123
13
13
  pro_craft/server/mcp/models.py,sha256=0QlohI7aSVjYjMdXK9Rq19Dp7b2LnjLKIiArDzI1ufg,1272
14
14
  pro_craft/server/mcp/prompt.py,sha256=zZ58zb422vhwoL_uYCVBdOwOR-xy69MLQ5tyVfbpBlU,2505
15
15
  pro_craft/server/router/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
16
- pro_craft/server/router/models.py,sha256=0LAFXsPQnDCUK_VNiS4xE_oXTyV5Mb0nzt_O5mWmne4,1276
17
- pro_craft/server/router/prompt.py,sha256=fDZu7bTE7dnztxxVcywNY5SY8YJrQh_llU3VGz979FA,6108
18
- pro_craft-0.1.52.dist-info/METADATA,sha256=VV8IXmZthjOBQ20zkQ18yeaeAh-0yweKkMDl09CX6ts,1750
19
- pro_craft-0.1.52.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
20
- pro_craft-0.1.52.dist-info/top_level.txt,sha256=yqYDHArnYMWpeCxkmGRwlL6sJtxiOUnYylLDx9EOgFg,10
21
- pro_craft-0.1.52.dist-info/RECORD,,
16
+ pro_craft/server/router/models.py,sha256=o60_qHjFIHwH3Pp6jNmg3V23GyFeXJXH-V6uBVoztXQ,1340
17
+ pro_craft/server/router/prompt.py,sha256=goKipoCX62BqtNXE2DSzpmqM2yzs2wvSzhvoDuuG5Ik,6862
18
+ pro_craft-0.1.54.dist-info/METADATA,sha256=Mz50Pcur2gMzh1--beNQsEYslXnaqfswZvjz6TX32jc,1782
19
+ pro_craft-0.1.54.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
20
+ pro_craft-0.1.54.dist-info/top_level.txt,sha256=yqYDHArnYMWpeCxkmGRwlL6sJtxiOUnYylLDx9EOgFg,10
21
+ pro_craft-0.1.54.dist-info/RECORD,,