Metadata-Version: 2.2
Name: llm2dict
Version: 0.0.1
Summary: Enable large language models to output structured data.
Home-page: https://github.com/NNNINNN/llm2dict
Author: NNNINNN
Author-email: jianningwork@outlook.com
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.6
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: requests
Dynamic: author
Dynamic: author-email
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: home-page
Dynamic: requires-dist
Dynamic: requires-python
Dynamic: summary

# llm2dict

**llm2dict** 是一个 Python 包，旨在通过与大语言模型（LLM）的两次交互，将自然语言转换为结构化的 Python 字典或列表数据。这个包的核心功能是通过两次提问，第一次获取大语言模型的自然语言回答，第二次则提取特定格式的数据并将其转换为 Python 可执行的代码，最终返回结构化的数据(**dict**或**list**)。
 
## 功能特点  

在代码中使用 LLM 的输出时，通常需要对输出文本进行处理，流程如下：
**LLM->str->python_function(str)->dict**  
传统方式需要手动编写 Python 提取函数，但 LLM 的输出可能存在意外情况，难以完全匹配提取逻辑。此外，不同问题对应的提取格式也可能不同，增加了开发复杂度。  

**llm2dict** 将提取格式的任务交给 LLM 处理：

- 第一次提问：获取 LLM 的自然语言回答。 
- 第二次提问：让 LLM 根据第一次的回答和指定的数据结构，生成提取数据的 Python 代码。 
- 代码执行：自动执行生成的代码，返回结构化的数据。 

你只需提供输入问题和期望的数据结构，llm2dict 会完成剩余的工作，简化了从 LLM 输出到结构化数据的转换流程。

## 安装与使用  

你可以通过以下命令安装 **llm2dict** 包：
```bash
pip install llm2dict
```  
**使用示例**  
