bisheng-langchain 0.3.3.dev2__py3-none-any.whl → 0.3.4.dev1__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.
@@ -27,6 +27,7 @@ from langchain_core.language_models import BaseLanguageModel
27
27
  from langchain_core.tools import BaseTool, Tool
28
28
  from mypy_extensions import Arg, KwArg
29
29
  from bisheng_langchain.rag import BishengRAGTool
30
+ from bisheng_langchain.utils.azure_dalle_image_generator import AzureDallEWrapper
30
31
 
31
32
 
32
33
  def _get_current_time() -> BaseTool:
@@ -59,17 +60,22 @@ def _get_bing_search(**kwargs: Any) -> BaseTool:
59
60
 
60
61
 
61
62
  def _get_dalle_image_generator(**kwargs: Any) -> Tool:
62
- openai_api_key = kwargs.get('openai_api_key')
63
- openai_api_base = kwargs.get('openai_api_base')
64
- http_async_client = httpx.AsyncClient(proxies=kwargs.get('openai_proxy'))
65
- httpc_client = httpx.Client(proxies=kwargs.get('openai_proxy'))
63
+ if kwargs.get('openai_proxy'):
64
+ kwargs['http_async_client'] = httpx.AsyncClient(proxies=kwargs.get('openai_proxy'))
65
+ kwargs['http_client'] = httpx.Client(proxies=kwargs.get('openai_proxy'))
66
+
67
+ # 说明是azure的openai配置
68
+ if kwargs.get("azure_endpoint"):
69
+ kwargs['api_key'] = kwargs.pop('openai_api_key')
70
+ kwargs['api_version'] = kwargs.pop('openai_api_version')
71
+ return DallEImageGenerator(
72
+ api_wrapper=AzureDallEWrapper(**kwargs)
73
+ )
74
+
66
75
  return DallEImageGenerator(
67
76
  api_wrapper=DallEAPIWrapper(
68
77
  model='dall-e-3',
69
- api_key=openai_api_key,
70
- base_url=openai_api_base,
71
- http_client=httpc_client,
72
- http_async_client=http_async_client,
78
+ **kwargs
73
79
  )
74
80
  )
75
81
 
@@ -83,11 +89,16 @@ def _get_native_code_interpreter(**kwargs: Any) -> Tool:
83
89
 
84
90
 
85
91
  # 第二个list内填必填参数,第三个list内填可选参数
