Skip to main content

CallAI

CallAI是一个简单易用的OpenAI API封装库,提供了更友好的接口和功能,使开发者能够更方便地使用大型语言模型。

安装

pip install callai

主要特性

  • 兼容OpenAI官方API
  • 简化的调用接口
  • 支持会话管理
  • 内置函数调用功能
  • 支持流式响应

快速开始

基本用法

from callai import AI

# 初始化客户端
ai = AI(api_key="your-api-key", default_model="gpt-3.5-turbo")

# 简单问答
response = ai.ask("请介绍一下Python语言的特点")
print(response)

# 使用系统提示
response = ai.ask("我应该如何入门Python?", system_prompt="你是一位编程教育专家")
print(response)

# 流式输出
for chunk in ai.stream_ask("讲一个关于AI的故事"):
    print(chunk, end="", flush=True)

会话管理

# 创建会话
session = ai.session(system_prompt="你是一位AI助手")

# 在会话中交流
response = session.ask("你好,请问你是谁?")
print(response)

response = session.ask("我们刚才聊了什么?")
print(response)

# 保存会话
session.save_json("my_session.json")

# 加载会话
restored_session = ai.load_json("my_session.json")

函数调用

from callai import AI, Tool

# 定义工具函数
@Tool.register
def get_weather(location: str, unit: str = "celsius"):
    """获取指定位置的天气信息
    
    Args:
        location: 位置名称,如"北京"
        unit: 温度单位,可选值为"celsius"或"fahrenheit"
    """
    # 模拟天气API返回
    return {"temperature": 25, "condition": "晴天", "location": location, "unit": unit}

# 使用工具函数
ai = AI(api_key="your-api-key")
result = ai.call_with_tools("北京今天的天气怎么样?")
print(result)

API参考

详细的API文档请访问我们的官方网站。

许可证

本项目采用MIT许可证。详见LICENSE文件。

Metadata

Release files for callai 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for callai 0.2.1
File Size Uploaded Provenance Actions
callai-0.2.1.tar.gz 16.6 kB Without provenance Details for callai-0.2.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for callai 0.2.1
File Interpreter ABI Platform Actions
callai-0.2.1-py3-none-any.whl Python 3 none any Details for callai-0.2.1-py3-none-any.whl

Total release size: 35.3 kB

Release files / callai-0.2.1.tar.gz

Download URL callai-0.2.1.tar.gz
Size 16.6 kB
Tags Source
SHA-256 checksum
How to use checksums
6574e59df6df3885cd4634e2787a5d9ac6686750f5efb0fe830dc7fef5cfa6d3
BLAKE2b-256 checksum
How to use checksums
bf7bbd71df633c51a8e63690e4813a277a359da3b61ff64ec045ef30c5df7641
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.2

Release files / callai-0.2.1-py3-none-any.whl

Download URL callai-0.2.1-py3-none-any.whl
Size 18.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
834e2eb80be96a40b0cbc089b3b2b381730bd7efcdeff2b7a2c72cf8bfaf3efb
BLAKE2b-256 checksum
How to use checksums
b9e5e0bf905b0f3bc8759e0a05a99bf07de9da240058dd514566817b47bf31d8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.2

Security for callai 0.2.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page