No project description provided
Project description
ask-api
EN DOC
说明
ask-api 是一个python框架,借助LLM(目前支持chatgpt-api)模型的代码理解能力,让你能够与你的python代码对话,提供包括但不限于如下的能力:
- 通过提问了解函数的用途。
- 直接通过自然语言来执行函数。
- 将操作过程中的各种异常信息,通过自然语言的方式告知用户。
- 与函数进行其他自由对话。
安装(待完善)
</code></pre>
<h4><a href="#user-content-开发计划进行中" aria-hidden="true" class="anchor" id="user-content-开发计划进行中"></a>开发计划(进行中)</h4>
<ul>
<li><input type="checkbox" checked="" disabled="" /> 基于openai的chatgpt-api,支持对python函数进行提问,了解函数的用途。</li>
<li><input type="checkbox" checked="" disabled="" /> 支持中文以及英文两种类型的prompt。</li>
<li><input type="checkbox" disabled="" /> 通过pip安装。</li>
<li><input type="checkbox" disabled="" /> 支持自定义的prompt。</li>
<li><input type="checkbox" checked="" disabled="" /> 支持通过自然语言命令来执行函数。</li>
<li><input type="checkbox" disabled="" /> 支持其他LLM模型或api作为底层算法支持</li>
</ul>
<h4><a href="#user-content-示例持续完善中" aria-hidden="true" class="anchor" id="user-content-示例持续完善中"></a>示例(持续完善中)</h4>
<ul>
<li>更多细节,请参考<a href="./examples/zh_askapi_example.ipynb">中文示例</a></li>
<li>示例函数</li>
</ul>
<pre><code class="language-python"># 示例函数,给定url,下载数据并保存至指定目录
import wget
import os
BASE_PATH = "./tmp/"
def download_data(url, save_path = None) -> str:
"""下载数据并保存至指定目录
Args:
url (_type_): 需要下载的数据的url
save_path (_type_): 保存数据的目录
Returns:
str: 保存数据的目录
"""
if save_path is None:
save_path = wget.detect_filename(url)
if not os.path.exists(BASE_PATH):
os.makedirs(BASE_PATH)
save_path = f'{BASE_PATH}/{save_path}'
wget.download(url, save_path)
return save_path
- 利用ask-api对函数进行提问,了解函数的用途
from ask_api.ask_api import ask_func
# 获取函数的功能说明
session = ask_func(download_data, message="", mode='desc')
print("*" * 100)
print(session.get_current())
- 利用ask-api,直接通过自然语言来执行函数
# 使用自然语言调用函数
session = ask_func(download_data, message="请帮我下载这个数据:https://github.com/redis/redis/archive/7.0.9.tar.gz", mode="execute")
print(session.get_current())
- 函数执行为异步执行,可以通过wait_task方法等待函数执行完成
# get result of the function task
from ask_api.util.askapi_asyn import wait_task
task = session.get_current().get_task()
if task is None:
print("task is complete!")
print(session.get_current())
else:
print("task is running")
result = wait_task(task)
print(result)
- 异常命令的处理
# 异常指令处理
session = ask_func(download_data, message="请帮我下载", mode="execute")
print(session.get_current())
- 函数执行异常的处理
# 任务执行中异常处理
session = ask_func(download_data, message="请帮我下载这个数据:xxx.xxx", mode="execute")
print("*" * 100)
print(session.get_current())
print("*" * 100)
task = session.get_current().get_task()
result_message = wait_task(task)
print(result_message)
- 与函数进行其他自由对话(TODO)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
ask-api-0.1.0.tar.gz
(15.4 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
ask_api-0.1.0-py3-none-any.whl
(17.8 kB
view details)
File details
Details for the file ask-api-0.1.0.tar.gz.
File metadata
- Download URL: ask-api-0.1.0.tar.gz
- Upload date:
- Size: 15.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.16
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0e556337617dab22ecb18d22152b6ee6305dd874c9b7383f254f42377a425250
|
|
| MD5 |
5dc2fc8d406dce2ae20f3f4b24308999
|
|
| BLAKE2b-256 |
8029c22369577315d8769f7ca9d84df9299c95438b3388b8a57c9de378e7db2f
|
File details
Details for the file ask_api-0.1.0-py3-none-any.whl.
File metadata
- Download URL: ask_api-0.1.0-py3-none-any.whl
- Upload date:
- Size: 17.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.16
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b6ebab7a7df4a0c8825d5ea57a251da4128734437ca2db07e14dee6638eb1eba
|
|
| MD5 |
4f1bb69ab216034e6b912721617c60f4
|
|
| BLAKE2b-256 |
95e8f302ffc68e24014ab0c4d879c9fefffa3bd4db2f70b1d13c23d079c654bf
|