86
- _EXTRA_PARAM_TOOLS: Dict[str, Tuple[Callable[[KwArg(Any)], BaseTool], List[Optional[str]], List[Optional[str]]]] = { # type: ignore
87
- 'dalle_image_generator': (_get_dalle_image_generator, ['openai_api_key', 'openai_proxy'], []),
92
+ _EXTRA_PARAM_TOOLS: Dict[str, Tuple[Callable[[KwArg(Any)], BaseTool], List[Optional[str]], List[Optional[str]]]] = {
93
+ # type: ignore
94
+ 'dalle_image_generator': (_get_dalle_image_generator,
95
+ ['openai_api_key'],
96
+ ['openai_api_base', 'openai_proxy', 'azure_deployment', 'azure_endpoint', 'openai_api_version']),
88
97
  'bing_search': (_get_bing_search, ['bing_subscription_key', 'bing_search_url'], []),
89
98
  'bisheng_code_interpreter': (_get_native_code_interpreter, ["minio"], ['files']),
90
- 'bisheng_rag': (BishengRAGTool.get_rag_tool, ['name', 'description'], ['vector_store', 'keyword_store', 'llm', 'collection_name', 'max_content', 'sort_by_source_and_index']),
99
+ 'bisheng_rag': (BishengRAGTool.get_rag_tool, ['name', 'description'],
100
+ ['vector_store', 'keyword_store', 'llm', 'collection_name', 'max_content',
101
+ 'sort_by_source_and_index']),
91
102
  }
92
103
 
93
104
  _API_TOOLS: Dict[str, Tuple[Callable[[KwArg(Any)], BaseTool], List[str]]] = {**ALL_API_TOOLS} # type: ignore
@@ -114,10 +125,10 @@ def _handle_callbacks(callback_manager: Optional[BaseCallbackManager], callbacks
114
125
 
115
126
 
116
127
  def load_tools(
117
- tool_params: Dict[str, Dict[str, Any]],
118
- llm: Optional[BaseLanguageModel] = None,
119
- callbacks: Callbacks = None,
120
- **kwargs: Any,
128
+ tool_params: Dict[str, Dict[str, Any]],
129
+ llm: Optional[BaseLanguageModel] = None,
130
+ callbacks: Callbacks = None,
131
+ **kwargs: Any,
121
132
  ) -> List[BaseTool]:
122
133
  tools = []
123
134
  callbacks = _handle_callbacks(callback_manager=kwargs.get('callback_manager'), callbacks=callbacks)
@@ -171,7 +182,6 @@ def get_all_tool_names() -> List[str]:
171
182
 
172
183
 
173
184
  def get_tool_table():
174
-
175
185
  load_dotenv('.sql_env', override=True)
176
186
  db = pymysql.connect(
177
187
  host=os.getenv('MYSQL_HOST'),
@@ -184,7 +194,7 @@ def get_tool_table():
184
194
  cursor.execute("SELECT name, t.desc, tool_key, extra FROM t_gpts_tools as t;")
185
195
  results = cursor.fetchall()
186
196
  db.close()
187
-
197
+
188
198
  df = pd.DataFrame(
189
199
  columns=[
190
200
  '前端工具名',
@@ -10,6 +10,8 @@ from langchain_core.pydantic_v1 import BaseModel, Extra, Field, root_validator
10
10
  from langchain_core.tools import BaseTool
11
11
  from langchain_core.utils import get_from_dict_or_env, get_pydantic_field_names
12
12
 
13
+ from bisheng_langchain.utils.azure_dalle_image_generator import AzureDallEWrapper
14
+
13
15
  logger = logging.getLogger(__name__)
14
16
 
15
17
 
@@ -170,7 +172,7 @@ class DallEImageGenerator(BaseTool):
170
172
  "A wrapper around OpenAI DALL-E API. Useful for when you need to generate images from a text description. Input should be an image description."
171
173
  )
172
174
  args_schema: Type[BaseModel] = DallEInput
173
- api_wrapper: DallEAPIWrapper
175
+ api_wrapper: DallEAPIWrapper | AzureDallEWrapper
174
176
 
175
177
  def _run(
176
178
  self,
@@ -127,12 +127,9 @@ class AzureDallEWrapper(DallEAPIWrapper):
127
127
  values['default_query'],
128
128
  }
129
129
  if not values.get('client'):
130
- sync_specific = {'http_client': values['http_client']}
131
- values['client'] = openai.AzureOpenAI(**client_params, **sync_specific).images
130
+ values['client'] = openai.AzureOpenAI(**client_params).images
132
131
  if not values.get('async_client'):
133
- async_specific = {'http_client': values['http_async_client']}
134
- values['async_client'] = openai.AsyncAzureOpenAI(**client_params,
135
- **async_specific).images
132
+ values['async_client'] = openai.AsyncAzureOpenAI(**client_params).images
136
133
  return values
137
134
 
138
135
  @property
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: bisheng-langchain
3
- Version: 0.3.3.dev2
3
+ Version: 0.3.4.dev1
4
4
  Summary: bisheng langchain modules
5
5
  Home-page: https://github.com/dataelement/bisheng
6
6
  Author: DataElem
@@ -16,23 +16,23 @@ Classifier: License :: OSI Approved :: Apache Software License
16
16
  Classifier: Operating System :: OS Independent
17
17
  Requires-Python: >=3.6
18
18
  Description-Content-Type: text/markdown
19
- Requires-Dist: langchain ==0.1.12
19
+ Requires-Dist: langchain==0.1.12
20
20
  Requires-Dist: zhipuai
21
21
  Requires-Dist: websocket-client
22
22
  Requires-Dist: elasticsearch
23
- Requires-Dist: opencv-python ==4.5.5.64
24
- Requires-Dist: Pillow ==9.5.0
23
+ Requires-Dist: opencv-python==4.5.5.64
24
+ Requires-Dist: Pillow==9.5.0
25
25
  Requires-Dist: bisheng-pyautogen
26
- Requires-Dist: jieba ==0.42.1
27
- Requires-Dist: pydantic ==1.10.13
28
- Requires-Dist: pymupdf ==1.23.8
29
- Requires-Dist: shapely ==2.0.2
30
- Requires-Dist: filetype ==1.2.0
31
- Requires-Dist: langgraph ==0.0.50
32
- Requires-Dist: openai ==1.14.3
33
- Requires-Dist: langchain-openai ==0.1.0
34
- Requires-Dist: llama-index ==0.9.48
35
- Requires-Dist: bisheng-ragas ==1.0.0
26
+ Requires-Dist: jieba==0.42.1
27
+ Requires-Dist: pydantic==1.10.13
28
+ Requires-Dist: pymupdf==1.23.8
29
+ Requires-Dist: shapely==2.0.2
30
+ Requires-Dist: filetype==1.2.0
31
+ Requires-Dist: langgraph==0.0.50
32
+ Requires-Dist: openai==1.14.3
33
+ Requires-Dist: langchain-openai==0.1.0
34
+ Requires-Dist: llama-index==0.9.48
35
+ Requires-Dist: bisheng-ragas==1.0.0
36
36
 
37
37
  ## What is bisheng-langchain?
38
38
 
@@ -73,7 +73,7 @@ bisheng_langchain/gpts/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3
73
73
  bisheng_langchain/gpts/assistant.py,sha256=jPGVjPhqx-z4nvEHVsprWLqAVbO99Uus_GADAPASXQE,5438
74
74
  bisheng_langchain/gpts/auto_optimization.py,sha256=WNsC19rgvuDYQlSIaYThq5RqCbuobDbzCwAJW4Ksw0c,3626
75
75
  bisheng_langchain/gpts/auto_tool_selected.py,sha256=21WETf9o0YS-QEBwv3mmZRObKWszefQkXEqAA6KzoaM,1582
76
- bisheng_langchain/gpts/load_tools.py,sha256=LiiK1OqFu7Ki-F_Rhfi1rgp0wBQCSrTDdqsgwciTOIU,8099
76
+ bisheng_langchain/gpts/load_tools.py,sha256=U0DTN53bCXWZ26dlx9ZEPXO42Uvt72Q8mqKWcaBVQYo,8488
77
77
  bisheng_langchain/gpts/message_types.py,sha256=7EJOx62j9E1U67jxWgxE_I7a8IjAvvKANknXkD2gFm0,213
78
78
  bisheng_langchain/gpts/utils.py,sha256=t3YDxaJ0OYd6EKsek7PJFRYnsezwzEFK5oVU-PRbu5g,6671
79
79
  bisheng_langchain/gpts/agent_types/__init__.py,sha256=88tFt1GfrfIqa4hCg0cMJk7rTeUmCSSdiVhR41CW4rM,381
@@ -102,7 +102,7 @@ bisheng_langchain/gpts/tools/calculator/tool.py,sha256=iwGPE7jvxZg_jUL2Aq9HHwnRJ
102
102
  bisheng_langchain/gpts/tools/code_interpreter/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
103
103
  bisheng_langchain/gpts/tools/code_interpreter/tool.py,sha256=1VLkgngRR0k8YjA4eYkfPd1E7fD29tMKpqtCtn7WwYE,11443
104
104
  bisheng_langchain/gpts/tools/dalle_image_generator/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
105
- bisheng_langchain/gpts/tools/dalle_image_generator/tool.py,sha256=mhxdNNhBESjbOy30Rnp6hQhnrV4evQpv-B1fFXcU-68,7528
105
+ bisheng_langchain/gpts/tools/dalle_image_generator/tool.py,sha256=h_mSGn2fvw4wGufrqKYC3lI1LLo9Uu_rynDM88IonMA,7631
106
106
  bisheng_langchain/gpts/tools/get_current_time/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
107
107
  bisheng_langchain/gpts/tools/get_current_time/tool.py,sha256=3uvk7Yu07qhZy1sBrFMhGEwyxEGMB8vubizs9x-6DG8,801
108
108
  bisheng_langchain/input_output/__init__.py,sha256=sW_GB7MlrHYsqY1Meb_LeimQqNsMz1gH-00Tqb2BUyM,153
@@ -147,13 +147,13 @@ bisheng_langchain/retrievers/mix_es_vector.py,sha256=dSrrsuMPSgGiu181EOzACyIKiDX
147
147
  bisheng_langchain/sql/__init__.py,sha256=2arRtNQ-kUvIsy_8v_PrLxf5r9W-S7mbqptG_l4_1RE,88
148
148
  bisheng_langchain/sql/base.py,sha256=WNHCy16UoxvDbroHnJq8CsZ9ot4NGflCm8Bgiv45kks,6152
149
149
  bisheng_langchain/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
150
- bisheng_langchain/utils/azure_dalle_image_generator.py,sha256=wbOIrVX8lN8zZni0GjUpwKBESy0TmlqrGLZCY5PbUsM,6819
150
+ bisheng_langchain/utils/azure_dalle_image_generator.py,sha256=96-_nO4hDSwyPE4rSYop5SgJ-U9CE2un4bTdW0E5RGU,6582
151
151
  bisheng_langchain/utils/requests.py,sha256=vWGKyNTxApVeaVdKxqACfIT1Q8wMy-jC3kUv2Ce9Mzc,8688
152
152
  bisheng_langchain/vectorstores/__init__.py,sha256=zCZgDe7LyQ0iDkfcm5UJ5NxwKQSRHnqrsjx700Fy11M,213
153
153
  bisheng_langchain/vectorstores/elastic_keywords_search.py,sha256=Pm1rS50GJ0HWbjBsFDgs28SVuVbjGSRPOor6yJlnE7w,13347
154
154
  bisheng_langchain/vectorstores/milvus.py,sha256=8HHbIxoSbLYDFlFJSfmjLOfqGpOSZd24iVYWSYz3TX0,36637
155
155
  bisheng_langchain/vectorstores/retriever.py,sha256=hj4nAAl352EV_ANnU2OHJn7omCH3nBK82ydo14KqMH4,4353
156
- bisheng_langchain-0.3.3.dev2.dist-info/METADATA,sha256=9JMcguR6d_cAwkNX3ynYJi55rnk6PjZSqfUIXH9gnG4,2489
157
- bisheng_langchain-0.3.3.dev2.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
158
- bisheng_langchain-0.3.3.dev2.dist-info/top_level.txt,sha256=Z6pPNyCo4ihyr9iqGQbH8sJiC4dAUwA_mAyGRQB5_Fs,18
159
- bisheng_langchain-0.3.3.dev2.dist-info/RECORD,,
156
+ bisheng_langchain-0.3.4.dev1.dist-info/METADATA,sha256=wMwMyK4VrN7WiO_IYurW5jWRN_-oWfEgDzgIFgLoFbE,2476
157
+ bisheng_langchain-0.3.4.dev1.dist-info/WHEEL,sha256=eOLhNAGa2EW3wWl_TU484h7q1UNgy0JXjjoqKoxAAQc,92
158
+ bisheng_langchain-0.3.4.dev1.dist-info/top_level.txt,sha256=Z6pPNyCo4ihyr9iqGQbH8sJiC4dAUwA_mAyGRQB5_Fs,18
159
+ bisheng_langchain-0.3.4.dev1.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.43.0)
2
+ Generator: bdist_wheel (0.44.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5