pangukitsappdev.api package¶
Subpackages¶
- pangukitsappdev.api.agent package
- Submodules
- pangukitsappdev.api.agent.base module
AbstractAgent
AbstractAgent.add_listener()
AbstractAgent.add_tool()
AbstractAgent.clear_tool()
AbstractAgent.convert_message_to_dict()
AbstractAgent.get_system_prompt()
AbstractAgent.get_tool()
AbstractAgent.init_tool_from_retriever()
AbstractAgent.levenshtein_distance()
AbstractAgent.need_interrupt()
AbstractAgent.notice_session_end()
AbstractAgent.notice_session_iteration()
AbstractAgent.notice_session_start()
AbstractAgent.react()
AbstractAgent.remove_start()
AbstractAgent.remove_tool()
AbstractAgent.run()
AbstractAgent.run_step()
AbstractAgent.set_max_iterations()
AbstractAgent.set_stream_callback()
AbstractAgent.set_tool_retriever()
AbstractAgent.sub_str_after()
AbstractAgent.sub_str_before()
AbstractAgent.sub_str_between()
AbstractAgent.tool_execute()
Agent
AgentListener
AgentSessionHelper
AgentStreamCallBack
- Module contents
- pangukitsappdev.api.doc_split package
- pangukitsappdev.api.embeddings package
- pangukitsappdev.api.llms package
- Submodules
- pangukitsappdev.api.llms.base module
AbstractLLMApi
AbstractLLMApi.ask()
AbstractLLMApi.ask_for_object()
AbstractLLMApi.create_chat_llm_with()
AbstractLLMApi.default_create_chat_llm_func()
AbstractLLMApi.do_create_chat_llm()
AbstractLLMApi.get_llm_config()
AbstractLLMApi.need_add_new_system_message()
AbstractLLMApi.parse_llm_response()
AbstractLLMApi.set_cache()
AbstractLLMApi.set_callback()
ConversationMessage
LLMApi
LLMApiAdapter
Role
convert_message_to_req()
get_llm_params()
- pangukitsappdev.api.llms.factory module
- pangukitsappdev.api.llms.llm_config module
- Module contents
- pangukitsappdev.api.memory package
- pangukitsappdev.api.prompt package
- Submodules
- pangukitsappdev.api.prompt.prompt_config module
PromptConfig
PromptTemplatesFileConfig
PromptTemplatesFileConfig.agent_react
PromptTemplatesFileConfig.agent_react_pangu
PromptTemplatesFileConfig.agent_react_pangu_2
PromptTemplatesFileConfig.agent_react_pangu_unify
PromptTemplatesFileConfig.agent_tool_desc
PromptTemplatesFileConfig.agent_tool_desc_pangu
PromptTemplatesFileConfig.agent_tool_desc_pangu_2
PromptTemplatesFileConfig.agent_tool_json_schema
PromptTemplatesFileConfig.agent_tool_simple_schema
PromptTemplatesFileConfig.conversation_default
PromptTemplatesFileConfig.documents_mapreduce_map
PromptTemplatesFileConfig.documents_mapreduce_reduce
PromptTemplatesFileConfig.documents_refine_combine
PromptTemplatesFileConfig.documents_refine_qa
PromptTemplatesFileConfig.documents_stuff
PromptTemplatesFileConfig.documents_summarize_mapreduce_map
PromptTemplatesFileConfig.documents_summarize_mapreduce_reduce
PromptTemplatesFileConfig.documents_summarize_refine_combine
PromptTemplatesFileConfig.documents_summarize_refine_qa
PromptTemplatesFileConfig.documents_summarize_stuff
PromptTemplatesFileConfig.memory_summary
PromptTemplatesFileConfig.question_long_answer
PromptTemplatesFileConfig.question_qa_with_sources_stuff
PromptTemplatesFileConfig.question_question_only
PromptTemplatesFileConfig.question_short_answer
PromptTemplatesFileConfig.skill_agent_session_summary
PromptTemplatesFileConfig.skill_conversation_rewrite
PromptTemplatesFileConfig.system_out_put_parser
- Module contents
- pangukitsappdev.api.retriever package
- Submodules
- pangukitsappdev.api.retriever.base module
AbstractToolRetriever
AbstractToolRetriever.RETRIEVER_SCORE_DEFAULT
AbstractToolRetriever.RETRIEVER_SIZE_DEFAULT
AbstractToolRetriever.add_tools_from_metadata()
AbstractToolRetriever.get_query_preprocessor()
AbstractToolRetriever.instantiation_tool()
AbstractToolRetriever.remove()
AbstractToolRetriever.search()
AbstractToolRetriever.set_query_preprocessor()
ToolRetriever
- pangukitsappdev.api.retriever.retriever_config module
- Module contents
- pangukitsappdev.api.skill package
- pangukitsappdev.api.tool package
- Submodules
- pangukitsappdev.api.tool.base module
AbstractTool
AbstractTool.func
AbstractTool.get_input_schema()
AbstractTool.get_output_schema()
AbstractTool.get_pangu_function()
AbstractTool.get_tool_desc()
AbstractTool.get_tool_id()
AbstractTool.input_desc
AbstractTool.input_type
AbstractTool.output_desc
AbstractTool.output_type
AbstractTool.principle
AbstractTool.return_type
PanguFunction
- Module contents
Submodules¶
pangukitsappdev.api.common_config module¶
- class pangukitsappdev.api.common_config.HttpConfig(env_prefix='sdk.proxy', *, proxy_default_enabled: Optional[bool] = False, proxy_enabled: Optional[bool] = None, proxy_url: Optional[str] = None, proxy_user: Optional[str] = None, proxy_passwd: Optional[str] = None)¶
-
http相关配置 Attributes:
proxy_default_enabled:默认代理开关 proxy_enabled: 优先模块代理开关,模块未定义则使用默认代理开关 proxy_url: 代理host地址:代理端口 proxy_user: 认证用户 proxy_passwd: 认证密码
- classmethod get_proxy_enabled(v, values)¶
- get_proxy_url() str ¶
- proxy_default_enabled: Optional[bool]¶
- proxy_enabled: Optional[bool]¶
- proxy_passwd: Optional[str]¶
- proxy_url: Optional[str]¶
- proxy_user: Optional[str]¶
- requests_proxies() dict ¶
构造requests请求时用的代理配置 Returns:
dict
- class pangukitsappdev.api.common_config.IAMConfig(_env_file: Optional[Union[str, PathLike, List[Union[str, PathLike]], Tuple[Union[str, PathLike], ...]]] = '<object object>', _env_file_encoding: Optional[str] = None, _env_nested_delimiter: Optional[str] = None, _secrets_dir: Optional[Union[str, PathLike]] = None, *, iam_disabled: Optional[bool] = None, iam_ak: Optional[str] = None, iam_sk: Optional[str] = None, iam_url: Optional[str] = None, iam_domain: Optional[str] = None, iam_user: Optional[str] = None, iam_pwd: Optional[str] = None, project_name: Optional[str] = None, expire_duration_millis: int = 82800000, x_auth_token: Optional[str] = None, http_config: HttpConfig = None)¶
-
IAM的配置参数
- expire_duration_millis: int¶
- http_config: HttpConfig¶
- iam_ak: Optional[str]¶
- iam_disabled: Optional[bool]¶
- iam_domain: Optional[str]¶
- iam_pwd: Optional[str]¶
- iam_sk: Optional[str]¶
- iam_url: Optional[str]¶
- iam_user: Optional[str]¶
- project_name: Optional[str]¶
- x_auth_token: Optional[str]¶
- class pangukitsappdev.api.common_config.IAMConfigWrapper(env_prefix: str = 'sdk.iam')¶
基类:
object
- get_iam_config()¶
- class pangukitsappdev.api.common_config.OpenAIConfig(_env_file: Optional[Union[str, PathLike, List[Union[str, PathLike]], Tuple[Union[str, PathLike], ...]]] = '<object object>', _env_file_encoding: Optional[str] = None, _env_nested_delimiter: Optional[str] = None, _secrets_dir: Optional[Union[str, PathLike]] = None, *, openai_base_url: Optional[str] = None, openai_key: Optional[str] = None, http_config: HttpConfig = None)¶
-
- http_config: HttpConfig¶
- openai_base_url: Optional[str]¶
- openai_key: Optional[str]¶
- class pangukitsappdev.api.common_config.ServerInfo(_env_file: Optional[Union[str, PathLike, List[Union[str, PathLike]], Tuple[Union[str, PathLike], ...]]] = '<object object>', _env_file_encoding: Optional[str] = None, _env_nested_delimiter: Optional[str] = None, _secrets_dir: Optional[Union[str, PathLike]] = None, *, url: Optional[str] = None, user: Optional[str] = None, password: Optional[str] = None)¶
-
存储服务器链接相关信息 Attributes:
url: 主机ip列表:访问端口 user: 用户 password: 密钥
- get_http_urls() [<class 'str'>] ¶
- get_urls() [<class 'str'>] ¶
- has_auth() bool ¶
- password: Optional[str]¶
- url: Optional[str]¶
- user: Optional[str]¶
pangukitsappdev.api.config_loader module¶
- class pangukitsappdev.api.config_loader.SdkBaseSettings(_env_file: Optional[Union[str, PathLike, List[Union[str, PathLike]], Tuple[Union[str, PathLike], ...]]] = '<object object>', _env_file_encoding: Optional[str] = None, _env_nested_delimiter: Optional[str] = None, _secrets_dir: Optional[Union[str, PathLike]] = None)¶
基类:
BaseSettings
Sdk的配置顶层类,覆盖了Pydantic的一些默认行为。通过在初始化的时候传递env_prefix参数来指定配置加载的key前缀, 传递env_prefix_ident_fields参数,用于指定env_prefix对指定field生效,默认None对全部field生效
- class Config¶
基类:
object
- classmethod customise_sources(init_settings: Callable[[BaseSettings], Dict[str, Any]], env_settings: Callable[[BaseSettings], Dict[str, Any]], file_secret_settings: Callable[[BaseSettings], Dict[str, Any]]) Tuple[Callable[[BaseSettings], Dict[str, Any]], ...] ¶
- env_file = None¶
- extra = 'ignore'¶
- class pangukitsappdev.api.config_loader.SdkEnvSettingsSource(env_file: Optional[Union[str, PathLike, List[Union[str, PathLike]], Tuple[Union[str, PathLike], ...]]], env_file_encoding: Optional[str], env_nested_delimiter: Optional[str] = None, env_prefix_len: int = 0, env_prefix: Optional[str] = None, env_name_joint: str = '.', env_prefix_ident_fields: Optional[list] = None)¶
基类:
EnvSettingsSource
主干逻辑是__call__方法,结构上基本上和EnvSettingsSource保持一致。区别点:
dotenv_vars配置文件的配置优先级高于环境变量.
增加env_prefix成员变量,用来实现匹配不同的前缀做配置加载
增加env_name_joint成员变量,默认使用”.”连接env_prefix和env_name
增加config_decryptor类变量用来做配置的的解密,使用者可以自行配置。
增加env_prefix_ident_fields对指定元素生效,默认None
- config_decryptor: Callable[[str, str], str] = None¶
- classmethod decrypt_if_need(config_value: str) str ¶
- env_file: Optional[Union[str, PathLike, List[Union[str, PathLike]], Tuple[Union[str, PathLike], ...]]]¶
- env_file_encoding: Optional[str]¶
- env_name_joint¶
- env_nested_delimiter: Optional[str]¶
- env_prefix¶
- env_prefix_ident_fields¶
- env_prefix_len: int¶
- classmethod load_config_decryptor(import_path: str) Callable[[str, str], str] ¶
从import_path加载config_decryptor 加载自定义的config_decryptor。比如自定义的config_decryptor使用如下:
from your.module import decrypt_func
plain_text = decrypt_func(key_id, cipher)
则等同使用如下方法加载:
decrypt_func = load_config_decryptor(“your.module.decrypt_func”)
plain_text = decrypt_func(key_id, cipher)
该方法用来初始化类变量:SdkEnvSettingsSource.config_decryptor。只会初始化一次 Args:
import_path: 自定义config_decryptor的路径,基本格式,{path.to.module}.{function_name}
- Returns:
一个可调用的方法对象
pangukitsappdev.api.crypto_util module¶
SCC加解密工具类 Usage: from crypto_util import crypto_util
- class pangukitsappdev.api.crypto_util.SccCryptoAPIWrapper(scc_conf_path=None)¶
基类:
object
SCC加解密Api 需要在机器上安装华为云的scc安全组件后使用这个类。内部封装了CryptoAPI(scc组件安装后获的),在SccCryptoAPIWrapper新创建实例时会对 CryptoAPI做初始化。
- Attributes:
scc_conf_path: scc的配置路径 _scc_api: 懒加载的CryptoAPI类实例,初始化的时候是None
- decrypt(cipher: str) str ¶
解密 :param cipher: 密文 :return: 解密后的明文
- encrypt(plain_text: str) str ¶
加密 :param plain_text: 明文敏感信息 :return: 加密后的密文
- pangukitsappdev.api.crypto_util.decrypt(key_id: str, cipher: str) str ¶