feat: add example (#9)
authored-by: zhengweijun <weijun.zheng@aminer.cn>
This commit is contained in:
parent
624ad13163
commit
6ffee13759
104 changed files with 1382 additions and 469 deletions
330
Release-Note.md
330
Release-Note.md
|
|
@ -1,6 +1,196 @@
|
|||
# Release Notes
|
||||
|
||||
## v0.0.1a1 - Initial Release (2025-01-02)
|
||||
## v0.0.1b1 - Major Enhancements & Restructuring (2025-07-22)
|
||||
|
||||
🚀 **A comprehensive update focusing on developer experience, code organization, and expanded examples!**
|
||||
|
||||
This release brings significant improvements to the SDK structure, comprehensive examples for all features, and enhanced developer experience.
|
||||
|
||||
### 🎯 **Major Features Examples**
|
||||
|
||||
#### 📹 **Comprehensive Video Generation Examples**
|
||||
- **Complete Model Coverage**: Added examples for all supported video generation models:
|
||||
- `cogvideox-3`: Text-to-video, image-to-video, start-end frame video
|
||||
- `cogvideox-2`: Enhanced text-to-video generation
|
||||
- `viduq1-text`, `viduq1-image`, `viduq1-start-end`: VidU Q1 series models
|
||||
- `vidu2-image`, `vidu2-start-end`, `vidu2-reference`: VidU 2 series models
|
||||
- **Advanced Features**: Support for 4K resolution, 60fps, audio generation, and custom quality settings
|
||||
- **Async Task Management**: Comprehensive polling and timeout handling for video generation tasks
|
||||
|
||||
#### 🤖 **Agent Invocation System Examples**
|
||||
- **General Translation Agent**: Multi-language translation with streaming support
|
||||
- Supports 10 languages: English, Chinese, Japanese, Korean, French, German, Spanish, Russian, Arabic, Portuguese
|
||||
- Real-time streaming translation responses
|
||||
- **Special Effects Video Agent**: Advanced video creation with template support
|
||||
- Async task submission and result polling
|
||||
- Template-based video generation (e.g., "french_kiss" template)
|
||||
- Image input support for video effects
|
||||
|
||||
#### 🧠 **GLM-4 Model Integration Examples**
|
||||
- **Synchronous Calls**: Direct model invocation with web search tool integration
|
||||
- **Streaming Responses**: Real-time text generation with SSE support
|
||||
- **Asynchronous Operations**: Task-based async processing with result polling
|
||||
- **Tool Integration**: Built-in web search capabilities for enhanced responses
|
||||
|
||||
#### 🔍 **Web Search Examples**
|
||||
- **Advanced Search Filters**: Domain filtering, recency filtering, content size control
|
||||
- **Multiple Search Engines**: Support for different search engines including "search_pro"
|
||||
- **Configurable Results**: Customizable result count (1-50) and content detail level
|
||||
- **GLM-4 Integration**: Seamless integration with chat models for search-enhanced responses
|
||||
|
||||
### 🏗️ **Architecture & Code Organization**
|
||||
|
||||
#### 📁 **Module Structure Refactoring**
|
||||
- **API Resources Reorganization**:
|
||||
```
|
||||
src/zai/api_resource/
|
||||
├── embeddings/
|
||||
│ ├── __init__.py
|
||||
│ └── embeddings.py
|
||||
├── files/
|
||||
│ ├── __init__.py
|
||||
│ └── files.py
|
||||
├── images/
|
||||
│ ├── __init__.py
|
||||
│ └── images.py
|
||||
└── batch/
|
||||
├── __init__.py
|
||||
└── batches.py
|
||||
```
|
||||
|
||||
- **Type Definitions Reorganization**:
|
||||
```
|
||||
src/zai/types/
|
||||
├── batch/
|
||||
│ ├── __init__.py
|
||||
│ ├── batch.py
|
||||
│ ├── batch_create_params.py
|
||||
│ ├── batch_error.py
|
||||
│ ├── batch_list_params.py
|
||||
│ └── batch_request_counts.py
|
||||
├── image/
|
||||
│ ├── __init__.py
|
||||
│ └── image.py
|
||||
├── embeddings/
|
||||
│ ├── __init__.py
|
||||
│ └── embeddings.py
|
||||
└── [other organized modules...]
|
||||
```
|
||||
|
||||
#### 🔗 **Import System Overhaul**
|
||||
- **Absolute Imports**: Converted all relative imports (`from ..core`) to absolute imports (`from zai.core`)
|
||||
- **Centralized Exports**: Moved all `__all__` definitions from individual modules to `__init__.py` files
|
||||
- **Backward Compatibility**: Maintained full compatibility with existing import patterns
|
||||
- **Clean Dependencies**: Eliminated circular imports and improved module loading
|
||||
|
||||
### 🛠️ **Developer Experience Improvements**
|
||||
|
||||
#### ⚙️ **Environment Configuration**
|
||||
- **Enhanced .env Support**: Robust environment variable loading with `python-dotenv`
|
||||
- **Fallback Mechanisms**: Graceful fallback to system environment variables
|
||||
- **API Key Validation**: Comprehensive error handling for missing or invalid API keys
|
||||
- **Setup Guidance**: Clear instructions for environment configuration
|
||||
|
||||
#### 🌍 **Internationalization**
|
||||
- **Complete English Translation**: All Chinese content translated to English
|
||||
- Code comments and documentation
|
||||
- Print statements and user messages
|
||||
- Error messages and status updates
|
||||
- Example code and variable names
|
||||
- **Consistent Terminology**: Standardized technical terms across all examples
|
||||
|
||||
### 📚 **Comprehensive Example Suite**
|
||||
|
||||
#### 📖 **New Example Files**
|
||||
- **`examples/video_models_examples.py`**: Complete guide for all video generation models
|
||||
- **`examples/agent_examples.py`**: Agent invocation patterns and best practices
|
||||
- **`examples/glm4_example.py`**: GLM-4 model usage in all modes (sync, async, streaming)
|
||||
- **`examples/web_search_example.py`**: Web search integration and configuration
|
||||
- **`examples/video_generator.py`**: Enhanced async video generation (updated)
|
||||
|
||||
#### 🔧 **Enhanced Existing Examples**
|
||||
- **`examples/basic_usage.py`**: Maintained comprehensive basic SDK usage
|
||||
- **Error Handling**: Added proper exception handling across all examples
|
||||
- **Type Hints**: Enhanced type annotations for better IDE support
|
||||
- **Documentation**: Improved inline documentation and usage explanations
|
||||
|
||||
### 🐛 **Bug Fixes & Stability**
|
||||
|
||||
#### 🔧 **Import Resolution**
|
||||
- Fixed `ModuleNotFoundError` issues after module restructuring
|
||||
- Corrected import paths in `src/zai/_client.py` for batch operations
|
||||
- Resolved circular dependency issues in type definitions
|
||||
- Ensured backward compatibility for existing test imports
|
||||
|
||||
#### 🔑 **API Key Management**
|
||||
- Fixed API key loading from `.env` files
|
||||
- Enhanced error messages for authentication issues
|
||||
- Improved error handling for missing environment variables
|
||||
|
||||
#### ⏱️ **Async Operations**
|
||||
- Enhanced timeout and polling mechanisms for video generation
|
||||
- Improved error handling in async task management
|
||||
- Better exception handling for network and API errors
|
||||
|
||||
### 📋 **Technical Improvements**
|
||||
|
||||
#### 🏃♂️ **Performance Optimizations**
|
||||
- Optimized module loading with improved import structure
|
||||
- Reduced memory footprint through better resource management
|
||||
- Enhanced async operation handling in examples
|
||||
|
||||
#### 🛡️ **Code Quality**
|
||||
- Consistent error handling patterns across all modules
|
||||
- Enhanced type safety with comprehensive type hints
|
||||
- Improved code documentation and comments
|
||||
- Standardized coding conventions
|
||||
|
||||
### 📦 **Dependencies & Compatibility**
|
||||
|
||||
#### 📌 **New Optional Dependencies**
|
||||
- `python-dotenv`: For enhanced environment variable management
|
||||
- Maintained backward compatibility - all dependencies remain optional
|
||||
|
||||
#### 🔄 **Python Version Support**
|
||||
- Continued support for Python 3.8, 3.9, 3.10, 3.11, 3.12
|
||||
- Enhanced async/await compatibility
|
||||
- Cross-platform stability improvements
|
||||
|
||||
### 🚀 **Migration Guide**
|
||||
|
||||
#### ✅ **For Existing Users**
|
||||
1. **No Breaking Changes**: All existing code continues to work without modifications
|
||||
2. **Optional Enhancements**: Consider adding `.env` file for API key management
|
||||
3. **New Examples**: Explore new example files for advanced usage patterns
|
||||
4. **Import Compatibility**: All existing imports remain functional
|
||||
|
||||
#### 📝 **Recommended Updates**
|
||||
```python
|
||||
# Before (still works)
|
||||
from zai import ZaiClient
|
||||
client = ZaiClient(api_key="your-key")
|
||||
|
||||
# Enhanced (recommended)
|
||||
import os
|
||||
from zai import ZaiClient
|
||||
from dotenv import load_dotenv
|
||||
|
||||
load_dotenv()
|
||||
api_key = os.getenv('ZAI_API_KEY')
|
||||
client = ZaiClient(api_key=api_key)
|
||||
```
|
||||
|
||||
### 🔮 **What's Coming Next**
|
||||
|
||||
- Additional video generation models and features
|
||||
- Enhanced streaming capabilities for all APIs
|
||||
- More agent templates and scenarios
|
||||
- Performance optimizations for large-scale usage
|
||||
- Extended tool integrations
|
||||
|
||||
---
|
||||
|
||||
## v0.0.1a1 - Initial Release (2025-07-14)
|
||||
|
||||
🎉 **Welcome to the first release of the Z.ai Python SDK!**
|
||||
|
||||
|
|
@ -121,135 +311,17 @@ This initial release establishes the foundation for Z.ai's Python SDK. Future re
|
|||
|
||||
## Migration Guide
|
||||
|
||||
*This is the initial release - no migration needed!*
|
||||
### From v0.0.1a1 to v0.0.1b1
|
||||
*No breaking changes - all existing code continues to work!*
|
||||
|
||||
For future versions, migration guides will be provided here to help you upgrade smoothly.
|
||||
**Optional Enhancements:**
|
||||
1. Add `.env` file support for better API key management
|
||||
2. Explore new example files for advanced usage patterns
|
||||
3. Consider using the new agent invocation examples
|
||||
4. Try the comprehensive video generation examples
|
||||
|
||||
For future versions, detailed migration guides will be provided here to help you upgrade smoothly.
|
||||
|
||||
---
|
||||
|
||||
# 版本更新
|
||||
|
||||
## v0.0.1a1 - 首次发布 (2025-07-15)
|
||||
|
||||
🎉 **欢迎使用 Z.ai Python SDK 的首个版本!**
|
||||
|
||||
这个初始版本通过现代化、类型安全的 Python SDK 提供了对 Z.ai 强大 AI 能力的全面访问。
|
||||
|
||||
### ✨ 核心功能
|
||||
|
||||
#### 🤖 **对话补全**
|
||||
- **标准对话**: 支持 `glm-4`、`charglm-3` 等多种模型的对话补全
|
||||
- **流式支持**: 实时流式响应,适用于交互式应用
|
||||
- **工具调用**: 函数调用能力,增强 AI 交互体验
|
||||
- **角色扮演**: 支持基于 `charglm-3` 模型的角色对话
|
||||
- **多模态对话**: 支持图像理解的视觉模型
|
||||
|
||||
#### 🧠 **向量嵌入**
|
||||
- **文本嵌入**: 生成高质量的文本向量嵌入
|
||||
- **可配置维度**: 自定义嵌入向量维度
|
||||
- **批量处理**: 单次请求支持多个输入
|
||||
|
||||
#### 🎥 **视频生成**
|
||||
- **文本生成视频**: 从文本提示生成视频
|
||||
- **图像生成视频**: 从图像输入创建视频
|
||||
- **参数可定制**: 控制质量、时长、帧率和尺寸
|
||||
- **音频支持**: 可选的视频音频生成
|
||||
|
||||
#### 🎵 **音频处理**
|
||||
- **语音转录**: 将音频文件转换为文本
|
||||
- **多格式支持**: 支持各种音频文件格式
|
||||
|
||||
#### 🤝 **智能助手 API**
|
||||
- **对话管理**: 结构化对话处理
|
||||
- **流式对话**: 实时助手交互
|
||||
- **元数据支持**: 丰富的对话上下文和用户信息
|
||||
|
||||
#### 🔧 **高级工具**
|
||||
- **网络搜索**: 集成的网络搜索功能
|
||||
- **文件管理**: 上传、下载和管理文件
|
||||
- **批量操作**: 多请求的高效批量处理
|
||||
- **知识库**: 知识管理和检索
|
||||
- **内容审核**: 内置内容安全和审核
|
||||
- **图像生成**: AI 驱动的图像创建
|
||||
- **模型微调**: 自定义模型训练功能
|
||||
|
||||
### 🛡️ **开发者体验**
|
||||
|
||||
#### **类型安全**
|
||||
- 所有 API 的完整类型注解
|
||||
- 完整的 IDE 支持,包括自动补全和类型检查
|
||||
- 基于 Pydantic 的请求/响应验证
|
||||
|
||||
#### **错误处理**
|
||||
- 针对不同失败场景的全面错误类型
|
||||
- 详细的错误消息和调试信息
|
||||
- 可配置设置的自动重试机制
|
||||
|
||||
#### **性能与可靠性**
|
||||
- 内置连接池和请求优化
|
||||
- 可配置的超时和重试策略
|
||||
- 高效的资源管理
|
||||
|
||||
#### **安全性**
|
||||
- 安全的 API 密钥管理
|
||||
- 带安全控制的可选令牌缓存
|
||||
- 内置身份验证处理
|
||||
|
||||
### 📋 **技术规格**
|
||||
|
||||
#### **Python 支持**
|
||||
- **Python 版本**: 3.8, 3.9, 3.10, 3.11, 3.12
|
||||
- **异步支持**: 完整的 async/await 兼容性
|
||||
- **跨平台**: Windows、macOS、Linux 支持
|
||||
|
||||
#### **依赖项**
|
||||
- `httpx` (≥0.23.0): 现代 HTTP 客户端
|
||||
- `pydantic` (≥1.9.0, <3.0): 数据验证和序列化
|
||||
- `typing-extensions` (≥4.0.0): 增强类型提示
|
||||
- `cachetools` (≥4.2.2): 缓存工具
|
||||
- `pyjwt` (~2.8.0): JWT 令牌处理
|
||||
|
||||
### 🚀 **快速开始**
|
||||
|
||||
```bash
|
||||
pip install zai-sdk
|
||||
```
|
||||
|
||||
```python
|
||||
from zai import ZaiClient
|
||||
|
||||
# 初始化客户端
|
||||
client = ZaiClient(api_key="your-api-key")
|
||||
|
||||
# 创建对话补全
|
||||
response = client.chat.completions.create(
|
||||
model="glm-4",
|
||||
messages=[{"role": "user", "content": "你好,Z.ai!"}]
|
||||
)
|
||||
|
||||
print(response.choices[0].message.content)
|
||||
```
|
||||
|
||||
### 📚 **文档与支持**
|
||||
|
||||
- **文档**: [Z.ai 开放平台](https://docs.z.ai/)
|
||||
- **示例**: `/examples` 目录中的全面示例
|
||||
- **社区**: GitHub Issues 和 Discussions
|
||||
- **联系**: user_feedback@z.ai
|
||||
|
||||
### 🔮 **未来规划**
|
||||
|
||||
这个初始版本为 Z.ai Python SDK 奠定了基础。未来版本将包括:
|
||||
- 更多模型支持
|
||||
- 增强的流式功能
|
||||
- 更多高级工具集成
|
||||
- 性能优化
|
||||
- 扩展的文档和示例
|
||||
|
||||
---
|
||||
|
||||
## 迁移指南
|
||||
|
||||
*这是初始版本 - 无需迁移!*
|
||||
|
||||
对于未来版本,我们将在此提供迁移指南,帮助您顺利升级。
|
||||
**Note**: This release significantly enhances the developer experience while maintaining full backward compatibility. All improvements are additive, ensuring your existing code continues to work seamlessly.
|
||||
136
examples/agent_examples.py
Normal file
136
examples/agent_examples.py
Normal file
|
|
@ -0,0 +1,136 @@
|
|||
import os
|
||||
from zai import ZaiClient
|
||||
import asyncio
|
||||
import time
|
||||
|
||||
# Try to load .env file
|
||||
try:
|
||||
from dotenv import load_dotenv
|
||||
load_dotenv()
|
||||
except ImportError:
|
||||
# If python-dotenv is not installed, continue using system environment variables
|
||||
pass
|
||||
|
||||
api_key = os.getenv('ZAI_API_KEY')
|
||||
if not api_key:
|
||||
print("Please set the ZAI_API_KEY environment variable or configure it in the .env file")
|
||||
exit()
|
||||
client = ZaiClient(api_key=api_key)
|
||||
|
||||
# ==================== General Translation Scenario ====================
|
||||
|
||||
def translate_text():
|
||||
"""General translation example"""
|
||||
response = client.agents.invoke(
|
||||
agent_id="general_translation",
|
||||
stream=True,
|
||||
messages=[
|
||||
{
|
||||
"role": "user",
|
||||
"content": [
|
||||
{
|
||||
"type": "text",
|
||||
"text": "Hello, how are you today?"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
custom_variables={
|
||||
"source_lang": "en", # Source language: en(English), zh(Chinese), ja(Japanese), ko(Korean), fr(French), de(German), es(Spanish), ru(Russian), ar(Arabic), pt(Portuguese)
|
||||
"target_lang": "zh" # Target language
|
||||
}
|
||||
)
|
||||
|
||||
print("Translation result:")
|
||||
for chunk in response:
|
||||
print(chunk, end="", flush=True)
|
||||
print()
|
||||
|
||||
# ==================== Special Effects Video Generation Scenario ====================
|
||||
|
||||
async def async_special_effects_video_example():
|
||||
"""
|
||||
Async special effects video generation example
|
||||
Includes result querying functionality
|
||||
"""
|
||||
print("=== Async Special Effects Video Generation Example ===")
|
||||
|
||||
# Submit async task
|
||||
print("Submitting async special effects video generation task...")
|
||||
response = client.agents.invoke(
|
||||
agent_id="vidu_template_agent",
|
||||
custom_variables={
|
||||
"template": "french_kiss"
|
||||
},
|
||||
messages=[{
|
||||
"role": "user",
|
||||
"content": [{
|
||||
"type": "text",
|
||||
"text": "The two figures in the painting gradually approach each other, then kiss passionately, alternating with deep and firm intensity"
|
||||
}, {
|
||||
"type": "image_url",
|
||||
"image_url": "https://i0.sinaimg.cn/edu/2011/1125/U4999P42DT20111125164101.jpg"
|
||||
}]
|
||||
}]
|
||||
)
|
||||
print(response)
|
||||
|
||||
# Get async task ID
|
||||
async_id = response.async_id
|
||||
if async_id:
|
||||
print(f"Async task ID: {async_id}")
|
||||
|
||||
# Poll for results
|
||||
max_wait_time = 300 # Maximum wait time 5 minutes
|
||||
start_time = time.time()
|
||||
|
||||
while True:
|
||||
if time.time() - start_time > max_wait_time:
|
||||
print("Query timeout")
|
||||
break
|
||||
|
||||
print(f"Querying task status... (waited {int(time.time() - start_time)} seconds)")
|
||||
result = client.agents.async_result(
|
||||
agent_id="vidu_template_agent",
|
||||
async_id=async_id
|
||||
)
|
||||
|
||||
# Check task status
|
||||
status = result.status
|
||||
if status == "success":
|
||||
print("Special effects video generation completed!")
|
||||
print(result)
|
||||
break
|
||||
elif status == "failed":
|
||||
print("Special effects video generation failed!")
|
||||
break
|
||||
elif status in ["pending"]:
|
||||
print(f"Task in progress, status: {status}")
|
||||
else:
|
||||
print(f"Unknown status: {status}")
|
||||
|
||||
# Wait 5 seconds before querying again
|
||||
await asyncio.sleep(5)
|
||||
else:
|
||||
print("Failed to get async task ID")
|
||||
|
||||
# ==================== Usage Examples ====================
|
||||
|
||||
async def main():
|
||||
print("=== Agent Quick Invocation Examples ===\n")
|
||||
|
||||
# 1. General translation
|
||||
print("1. General translation example:")
|
||||
translate_text()
|
||||
|
||||
print("\n" + "="*50 + "\n")
|
||||
|
||||
# 2. Special effects video generation
|
||||
print("2. Special effects video generation example:")
|
||||
result = await async_special_effects_video_example()
|
||||
print(result)
|
||||
|
||||
print("\n=== Examples completed ===")
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(main())
|
||||
93
examples/glm4_example.py
Normal file
93
examples/glm4_example.py
Normal file
|
|
@ -0,0 +1,93 @@
|
|||
import os
|
||||
import time
|
||||
from zai import ZaiClient
|
||||
|
||||
# Try to load .env file
|
||||
try:
|
||||
from dotenv import load_dotenv
|
||||
load_dotenv()
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
api_key = os.getenv('ZAI_API_KEY')
|
||||
if not api_key:
|
||||
print("Please set the ZAI_API_KEY environment variable or configure it in the .env file.")
|
||||
exit()
|
||||
|
||||
client = ZaiClient(api_key=api_key)
|
||||
|
||||
def stream_web_search_example():
|
||||
print("=== GLM-4 Streaming Web Search Example ===")
|
||||
tools = [{
|
||||
"type": "web_search",
|
||||
"web_search": {
|
||||
"enable": "True",
|
||||
"search_engine": "search_pro",
|
||||
"search_result": "True",
|
||||
"search_prompt": "You are a financial analyst. Please concisely summarize the key information from the web search: {{search_result}}, rank by importance and mark the source date. The current date is April 11, 2025.",
|
||||
"count": "5",
|
||||
"search_domain_filter": "www.sohu.com",
|
||||
"search_recency_filter": "noLimit",
|
||||
"content_size": "high"
|
||||
}
|
||||
}]
|
||||
messages = [{
|
||||
"role": "user",
|
||||
"content": "Major financial events, policy changes, and market data in April 2025."
|
||||
}]
|
||||
response = client.chat.completions.create(
|
||||
model="glm-4-air",
|
||||
messages=messages,
|
||||
tools=tools,
|
||||
stream=True
|
||||
)
|
||||
for chunk in response:
|
||||
print(chunk.choices[0].delta)
|
||||
|
||||
def sync_example():
|
||||
print("=== GLM-4 Synchronous Example ===")
|
||||
response = client.chat.completions.create(
|
||||
model="glm-4-plus",
|
||||
messages=[
|
||||
{"role": "system", "content": "You are a helpful assistant who provides professional, accurate, and insightful advice."},
|
||||
{"role": "user", "content": "I'm very interested in the planets of the solar system, especially Saturn. Please provide basic information about Saturn, including its size, composition, ring system, and any unique astronomical phenomena."},
|
||||
]
|
||||
)
|
||||
print(response)
|
||||
|
||||
def async_example():
|
||||
print("=== GLM-4 Async Example ===")
|
||||
response = client.chat.asyncCompletions.create(
|
||||
model="glm-4-plus",
|
||||
messages=[
|
||||
{
|
||||
"role": "user",
|
||||
"content": "As the king of fairy tales, please write a short fairy tale with the theme of always keeping a kind heart. The story should inspire children's interest in learning and imagination, and help them better understand and accept the morals and values contained in the story."
|
||||
}
|
||||
],
|
||||
)
|
||||
print(response)
|
||||
return response.id
|
||||
|
||||
def async_result_example(task_id):
|
||||
print("=== GLM-4 Async Result Polling Example ===")
|
||||
task_status = ''
|
||||
get_cnt = 0
|
||||
while task_status != 'SUCCESS' and task_status != 'FAILED' and get_cnt <= 40:
|
||||
result_response = client.chat.asyncCompletions.retrieve_completion_result(id=task_id)
|
||||
print(result_response)
|
||||
task_status = getattr(result_response, 'task_status', None)
|
||||
time.sleep(2)
|
||||
get_cnt += 1
|
||||
|
||||
def main():
|
||||
stream_web_search_example()
|
||||
print("\n" + "="*50 + "\n")
|
||||
sync_example()
|
||||
print("\n" + "="*50 + "\n")
|
||||
task_id = async_example()
|
||||
print("\n" + "="*50 + "\n")
|
||||
async_result_example(task_id)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
|
@ -4,6 +4,18 @@ import time
|
|||
|
||||
from zai import ZaiClient
|
||||
|
||||
# Try to load .env file
|
||||
try:
|
||||
from dotenv import load_dotenv
|
||||
load_dotenv()
|
||||
except ImportError:
|
||||
# If python-dotenv is not installed, continue using system environment variables
|
||||
pass
|
||||
|
||||
api_key = os.getenv('ZAI_API_KEY')
|
||||
if not api_key:
|
||||
print("Please set the ZAI_API_KEY environment variable or configure it in the .env file")
|
||||
exit()
|
||||
|
||||
class VideoGenerator:
|
||||
def __init__(self, api_key: str):
|
||||
|
|
@ -83,20 +95,10 @@ class VideoGenerator:
|
|||
|
||||
# Usage example
|
||||
async def main():
|
||||
# Please fill in your own API Key
|
||||
api_key = ''
|
||||
|
||||
if not api_key:
|
||||
api_key = os.getenv('ZAI_API_KEY')
|
||||
|
||||
if not api_key:
|
||||
print('Please set your API Key')
|
||||
return
|
||||
|
||||
generator = VideoGenerator()
|
||||
generator = VideoGenerator(api_key)
|
||||
try:
|
||||
result = await generator.video_generate(
|
||||
prompt='A beautiful sunset beach scene',
|
||||
prompt='A beautiful sunset beach scene with a beautiful girl',
|
||||
quality='quality',
|
||||
with_audio=True,
|
||||
)
|
||||
|
|
|
|||
547
examples/video_models_examples.py
Normal file
547
examples/video_models_examples.py
Normal file
|
|
@ -0,0 +1,547 @@
|
|||
import asyncio
|
||||
import os
|
||||
import time
|
||||
from typing import List, Optional
|
||||
|
||||
from zai import ZaiClient
|
||||
|
||||
# Try to load .env file
|
||||
try:
|
||||
from dotenv import load_dotenv
|
||||
load_dotenv()
|
||||
except ImportError:
|
||||
# If python-dotenv is not installed, continue using system environment variables
|
||||
pass
|
||||
|
||||
api_key = os.getenv('ZAI_API_KEY')
|
||||
if not api_key:
|
||||
print("Please set the ZAI_API_KEY environment variable or configure it in the .env file")
|
||||
exit()
|
||||
|
||||
class VideoModelsExamples:
|
||||
def __init__(self, api_key: str):
|
||||
self.client = ZaiClient(api_key=api_key)
|
||||
|
||||
async def cogvideox3_text_to_video(
|
||||
self,
|
||||
prompt: str,
|
||||
quality: str = "quality",
|
||||
with_audio: bool = True,
|
||||
size: str = "1920x1080",
|
||||
fps: int = 30,
|
||||
max_wait_time: int = 300,
|
||||
):
|
||||
"""
|
||||
cogvideox-3 text-to-video generation
|
||||
|
||||
Args:
|
||||
prompt: Video generation prompt
|
||||
quality: Output mode, "quality" for quality priority, "speed" for speed priority
|
||||
with_audio: Whether to include audio
|
||||
size: Video resolution, supports up to 4K (e.g., "3840x2160")
|
||||
fps: Frame rate, can be 30 or 60
|
||||
max_wait_time: Maximum wait time (seconds)
|
||||
"""
|
||||
print("=== cogvideox-3 Text-to-Video ===")
|
||||
try:
|
||||
response = self.client.videos.generations(
|
||||
model="cogvideox-3",
|
||||
prompt=prompt,
|
||||
quality=quality,
|
||||
with_audio=with_audio,
|
||||
size=size,
|
||||
fps=fps,
|
||||
)
|
||||
return await self._wait_for_completion(response.id, max_wait_time)
|
||||
except Exception as e:
|
||||
print(f"cogvideox-3 text-to-video failed: {e}")
|
||||
raise
|
||||
|
||||
async def cogvideox3_image_to_video(
|
||||
self,
|
||||
image_url: str,
|
||||
prompt: str,
|
||||
quality: str = "quality",
|
||||
with_audio: bool = True,
|
||||
size: str = "1920x1080",
|
||||
fps: int = 30,
|
||||
max_wait_time: int = 300,
|
||||
):
|
||||
"""
|
||||
cogvideox-3 image-to-video generation
|
||||
|
||||
Args:
|
||||
image_url: Image URL or Base64 encoding
|
||||
prompt: Video generation prompt
|
||||
quality: Output mode, "quality" for quality priority, "speed" for speed priority
|
||||
with_audio: Whether to include audio
|
||||
size: Video resolution, supports up to 4K (e.g., "3840x2160")
|
||||
fps: Frame rate, can be 30 or 60
|
||||
max_wait_time: Maximum wait time (seconds)
|
||||
"""
|
||||
print("=== cogvideox-3 Image-to-Video ===")
|
||||
try:
|
||||
response = self.client.videos.generations(
|
||||
model="cogvideox-3",
|
||||
image_url=image_url,
|
||||
prompt=prompt,
|
||||
quality=quality,
|
||||
with_audio=with_audio,
|
||||
size=size,
|
||||
fps=fps,
|
||||
)
|
||||
return await self._wait_for_completion(response.id, max_wait_time)
|
||||
except Exception as e:
|
||||
print(f"cogvideox-3 image-to-video failed: {e}")
|
||||
raise
|
||||
|
||||
async def cogvideox3_start_end_video(
|
||||
self,
|
||||
image_urls: List[str],
|
||||
prompt: str,
|
||||
quality: str = "quality",
|
||||
with_audio: bool = True,
|
||||
size: str = "1920x1080",
|
||||
fps: int = 30,
|
||||
max_wait_time: int = 300,
|
||||
):
|
||||
"""
|
||||
cogvideox-3 start-end frame video generation
|
||||
|
||||
Args:
|
||||
image_urls: List of start and end frame image URLs
|
||||
prompt: Video generation prompt
|
||||
quality: Output mode, "quality" for quality priority, "speed" for speed priority
|
||||
with_audio: Whether to include audio
|
||||
size: Video resolution, supports up to 4K (e.g., "3840x2160")
|
||||
fps: Frame rate, can be 30 or 60
|
||||
max_wait_time: Maximum wait time (seconds)
|
||||
"""
|
||||
print("=== cogvideox-3 Start-End Frame Video ===")
|
||||
try:
|
||||
response = self.client.videos.generations(
|
||||
model="cogvideox-3",
|
||||
image_url=image_urls,
|
||||
prompt=prompt,
|
||||
quality=quality,
|
||||
with_audio=with_audio,
|
||||
size=size,
|
||||
fps=fps,
|
||||
)
|
||||
return await self._wait_for_completion(response.id, max_wait_time)
|
||||
except Exception as e:
|
||||
print(f"cogvideox-3 start-end frame video failed: {e}")
|
||||
raise
|
||||
|
||||
async def cogvideox2_text_to_video(
|
||||
self,
|
||||
prompt: str,
|
||||
quality: str = "speed",
|
||||
with_audio: bool = True,
|
||||
max_wait_time: int = 300,
|
||||
):
|
||||
"""
|
||||
cogvideox-2 text-to-video generation
|
||||
|
||||
Args:
|
||||
prompt: Video generation prompt
|
||||
quality: Output mode, "quality" for quality priority, "speed" for speed priority
|
||||
with_audio: Whether to include audio
|
||||
max_wait_time: Maximum wait time (seconds)
|
||||
"""
|
||||
print("=== cogvideox-2 Text-to-Video ===")
|
||||
try:
|
||||
response = self.client.videos.generations(
|
||||
model="cogvideox-2",
|
||||
prompt=prompt,
|
||||
quality=quality,
|
||||
with_audio=with_audio,
|
||||
)
|
||||
return await self._wait_for_completion(response.id, max_wait_time)
|
||||
except Exception as e:
|
||||
print(f"cogvideox-2 text-to-video failed: {e}")
|
||||
raise
|
||||
|
||||
async def viduq1_text_to_video(
|
||||
self,
|
||||
prompt: str,
|
||||
quality: str = "quality",
|
||||
with_audio: bool = True,
|
||||
size: str = "1920x1080",
|
||||
fps: int = 30,
|
||||
max_wait_time: int = 300,
|
||||
):
|
||||
"""
|
||||
viduq1-text text-to-video generation
|
||||
|
||||
Args:
|
||||
prompt: Video generation prompt
|
||||
quality: Output mode, "quality" for quality priority, "speed" for speed priority
|
||||
with_audio: Whether to include audio
|
||||
size: Video resolution
|
||||
fps: Frame rate
|
||||
max_wait_time: Maximum wait time (seconds)
|
||||
"""
|
||||
print("=== viduq1-text Text-to-Video ===")
|
||||
try:
|
||||
response = self.client.videos.generations(
|
||||
model="viduq1-text",
|
||||
prompt=prompt,
|
||||
quality=quality,
|
||||
with_audio=with_audio,
|
||||
size=size,
|
||||
fps=fps,
|
||||
)
|
||||
return await self._wait_for_completion(response.id, max_wait_time)
|
||||
except Exception as e:
|
||||
print(f"viduq1-text text-to-video failed: {e}")
|
||||
raise
|
||||
|
||||
async def viduq1_image_to_video(
|
||||
self,
|
||||
image_url: str,
|
||||
prompt: str,
|
||||
quality: str = "quality",
|
||||
with_audio: bool = True,
|
||||
size: str = "1920x1080",
|
||||
fps: int = 30,
|
||||
max_wait_time: int = 300,
|
||||
):
|
||||
"""
|
||||
viduq1-image image-to-video generation
|
||||
|
||||
Args:
|
||||
image_url: Image URL or Base64 encoding
|
||||
prompt: Video generation prompt
|
||||
quality: Output mode, "quality" for quality priority, "speed" for speed priority
|
||||
with_audio: Whether to include audio
|
||||
size: Video resolution
|
||||
fps: Frame rate
|
||||
max_wait_time: Maximum wait time (seconds)
|
||||
"""
|
||||
print("=== viduq1-image Image-to-Video ===")
|
||||
try:
|
||||
response = self.client.videos.generations(
|
||||
model="viduq1-image",
|
||||
image_url=image_url,
|
||||
prompt=prompt,
|
||||
quality=quality,
|
||||
with_audio=with_audio,
|
||||
size=size,
|
||||
fps=fps,
|
||||
)
|
||||
return await self._wait_for_completion(response.id, max_wait_time)
|
||||
except Exception as e:
|
||||
print(f"viduq1-image image-to-video failed: {e}")
|
||||
raise
|
||||
|
||||
async def viduq1_start_end_video(
|
||||
self,
|
||||
image_urls: List[str],
|
||||
prompt: str,
|
||||
quality: str = "quality",
|
||||
with_audio: bool = True,
|
||||
size: str = "1920x1080",
|
||||
fps: int = 30,
|
||||
max_wait_time: int = 300,
|
||||
):
|
||||
"""
|
||||
viduq1-start-end start-end frame video generation
|
||||
|
||||
Args:
|
||||
image_urls: List of start and end frame image URLs
|
||||
prompt: Video generation prompt
|
||||
quality: Output mode, "quality" for quality priority, "speed" for speed priority
|
||||
with_audio: Whether to include audio
|
||||
size: Video resolution
|
||||
fps: Frame rate
|
||||
max_wait_time: Maximum wait time (seconds)
|
||||
"""
|
||||
print("=== viduq1-start-end Start-End Frame Video ===")
|
||||
try:
|
||||
response = self.client.videos.generations(
|
||||
model="viduq1-start-end",
|
||||
image_urls=image_urls,
|
||||
prompt=prompt,
|
||||
quality=quality,
|
||||
with_audio=with_audio,
|
||||
size=size,
|
||||
fps=fps,
|
||||
)
|
||||
return await self._wait_for_completion(response.id, max_wait_time)
|
||||
except Exception as e:
|
||||
print(f"viduq1-start-end start-end frame video failed: {e}")
|
||||
raise
|
||||
|
||||
async def vidu2_image_to_video(
|
||||
self,
|
||||
image_url: str,
|
||||
prompt: str,
|
||||
quality: str = "quality",
|
||||
with_audio: bool = True,
|
||||
size: str = "1920x1080",
|
||||
fps: int = 30,
|
||||
max_wait_time: int = 300,
|
||||
):
|
||||
"""
|
||||
vidu2-image image-to-video generation
|
||||
|
||||
Args:
|
||||
image_url: Image URL or Base64 encoding
|
||||
prompt: Video generation prompt
|
||||
quality: Output mode, "quality" for quality priority, "speed" for speed priority
|
||||
with_audio: Whether to include audio
|
||||
size: Video resolution
|
||||
fps: Frame rate
|
||||
max_wait_time: Maximum wait time (seconds)
|
||||
"""
|
||||
print("=== vidu2-image Image-to-Video ===")
|
||||
try:
|
||||
response = self.client.videos.generations(
|
||||
model="vidu2-image",
|
||||
image_url=image_url,
|
||||
prompt=prompt,
|
||||
quality=quality,
|
||||
with_audio=with_audio,
|
||||
size=size,
|
||||
fps=fps,
|
||||
)
|
||||
return await self._wait_for_completion(response.id, max_wait_time)
|
||||
except Exception as e:
|
||||
print(f"vidu2-image image-to-video failed: {e}")
|
||||
raise
|
||||
|
||||
async def vidu2_start_end_video(
|
||||
self,
|
||||
image_urls: List[str],
|
||||
prompt: str,
|
||||
quality: str = "quality",
|
||||
with_audio: bool = True,
|
||||
size: str = "1920x1080",
|
||||
fps: int = 30,
|
||||
max_wait_time: int = 300,
|
||||
):
|
||||
"""
|
||||
vidu2-start-end start-end frame video generation
|
||||
|
||||
Args:
|
||||
image_urls: List of start and end frame image URLs
|
||||
prompt: Video generation prompt
|
||||
quality: Output mode, "quality" for quality priority, "speed" for speed priority
|
||||
with_audio: Whether to include audio
|
||||
size: Video resolution
|
||||
fps: Frame rate
|
||||
max_wait_time: Maximum wait time (seconds)
|
||||
"""
|
||||
print("=== vidu2-start-end Start-End Frame Video ===")
|
||||
try:
|
||||
response = self.client.videos.generations(
|
||||
model="vidu2-start-end",
|
||||
image_urls=image_urls,
|
||||
prompt=prompt,
|
||||
quality=quality,
|
||||
with_audio=with_audio,
|
||||
size=size,
|
||||
fps=fps,
|
||||
)
|
||||
return await self._wait_for_completion(response.id, max_wait_time)
|
||||
except Exception as e:
|
||||
print(f"vidu2-start-end start-end frame video failed: {e}")
|
||||
raise
|
||||
|
||||
async def vidu2_reference_video(
|
||||
self,
|
||||
image_url: str,
|
||||
prompt: str,
|
||||
quality: str = "quality",
|
||||
with_audio: bool = True,
|
||||
size: str = "1920x1080",
|
||||
fps: int = 30,
|
||||
max_wait_time: int = 300,
|
||||
):
|
||||
"""
|
||||
vidu2-reference reference video generation
|
||||
|
||||
Args:
|
||||
image_url: Reference video URL
|
||||
prompt: Video generation prompt
|
||||
quality: Output mode, "quality" for quality priority, "speed" for speed priority
|
||||
with_audio: Whether to include audio
|
||||
size: Video resolution
|
||||
fps: Frame rate
|
||||
max_wait_time: Maximum wait time (seconds)
|
||||
"""
|
||||
print("=== vidu2-reference Reference Video Generation ===")
|
||||
try:
|
||||
response = self.client.videos.generations(
|
||||
model="vidu2-reference",
|
||||
image_url=image_url,
|
||||
prompt=prompt,
|
||||
quality=quality,
|
||||
with_audio=with_audio,
|
||||
size=size,
|
||||
fps=fps,
|
||||
)
|
||||
return await self._wait_for_completion(response.id, max_wait_time)
|
||||
except Exception as e:
|
||||
print(f"vidu2-reference reference video generation failed: {e}")
|
||||
raise
|
||||
|
||||
async def _wait_for_completion(self, task_id: str, max_wait_time: int = 300):
|
||||
"""
|
||||
Common method to wait for task completion
|
||||
"""
|
||||
start_time = time.time()
|
||||
|
||||
while True:
|
||||
# Check for timeout
|
||||
if time.time() - start_time > max_wait_time:
|
||||
raise TimeoutError(f"Video generation timeout, exceeded {max_wait_time} seconds")
|
||||
|
||||
# Get task result
|
||||
print(f"Querying task status... (waited {int(time.time() - start_time)} seconds)")
|
||||
result = self.client.videos.retrieve_videos_result(id=task_id)
|
||||
|
||||
print(f"Task status: {result}")
|
||||
|
||||
# Check if task is completed
|
||||
if hasattr(result, 'task_status'):
|
||||
if result.task_status == 'SUCCESS':
|
||||
print('Video generation completed!')
|
||||
return result
|
||||
elif result.task_status == 'FAIL':
|
||||
raise Exception(f'Video generation failed: {result}')
|
||||
elif result.task_status in ['PROCESSING', 'SUBMITTED']:
|
||||
print(f'Task in progress, status: {result.task_status}')
|
||||
else:
|
||||
print(f'Unknown status: {result.task_status}')
|
||||
else:
|
||||
# If no task_status field, check other possible status fields
|
||||
print(f'Checking result structure: {result}')
|
||||
|
||||
# Wait 5 seconds before querying again
|
||||
await asyncio.sleep(5)
|
||||
|
||||
|
||||
# Usage examples
|
||||
async def main():
|
||||
# Please fill in your API Key
|
||||
examples = VideoModelsExamples(api_key)
|
||||
|
||||
# Sample image and video URLs (please replace with actual URLs)
|
||||
sample_image_url = "https://i0.sinaimg.cn/edu/2011/1125/U4999P42DT20111125164101.jpg"
|
||||
sample_first_frame = "https://gd-hbimg.huaban.com/ccee58d77afe8f5e17a572246b1994f7e027657fe9e6-qD66In_fw1200webp"
|
||||
sample_last_frame = "https://gd-hbimg.huaban.com/cc2601d568a72d18d90b2cc7f1065b16b2d693f7fa3f7-hDAwNq_fw1200webp"
|
||||
ref_image_url = ["ref1", "ref2", "ref3"]
|
||||
|
||||
try:
|
||||
# 1. cogvideox-3 text-to-video
|
||||
print("\n" + "="*50)
|
||||
result1 = await examples.cogvideox3_text_to_video(
|
||||
prompt="Peter Rabbit driving a car, wandering on the road, with a happy and joyful expression on his face.",
|
||||
quality="quality",
|
||||
with_audio=True,
|
||||
size="1920x1080",
|
||||
fps=30,
|
||||
)
|
||||
print("cogvideox-3 text-to-video result:", result1)
|
||||
|
||||
# 2. cogvideox-3 image-to-video
|
||||
print("\n" + "="*50)
|
||||
result2 = await examples.cogvideox3_image_to_video(
|
||||
image_url=sample_image_url,
|
||||
prompt="Make the scene come alive",
|
||||
quality="quality",
|
||||
with_audio=True,
|
||||
size="1920x1080",
|
||||
fps=30,
|
||||
)
|
||||
print("cogvideox-3 image-to-video result:", result2)
|
||||
|
||||
# 3. cogvideox-3 start-end frame video
|
||||
print("\n" + "="*50)
|
||||
result3 = await examples.cogvideox3_start_end_video(
|
||||
image_urls=[sample_first_frame, sample_last_frame],
|
||||
prompt="Make the scene come alive",
|
||||
quality="speed",
|
||||
with_audio=True,
|
||||
size="1920x1080",
|
||||
fps=30,
|
||||
)
|
||||
print("cogvideox-3 start-end frame video result:", result3)
|
||||
|
||||
# 4. cogvideox-2 text-to-video
|
||||
print("\n" + "="*50)
|
||||
result4 = await examples.cogvideox2_text_to_video(
|
||||
prompt="Peter Rabbit driving a car, wandering on the road, with a happy and joyful expression on his face.",
|
||||
quality="speed",
|
||||
with_audio=True,
|
||||
)
|
||||
print("cogvideox-2 text-to-video result:", result4)
|
||||
|
||||
# 5. viduq1-text text-to-video
|
||||
print("\n" + "="*50)
|
||||
result5 = await examples.viduq1_text_to_video(
|
||||
prompt="Peter Rabbit driving a car, wandering on the road, with a happy and joyful expression on his face.",
|
||||
quality="speed",
|
||||
with_audio=True,
|
||||
)
|
||||
print("viduq1-text text-to-video result:", result5)
|
||||
|
||||
# 6. viduq1-image image-to-video
|
||||
print("\n" + "="*50)
|
||||
result6 = await examples.viduq1_image_to_video(
|
||||
image_url=sample_image_url,
|
||||
prompt="Peter Rabbit driving a car, wandering on the road, with a happy and joyful expression on his face.",
|
||||
quality="speed",
|
||||
with_audio=True,
|
||||
)
|
||||
print("viduq1-image image-to-video result:", result6)
|
||||
|
||||
# 7. viduq1-start-end start-end frame video
|
||||
print("\n" + "="*50)
|
||||
result7 = await examples.viduq1_start_end_video(
|
||||
image_url=[sample_first_frame, sample_last_frame],
|
||||
prompt="Peter Rabbit driving a car, wandering on the road, with a happy and joyful expression on his face.",
|
||||
quality="speed",
|
||||
with_audio=True,
|
||||
)
|
||||
print("viduq1-start-end start-end frame video result:", result7)
|
||||
|
||||
# 8. vidu2-image image-to-video
|
||||
print("\n" + "="*50)
|
||||
result8 = await examples.vidu2_image_to_video(
|
||||
image_url=sample_image_url,
|
||||
prompt="Peter Rabbit driving a car, wandering on the road, with a happy and joyful expression on his face.",
|
||||
quality="speed",
|
||||
with_audio=True,
|
||||
)
|
||||
print("vidu2-image image-to-video result:", result8)
|
||||
|
||||
# 9. vidu2-start-end start-end frame video
|
||||
print("\n" + "="*50)
|
||||
result9 = await examples.vidu2_start_end_video(
|
||||
image_url=[sample_first_frame, sample_last_frame],
|
||||
prompt="Peter Rabbit driving a car, wandering on the road, with a happy and joyful expression on his face.",
|
||||
quality="speed",
|
||||
with_audio=True,
|
||||
)
|
||||
print("vidu2-start-end start-end frame video result:", result9)
|
||||
|
||||
# 10. vidu2-reference reference video generation
|
||||
print("\n" + "="*50)
|
||||
result10 = await examples.vidu2_reference_video(
|
||||
image_url=ref_image_url,
|
||||
prompt="Peter Rabbit driving a car, wandering on the road, with a happy and joyful expression on his face.",
|
||||
quality="speed",
|
||||
with_audio=True,
|
||||
)
|
||||
print("vidu2-reference reference video generation result:", result10)
|
||||
except Exception as e:
|
||||
print(f"Video generation failed: {e}")
|
||||
raise e
|
||||
finally:
|
||||
print("\n=== Examples completed ===")
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(main())
|
||||
30
examples/web_search_example.py
Normal file
30
examples/web_search_example.py
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
import os
|
||||
from zai import ZaiClient
|
||||
|
||||
# Try to load .env file
|
||||
try:
|
||||
from dotenv import load_dotenv
|
||||
load_dotenv()
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
api_key = os.getenv('ZAI_API_KEY')
|
||||
if not api_key:
|
||||
print("Please set the ZAI_API_KEY environment variable or configure it in the .env file")
|
||||
exit()
|
||||
|
||||
client = ZaiClient(api_key=api_key)
|
||||
|
||||
def web_search_example():
|
||||
response = client.web_search.web_search(
|
||||
search_engine="search_pro",
|
||||
search_query="Search for financial news in April 2025",
|
||||
count=15, # Number of returned results, range 1-50, default 10
|
||||
search_domain_filter="www.sohu.com", # Only access content from specified domain
|
||||
search_recency_filter="noLimit", # Search content within specified time range
|
||||
content_size="high" # Control the word count of web page summaries, default medium
|
||||
)
|
||||
print(response)
|
||||
|
||||
if __name__ == "__main__":
|
||||
web_search_example()
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
[tool.poetry]
|
||||
name = "zai-sdk"
|
||||
version = "0.0.1a1"
|
||||
version = "0.0.1b1"
|
||||
description = "A SDK library for accessing big model apis from Z.ai"
|
||||
authors = ["Z.ai"]
|
||||
readme = "README.md"
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ if TYPE_CHECKING:
|
|||
from zai.api_resource.agents import Agents
|
||||
from zai.api_resource.assistant import Assistant
|
||||
from zai.api_resource.audio import Audio
|
||||
from zai.api_resource.batches import Batches
|
||||
from zai.api_resource.batch import Batches
|
||||
from zai.api_resource.chat import Chat
|
||||
from zai.api_resource.embeddings import Embeddings
|
||||
from zai.api_resource.files import Files
|
||||
|
|
@ -139,7 +139,7 @@ class ZaiClient(HttpClient):
|
|||
|
||||
@cached_property
|
||||
def batches(self) -> Batches:
|
||||
from zai.api_resource.batches import Batches
|
||||
from zai.api_resource.batch import Batches
|
||||
|
||||
return Batches(self)
|
||||
|
||||
|
|
|
|||
|
|
@ -1,2 +1,2 @@
|
|||
__title__ = 'Z.ai'
|
||||
__version__ = '0.0.1a1'
|
||||
__version__ = '0.0.1b1'
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ from .assistant import (
|
|||
Assistant,
|
||||
)
|
||||
from .audio import Audio
|
||||
from .batches import Batches
|
||||
from .batch import Batches
|
||||
from .chat import (
|
||||
AsyncCompletions,
|
||||
Chat,
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ from typing import TYPE_CHECKING, List, Optional, Union
|
|||
import httpx
|
||||
from typing_extensions import Literal
|
||||
|
||||
from ...core import (
|
||||
from zai.core import (
|
||||
NOT_GIVEN,
|
||||
BaseAPI,
|
||||
Body,
|
||||
|
|
@ -16,14 +16,14 @@ from ...core import (
|
|||
deepcopy_minimal,
|
||||
make_request_options,
|
||||
)
|
||||
from ...types.agents.agents_completion import AgentsCompletion
|
||||
from ...types.agents.agents_completion_chunk import AgentsCompletionChunk
|
||||
from ...types.sensitive_word_check import SensitiveWordCheckRequest
|
||||
from zai.types.agents.agents_completion import AgentsCompletion
|
||||
from zai.types.agents.agents_completion_chunk import AgentsCompletionChunk
|
||||
from zai.types.sensitive_word_check import SensitiveWordCheckRequest
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..._client import ZaiClient
|
||||
from zai._client import ZaiClient
|
||||
|
||||
|
||||
class Agents(BaseAPI):
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ from typing import TYPE_CHECKING, List, Optional
|
|||
import httpx
|
||||
from typing_extensions import Literal
|
||||
|
||||
from ...core import (
|
||||
from zai.core import (
|
||||
NOT_GIVEN,
|
||||
BaseAPI,
|
||||
Body,
|
||||
|
|
@ -16,16 +16,16 @@ from ...core import (
|
|||
make_request_options,
|
||||
maybe_transform,
|
||||
)
|
||||
from ...types.assistant import AssistantCompletion
|
||||
from ...types.assistant.assistant_conversation_resp import (
|
||||
from zai.types.assistant import AssistantCompletion
|
||||
from zai.types.assistant.assistant_conversation_resp import (
|
||||
ConversationUsageListResp,
|
||||
)
|
||||
from ...types.assistant.assistant_support_resp import AssistantSupportResp
|
||||
from zai.types.assistant.assistant_support_resp import AssistantSupportResp
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..._client import ZaiClient
|
||||
from zai._client import ZaiClient
|
||||
|
||||
from ...types.assistant import assistant_conversation_params, assistant_create_params
|
||||
from zai.types.assistant import assistant_conversation_params, assistant_create_params
|
||||
|
||||
__all__ = ['Assistant']
|
||||
|
||||
|
|
|
|||
|
|
@ -11,24 +11,21 @@ from zai.core import (
|
|||
FileTypes,
|
||||
Headers,
|
||||
NotGiven,
|
||||
cached_property,
|
||||
deepcopy_minimal,
|
||||
make_request_options,
|
||||
maybe_transform,
|
||||
)
|
||||
from zai.core._legacy_binary_response import HttpxBinaryResponseContent
|
||||
from zai.core._utils import extract_files
|
||||
from zai.types.audio import AudioSpeechParams
|
||||
from zai.types.audio import AudioSpeechParams, audio_customization_param
|
||||
from zai.types.sensitive_word_check import SensitiveWordCheckRequest
|
||||
|
||||
from ...core import cached_property
|
||||
from ...types.audio import audio_customization_param
|
||||
from .transcriptions import Transcriptions
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from zai._client import ZaiClient
|
||||
|
||||
__all__ = ['Audio']
|
||||
|
||||
|
||||
class Audio(BaseAPI):
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -6,9 +6,7 @@ from typing import TYPE_CHECKING, Mapping, Optional, cast
|
|||
import httpx
|
||||
from typing_extensions import Literal
|
||||
|
||||
from zai.core._utils import extract_files
|
||||
|
||||
from ...core import (
|
||||
from zai.core import (
|
||||
NOT_GIVEN,
|
||||
BaseAPI,
|
||||
Body,
|
||||
|
|
@ -20,19 +18,18 @@ from ...core import (
|
|||
make_request_options,
|
||||
maybe_transform,
|
||||
)
|
||||
from ...types.audio import transcriptions_create_param
|
||||
from ...types.chat.chat_completion import Completion
|
||||
from ...types.chat.chat_completion_chunk import ChatCompletionChunk
|
||||
from ...types.sensitive_word_check import SensitiveWordCheckRequest
|
||||
from zai.core._utils import extract_files
|
||||
from zai.types.audio import transcriptions_create_param
|
||||
from zai.types.chat.chat_completion import Completion
|
||||
from zai.types.chat.chat_completion_chunk import ChatCompletionChunk
|
||||
from zai.types.sensitive_word_check import SensitiveWordCheckRequest
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..._client import ZaiClient
|
||||
from zai._client import ZaiClient
|
||||
|
||||
|
||||
__all__ = ['Transcriptions']
|
||||
|
||||
|
||||
class Transcriptions(BaseAPI):
|
||||
"""
|
||||
|
|
|
|||
3
src/zai/api_resource/batch/__init__.py
Normal file
3
src/zai/api_resource/batch/__init__.py
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
from .batches import Batches
|
||||
|
||||
__all__ = ["Batches"]
|
||||
|
|
@ -4,7 +4,7 @@ from typing import TYPE_CHECKING, Dict, Literal, Optional
|
|||
|
||||
import httpx
|
||||
|
||||
from ..core import (
|
||||
from zai.core import (
|
||||
NOT_GIVEN,
|
||||
BaseAPI,
|
||||
Body,
|
||||
|
|
@ -13,9 +13,8 @@ from ..core import (
|
|||
make_request_options,
|
||||
maybe_transform,
|
||||
)
|
||||
from ..core.pagination import SyncCursorPage
|
||||
from ..types import batch_create_params, batch_list_params
|
||||
from ..types.batch import Batch
|
||||
from zai.core.pagination import SyncCursorPage
|
||||
from zai.types.batch import Batch, BatchCreateParams, BatchListParams
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from .._client import ZaiClient
|
||||
|
|
@ -47,7 +46,7 @@ class Batches(BaseAPI):
|
|||
'metadata': metadata,
|
||||
'auto_delete_input_file': auto_delete_input_file,
|
||||
},
|
||||
batch_create_params.BatchCreateParams,
|
||||
BatchCreateParams,
|
||||
),
|
||||
options=make_request_options(extra_headers=extra_headers, extra_body=extra_body, timeout=timeout),
|
||||
cast_type=Batch,
|
||||
|
|
@ -119,7 +118,7 @@ class Batches(BaseAPI):
|
|||
'after': after,
|
||||
'limit': limit,
|
||||
},
|
||||
batch_list_params.BatchListParams,
|
||||
BatchListParams,
|
||||
),
|
||||
),
|
||||
model=Batch,
|
||||
|
|
@ -6,7 +6,7 @@ from typing import TYPE_CHECKING, Dict, List, Optional, Union
|
|||
import httpx
|
||||
from typing_extensions import Literal
|
||||
|
||||
from ...core import (
|
||||
from zai.core import (
|
||||
NOT_GIVEN,
|
||||
BaseAPI,
|
||||
Body,
|
||||
|
|
@ -16,14 +16,14 @@ from ...core import (
|
|||
make_request_options,
|
||||
maybe_transform,
|
||||
)
|
||||
from ...types.chat.async_chat_completion import AsyncCompletion, AsyncTaskStatus
|
||||
from ...types.chat.code_geex import code_geex_params
|
||||
from ...types.sensitive_word_check import SensitiveWordCheckRequest
|
||||
from zai.types.chat.async_chat_completion import AsyncCompletion, AsyncTaskStatus
|
||||
from zai.types.chat.code_geex import code_geex_params
|
||||
from zai.types.sensitive_word_check import SensitiveWordCheckRequest
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..._client import ZaiClient
|
||||
from zai._client import ZaiClient
|
||||
|
||||
|
||||
class AsyncCompletions(BaseAPI):
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
from typing import TYPE_CHECKING
|
||||
|
||||
from ...core import BaseAPI, cached_property
|
||||
from zai.core import BaseAPI, cached_property
|
||||
|
||||
from .async_completions import AsyncCompletions
|
||||
from .completions import Completions
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ from typing import TYPE_CHECKING, Dict, List, Optional, Union
|
|||
import httpx
|
||||
from typing_extensions import Literal
|
||||
|
||||
from ...core import (
|
||||
from zai.core import (
|
||||
NOT_GIVEN,
|
||||
BaseAPI,
|
||||
Body,
|
||||
|
|
@ -18,15 +18,15 @@ from ...core import (
|
|||
make_request_options,
|
||||
maybe_transform,
|
||||
)
|
||||
from ...types.chat.chat_completion import Completion
|
||||
from ...types.chat.chat_completion_chunk import ChatCompletionChunk
|
||||
from ...types.chat.code_geex import code_geex_params
|
||||
from ...types.sensitive_word_check import SensitiveWordCheckRequest
|
||||
from zai.types.chat.chat_completion import Completion
|
||||
from zai.types.chat.chat_completion_chunk import ChatCompletionChunk
|
||||
from zai.types.chat.code_geex import code_geex_params
|
||||
from zai.types.sensitive_word_check import SensitiveWordCheckRequest
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..._client import ZaiClient
|
||||
from zai._client import ZaiClient
|
||||
|
||||
|
||||
class Completions(BaseAPI):
|
||||
|
|
|
|||
3
src/zai/api_resource/embeddings/__init__.py
Normal file
3
src/zai/api_resource/embeddings/__init__.py
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
from .embeddings import Embeddings
|
||||
|
||||
__all__ = ['Embeddings']
|
||||
|
|
@ -4,11 +4,11 @@ from typing import TYPE_CHECKING, List, Optional, Union
|
|||
|
||||
import httpx
|
||||
|
||||
from ..core import NOT_GIVEN, BaseAPI, Body, Headers, NotGiven, make_request_options
|
||||
from ..types.embeddings import EmbeddingsResponded
|
||||
from zai.core import NOT_GIVEN, BaseAPI, Body, Headers, NotGiven, make_request_options
|
||||
from zai.types.embeddings import EmbeddingsResponded
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from .._client import ZaiClient
|
||||
from zai._client import ZaiClient
|
||||
|
||||
|
||||
class Embeddings(BaseAPI):
|
||||
3
src/zai/api_resource/files/__init__.py
Normal file
3
src/zai/api_resource/files/__init__.py
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
from .files import Files, FilesWithRawResponse
|
||||
|
||||
__all__ = ['Files', 'FilesWithRawResponse']
|
||||
|
|
@ -5,7 +5,7 @@ from typing import TYPE_CHECKING, List, Mapping, cast
|
|||
import httpx
|
||||
from typing_extensions import Literal
|
||||
|
||||
from ..core import (
|
||||
from zai.core import (
|
||||
NOT_GIVEN,
|
||||
BaseAPI,
|
||||
Body,
|
||||
|
|
@ -19,7 +19,7 @@ from ..core import (
|
|||
make_request_options,
|
||||
maybe_transform,
|
||||
)
|
||||
from ..types.files import (
|
||||
from zai.types.files import (
|
||||
FileDeleted,
|
||||
FileObject,
|
||||
ListOfFileObject,
|
||||
|
|
@ -30,8 +30,6 @@ from ..types.files import (
|
|||
if TYPE_CHECKING:
|
||||
from .._client import ZaiClient
|
||||
|
||||
__all__ = ['Files', 'FilesWithRawResponse']
|
||||
|
||||
|
||||
class Files(BaseAPI):
|
||||
def __init__(self, client: 'ZaiClient') -> None:
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
from typing import TYPE_CHECKING
|
||||
|
||||
from ...core import BaseAPI, cached_property
|
||||
from zai.core import BaseAPI, cached_property
|
||||
|
||||
from .jobs import Jobs
|
||||
from .models import FineTunedModels
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ from typing import TYPE_CHECKING, Optional
|
|||
|
||||
import httpx
|
||||
|
||||
from ....core import (
|
||||
from zai.core import (
|
||||
NOT_GIVEN,
|
||||
BaseAPI,
|
||||
Body,
|
||||
|
|
@ -12,7 +12,7 @@ from ....core import (
|
|||
NotGiven,
|
||||
make_request_options,
|
||||
)
|
||||
from ....types.fine_tuning import (
|
||||
from zai.types.fine_tuning import (
|
||||
FineTuningJob,
|
||||
FineTuningJobEvent,
|
||||
ListOfFineTuningJob,
|
||||
|
|
@ -20,9 +20,7 @@ from ....types.fine_tuning import (
|
|||
)
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ...._client import ZaiClient
|
||||
|
||||
__all__ = ['Jobs']
|
||||
from zai._client import ZaiClient
|
||||
|
||||
|
||||
class Jobs(BaseAPI):
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ from typing import TYPE_CHECKING
|
|||
|
||||
import httpx
|
||||
|
||||
from ....core import (
|
||||
from zai.core import (
|
||||
NOT_GIVEN,
|
||||
BaseAPI,
|
||||
Body,
|
||||
|
|
@ -12,12 +12,10 @@ from ....core import (
|
|||
NotGiven,
|
||||
make_request_options,
|
||||
)
|
||||
from ....types.fine_tuning.models import FineTunedModelsStatus
|
||||
from zai.types.fine_tuning.models import FineTunedModelsStatus
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ...._client import ZaiClient
|
||||
|
||||
__all__ = ['FineTunedModels']
|
||||
from zai._client import ZaiClient
|
||||
|
||||
|
||||
class FineTunedModels(BaseAPI):
|
||||
|
|
|
|||
3
src/zai/api_resource/images/__init__.py
Normal file
3
src/zai/api_resource/images/__init__.py
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
from .images import Images
|
||||
|
||||
__all__ = ['Images']
|
||||
|
|
@ -4,12 +4,12 @@ from typing import TYPE_CHECKING, Optional
|
|||
|
||||
import httpx
|
||||
|
||||
from ..core import NOT_GIVEN, BaseAPI, Body, Headers, NotGiven, make_request_options
|
||||
from ..types.image import ImagesResponded
|
||||
from ..types.sensitive_word_check import SensitiveWordCheckRequest
|
||||
from zai.core import NOT_GIVEN, BaseAPI, Body, Headers, NotGiven, make_request_options
|
||||
from zai.types.image import ImagesResponded
|
||||
from zai.types.sensitive_word_check import SensitiveWordCheckRequest
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from .._client import ZaiClient
|
||||
from zai._client import ZaiClient
|
||||
|
||||
|
||||
class Images(BaseAPI):
|
||||
|
|
@ -5,7 +5,7 @@ from typing import TYPE_CHECKING, Dict, List, Mapping, Optional, cast
|
|||
import httpx
|
||||
from typing_extensions import Literal
|
||||
|
||||
from ....core import (
|
||||
from zai.core import (
|
||||
NOT_GIVEN,
|
||||
BaseAPI,
|
||||
Body,
|
||||
|
|
@ -17,19 +17,17 @@ from ....core import (
|
|||
make_request_options,
|
||||
maybe_transform,
|
||||
)
|
||||
from ....types.files import UploadDetail, file_create_params
|
||||
from ....types.knowledge.document import (
|
||||
from zai.types.files import UploadDetail, file_create_params
|
||||
from zai.types.knowledge.document import (
|
||||
DocumentData,
|
||||
DocumentObject,
|
||||
document_edit_params,
|
||||
document_list_params,
|
||||
)
|
||||
from ....types.knowledge.document.document_list_resp import DocumentPage
|
||||
from zai.types.knowledge.document.document_list_resp import DocumentPage
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ...._client import ZaiClient
|
||||
|
||||
__all__ = ['Document']
|
||||
from zai._client import ZaiClient
|
||||
|
||||
|
||||
class Document(BaseAPI):
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ from typing import TYPE_CHECKING, Optional
|
|||
import httpx
|
||||
from typing_extensions import Literal
|
||||
|
||||
from ...core import (
|
||||
from zai.core import (
|
||||
NOT_GIVEN,
|
||||
BaseAPI,
|
||||
Body,
|
||||
|
|
@ -16,19 +16,18 @@ from ...core import (
|
|||
make_request_options,
|
||||
maybe_transform,
|
||||
)
|
||||
from ...types.knowledge import (
|
||||
from zai.types.knowledge import (
|
||||
KnowledgeInfo,
|
||||
KnowledgeUsed,
|
||||
knowledge_create_params,
|
||||
knowledge_list_params,
|
||||
)
|
||||
from ...types.knowledge.knowledge_list_resp import KnowledgePage
|
||||
from zai.types.knowledge.knowledge_list_resp import KnowledgePage
|
||||
|
||||
from .document import Document
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..._client import ZaiClient
|
||||
|
||||
__all__ = ['Knowledge']
|
||||
from zai._client import ZaiClient
|
||||
|
||||
|
||||
class Knowledge(BaseAPI):
|
||||
|
|
|
|||
|
|
@ -3,13 +3,13 @@ from __future__ import annotations
|
|||
import logging
|
||||
from typing import TYPE_CHECKING, Dict, List, Union
|
||||
|
||||
from ...core import BaseAPI, deepcopy_minimal
|
||||
from ...types.moderation.moderation_completion import Completion
|
||||
from zai.core import BaseAPI, deepcopy_minimal
|
||||
from zai.types.moderation.moderation_completion import Completion
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..._client import ZaiClient
|
||||
from zai._client import ZaiClient
|
||||
|
||||
|
||||
class Moderations(BaseAPI):
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ from typing import TYPE_CHECKING, List, Optional, Union
|
|||
import httpx
|
||||
from typing_extensions import Literal
|
||||
|
||||
from ...core import (
|
||||
from zai.core import (
|
||||
NOT_GIVEN,
|
||||
BaseAPI,
|
||||
Body,
|
||||
|
|
@ -17,14 +17,12 @@ from ...core import (
|
|||
make_request_options,
|
||||
maybe_transform,
|
||||
)
|
||||
from ...types.tools import WebSearch, WebSearchChunk, tools_web_search_params
|
||||
from zai.types.tools import WebSearch, WebSearchChunk, tools_web_search_params
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..._client import ZaiClient
|
||||
|
||||
__all__ = ['Tools']
|
||||
from zai._client import ZaiClient
|
||||
|
||||
|
||||
class Tools(BaseAPI):
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, Optional
|
||||
from typing import TYPE_CHECKING, Optional, List
|
||||
|
||||
import httpx
|
||||
|
||||
from ...core import (
|
||||
from zai.core import (
|
||||
NOT_GIVEN,
|
||||
BaseAPI,
|
||||
Body,
|
||||
|
|
@ -14,13 +14,11 @@ from ...core import (
|
|||
make_request_options,
|
||||
maybe_transform,
|
||||
)
|
||||
from ...types.sensitive_word_check import SensitiveWordCheckRequest
|
||||
from ...types.video import VideoObject, video_create_params
|
||||
from zai.types.sensitive_word_check import SensitiveWordCheckRequest
|
||||
from zai.types.video import VideoObject, video_create_params
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..._client import ZaiClient
|
||||
|
||||
__all__ = ['Videos']
|
||||
from zai._client import ZaiClient
|
||||
|
||||
|
||||
class Videos(BaseAPI):
|
||||
|
|
@ -36,7 +34,7 @@ class Videos(BaseAPI):
|
|||
model: str,
|
||||
*,
|
||||
prompt: str = None,
|
||||
image_url: str = None,
|
||||
image_url: str | List[str] | None = None,
|
||||
quality: str = None,
|
||||
with_audio: bool = None,
|
||||
size: str = None,
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ from typing import TYPE_CHECKING, Optional
|
|||
|
||||
import httpx
|
||||
|
||||
from ...core import (
|
||||
from zai.core import (
|
||||
NOT_GIVEN,
|
||||
BaseAPI,
|
||||
Body,
|
||||
|
|
@ -15,16 +15,14 @@ from ...core import (
|
|||
make_request_options,
|
||||
maybe_transform,
|
||||
)
|
||||
from ...types.sensitive_word_check import SensitiveWordCheckRequest
|
||||
from ...types.web_search import web_search_create_params
|
||||
from ...types.web_search.web_search_resp import WebSearchResp
|
||||
from zai.types.sensitive_word_check import SensitiveWordCheckRequest
|
||||
from zai.types.web_search import web_search_create_params
|
||||
from zai.types.web_search.web_search_resp import WebSearchResp
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..._client import ZaiClient
|
||||
|
||||
__all__ = ['WebSearchApi']
|
||||
from zai._client import ZaiClient
|
||||
|
||||
|
||||
class WebSearchApi(BaseAPI):
|
||||
|
|
|
|||
|
|
@ -0,0 +1,15 @@
|
|||
from .agents_completion import AgentsCompletion, AgentsCompletionUsage, AgentsError
|
||||
from .agents_completion_chunk import AgentsChoice, AgentsChoiceDelta, AgentsCompletionChunk
|
||||
from .agents_completion_chunk import AgentsCompletionUsage as AgentsCompletionChunkUsage
|
||||
from .chat_completions_create_param import Reference
|
||||
|
||||
__all__ = [
|
||||
'AgentsCompletion',
|
||||
'AgentsCompletionUsage',
|
||||
'AgentsCompletionChunkUsage',
|
||||
'AgentsCompletionChunk',
|
||||
'AgentsChoice',
|
||||
'AgentsChoiceDelta',
|
||||
'AgentsError',
|
||||
'Reference',
|
||||
]
|
||||
|
|
@ -1,8 +1,6 @@
|
|||
from typing import List, Optional
|
||||
|
||||
from ...core import BaseModel
|
||||
|
||||
__all__ = ['AgentsCompletion', 'AgentsCompletionUsage']
|
||||
from zai.core import BaseModel
|
||||
|
||||
|
||||
class AgentsCompletionMessage(BaseModel):
|
||||
|
|
|
|||
|
|
@ -1,13 +1,6 @@
|
|||
from typing import List, Optional
|
||||
|
||||
from ...core import BaseModel
|
||||
|
||||
__all__ = [
|
||||
'AgentsCompletionUsage',
|
||||
'AgentsCompletionChunk',
|
||||
'AgentsChoice',
|
||||
'AgentsChoiceDelta',
|
||||
]
|
||||
from zai.core import BaseModel
|
||||
|
||||
|
||||
class AgentsChoiceDelta(BaseModel):
|
||||
|
|
|
|||
|
|
@ -1,5 +1,34 @@
|
|||
from .assistant_completion import AssistantCompletion
|
||||
from .assistant_completion import AssistantChoice, AssistantCompletion, CompletionUsage, ErrorInfo
|
||||
from .assistant_conversation_params import ConversationParameters
|
||||
from .assistant_conversation_resp import ConversationUsage, ConversationUsageList, ConversationUsageListResp, Usage
|
||||
from .assistant_create_params import (
|
||||
AssistantAttachments,
|
||||
AssistantParameters,
|
||||
ConversationMessage,
|
||||
ExtraParameters,
|
||||
MessageContent,
|
||||
MessageTextContent,
|
||||
TranslateParameters,
|
||||
)
|
||||
from .assistant_support_resp import AssistantSupport, AssistantSupportResp
|
||||
|
||||
__all__ = [
|
||||
'AssistantCompletion',
|
||||
'AssistantCompletion',
|
||||
'CompletionUsage',
|
||||
'ErrorInfo',
|
||||
'AssistantChoice',
|
||||
'ConversationUsageListResp',
|
||||
'ConversationUsage',
|
||||
'ConversationUsageList',
|
||||
'Usage',
|
||||
'AssistantSupportResp',
|
||||
'AssistantSupport',
|
||||
'AssistantAttachments',
|
||||
'MessageTextContent',
|
||||
'MessageContent',
|
||||
'ConversationMessage',
|
||||
'AssistantParameters',
|
||||
'TranslateParameters',
|
||||
'ExtraParameters',
|
||||
'ConversationParameters',
|
||||
]
|
||||
|
|
|
|||
|
|
@ -1,9 +1,7 @@
|
|||
from typing import Any, Dict, List, Optional
|
||||
|
||||
from ...core import BaseModel
|
||||
from .message import MessageContent
|
||||
|
||||
__all__ = ['AssistantCompletion', 'CompletionUsage']
|
||||
from zai.core import BaseModel
|
||||
from zai.types.assistant.message import MessageContent
|
||||
|
||||
|
||||
class ErrorInfo(BaseModel):
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
from typing import List
|
||||
|
||||
from ...core import BaseModel
|
||||
|
||||
__all__ = ['ConversationUsageListResp']
|
||||
from zai.core import BaseModel
|
||||
|
||||
|
||||
class Usage(BaseModel):
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
from typing import List
|
||||
|
||||
from ...core import BaseModel
|
||||
|
||||
__all__ = ['AssistantSupportResp']
|
||||
from zai.core import BaseModel
|
||||
|
||||
|
||||
class AssistantSupport(BaseModel):
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
from .message_content import MessageContent
|
||||
from .text_content_block import TextContentBlock
|
||||
from .tools_delta_block import ToolsDeltaBlock
|
||||
|
||||
__all__ = ['MessageContent']
|
||||
__all__ = ['MessageContent', 'TextContentBlock', 'ToolsDeltaBlock']
|
||||
|
|
|
|||
|
|
@ -2,12 +2,9 @@ from typing import Union
|
|||
|
||||
from typing_extensions import Annotated, TypeAlias
|
||||
|
||||
from ....core._utils import PropertyInfo
|
||||
from .text_content_block import TextContentBlock
|
||||
from .tools_delta_block import ToolsDeltaBlock
|
||||
|
||||
__all__ = ['MessageContent']
|
||||
|
||||
from zai.core._utils import PropertyInfo
|
||||
from zai.types.assistant.message.text_content_block import TextContentBlock
|
||||
from zai.types.assistant.message.tools_delta_block import ToolsDeltaBlock
|
||||
|
||||
MessageContent: TypeAlias = Annotated[
|
||||
Union[ToolsDeltaBlock, TextContentBlock],
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
from typing_extensions import Literal
|
||||
|
||||
from ....core import BaseModel
|
||||
|
||||
__all__ = ['TextContentBlock']
|
||||
from zai.core import BaseModel
|
||||
|
||||
|
||||
class TextContentBlock(BaseModel):
|
||||
|
|
|
|||
15
src/zai/types/assistant/message/tools/__init__.py
Normal file
15
src/zai/types/assistant/message/tools/__init__.py
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
from .code_interpreter_delta_block import CodeInterpreterToolBlock
|
||||
from .drawing_tool_delta_block import DrawingToolBlock
|
||||
from .function_delta_block import FunctionToolBlock
|
||||
from .retrieval_delta_black import RetrievalToolBlock
|
||||
from .tools_type import ToolsType
|
||||
from .web_browser_delta_block import WebBrowserToolBlock
|
||||
|
||||
__all__ = [
|
||||
'CodeInterpreterToolBlock',
|
||||
'DrawingToolBlock',
|
||||
'FunctionToolBlock',
|
||||
'RetrievalToolBlock',
|
||||
'WebBrowserToolBlock',
|
||||
'ToolsType',
|
||||
]
|
||||
|
|
@ -2,9 +2,7 @@ from typing import List
|
|||
|
||||
from typing_extensions import Literal
|
||||
|
||||
__all__ = ['CodeInterpreterToolBlock']
|
||||
|
||||
from .....core import BaseModel
|
||||
from zai.core import BaseModel
|
||||
|
||||
|
||||
class CodeInterpreterToolOutput(BaseModel):
|
||||
|
|
|
|||
|
|
@ -2,9 +2,7 @@ from typing import List
|
|||
|
||||
from typing_extensions import Literal
|
||||
|
||||
from .....core import BaseModel
|
||||
|
||||
__all__ = ['DrawingToolBlock']
|
||||
from zai.core import BaseModel
|
||||
|
||||
|
||||
class DrawingToolOutput(BaseModel):
|
||||
|
|
|
|||
|
|
@ -2,9 +2,7 @@ from typing import List, Union
|
|||
|
||||
from typing_extensions import Literal
|
||||
|
||||
__all__ = ['FunctionToolBlock']
|
||||
|
||||
from .....core import BaseModel
|
||||
from zai.core import BaseModel
|
||||
|
||||
|
||||
class FunctionToolOutput(BaseModel):
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ from typing import List
|
|||
|
||||
from typing_extensions import Literal
|
||||
|
||||
from .....core import BaseModel
|
||||
from zai.core import BaseModel
|
||||
|
||||
|
||||
class RetrievalToolOutput(BaseModel):
|
||||
|
|
|
|||
|
|
@ -2,16 +2,14 @@ from typing import Union
|
|||
|
||||
from typing_extensions import Annotated, TypeAlias
|
||||
|
||||
from .....core._utils import PropertyInfo
|
||||
from zai.core._utils import PropertyInfo
|
||||
|
||||
from .code_interpreter_delta_block import CodeInterpreterToolBlock
|
||||
from .drawing_tool_delta_block import DrawingToolBlock
|
||||
from .function_delta_block import FunctionToolBlock
|
||||
from .retrieval_delta_black import RetrievalToolBlock
|
||||
from .web_browser_delta_block import WebBrowserToolBlock
|
||||
|
||||
__all__ = ['ToolsType']
|
||||
|
||||
|
||||
ToolsType: TypeAlias = Annotated[
|
||||
Union[
|
||||
DrawingToolBlock,
|
||||
|
|
|
|||
|
|
@ -2,9 +2,7 @@ from typing import List
|
|||
|
||||
from typing_extensions import Literal
|
||||
|
||||
from .....core import BaseModel
|
||||
|
||||
__all__ = ['WebBrowserToolBlock']
|
||||
from zai.core import BaseModel
|
||||
|
||||
|
||||
class WebBrowserOutput(BaseModel):
|
||||
|
|
|
|||
|
|
@ -2,10 +2,8 @@ from typing import List
|
|||
|
||||
from typing_extensions import Literal
|
||||
|
||||
from ....core import BaseModel
|
||||
from .tools.tools_type import ToolsType
|
||||
|
||||
__all__ = ['ToolsDeltaBlock']
|
||||
from zai.core import BaseModel
|
||||
from zai.types.assistant.message.tools.tools_type import ToolsType
|
||||
|
||||
|
||||
class ToolsDeltaBlock(BaseModel):
|
||||
|
|
|
|||
|
|
@ -4,9 +4,7 @@ from typing import Optional
|
|||
|
||||
from typing_extensions import TypedDict
|
||||
|
||||
__all__ = ['AudioCustomizationParam']
|
||||
|
||||
from ..sensitive_word_check import SensitiveWordCheckRequest
|
||||
from zai.types.sensitive_word_check import SensitiveWordCheckRequest
|
||||
|
||||
|
||||
class AudioCustomizationParam(TypedDict, total=False):
|
||||
|
|
|
|||
|
|
@ -4,9 +4,7 @@ from typing import Optional
|
|||
|
||||
from typing_extensions import TypedDict
|
||||
|
||||
__all__ = ['AudioSpeechParams']
|
||||
|
||||
from ..sensitive_word_check import SensitiveWordCheckRequest
|
||||
from zai.types.sensitive_word_check import SensitiveWordCheckRequest
|
||||
|
||||
|
||||
class AudioSpeechParams(TypedDict, total=False):
|
||||
|
|
|
|||
|
|
@ -4,9 +4,7 @@ from typing import Optional
|
|||
|
||||
from typing_extensions import TypedDict
|
||||
|
||||
__all__ = ['TranscriptionsParam']
|
||||
|
||||
from ..sensitive_word_check import SensitiveWordCheckRequest
|
||||
from zai.types.sensitive_word_check import SensitiveWordCheckRequest
|
||||
|
||||
|
||||
class TranscriptionsParam(TypedDict, total=False):
|
||||
|
|
|
|||
14
src/zai/types/batch/__init__.py
Normal file
14
src/zai/types/batch/__init__.py
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
from .batch import Batch, Errors
|
||||
from .batch_create_params import BatchCreateParams
|
||||
from .batch_error import BatchError
|
||||
from .batch_list_params import BatchListParams
|
||||
from .batch_request_counts import BatchRequestCounts
|
||||
|
||||
__all__ = [
|
||||
'Batch',
|
||||
'Errors',
|
||||
'BatchCreateParams',
|
||||
'BatchError',
|
||||
'BatchListParams',
|
||||
'BatchRequestCounts',
|
||||
]
|
||||
|
|
@ -5,11 +5,9 @@ from typing import List, Optional
|
|||
|
||||
from typing_extensions import Literal
|
||||
|
||||
from ..core import BaseModel
|
||||
from .batch_error import BatchError
|
||||
from .batch_request_counts import BatchRequestCounts
|
||||
|
||||
__all__ = ['Batch', 'Errors']
|
||||
from zai.core import BaseModel
|
||||
from zai.types.batch.batch_error import BatchError
|
||||
from zai.types.batch.batch_request_counts import BatchRequestCounts
|
||||
|
||||
|
||||
class Errors(BaseModel):
|
||||
|
|
@ -4,8 +4,6 @@ from typing import Dict, Optional
|
|||
|
||||
from typing_extensions import Literal, Required, TypedDict
|
||||
|
||||
__all__ = ['BatchCreateParams']
|
||||
|
||||
|
||||
class BatchCreateParams(TypedDict, total=False):
|
||||
completion_window: Required[str]
|
||||
|
|
@ -2,9 +2,7 @@
|
|||
|
||||
from typing import Optional
|
||||
|
||||
from ..core import BaseModel
|
||||
|
||||
__all__ = ['BatchError']
|
||||
from zai.core import BaseModel
|
||||
|
||||
|
||||
class BatchError(BaseModel):
|
||||
|
|
@ -2,8 +2,6 @@ from __future__ import annotations
|
|||
|
||||
from typing_extensions import TypedDict
|
||||
|
||||
__all__ = ['BatchListParams']
|
||||
|
||||
|
||||
class BatchListParams(TypedDict, total=False):
|
||||
"""
|
||||
|
|
@ -1,6 +1,4 @@
|
|||
from ..core import BaseModel
|
||||
|
||||
__all__ = ['BatchRequestCounts']
|
||||
from zai.core import BaseModel
|
||||
|
||||
|
||||
class BatchRequestCounts(BaseModel):
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
from .async_chat_completion import AsyncCompletion, AsyncTaskStatus
|
||||
from .chat_completion import (
|
||||
Completion,
|
||||
CompletionChoice,
|
||||
CompletionMessage,
|
||||
CompletionMessageToolCall,
|
||||
CompletionUsage,
|
||||
Function,
|
||||
)
|
||||
from .chat_completion_chunk import (
|
||||
AudioCompletionChunk,
|
||||
ChatCompletionChunk,
|
||||
Choice,
|
||||
ChoiceDelta,
|
||||
ChoiceDeltaFunctionCall,
|
||||
ChoiceDeltaToolCall,
|
||||
ChoiceDeltaToolCallFunction,
|
||||
)
|
||||
from .chat_completion_chunk import CompletionUsage as CompletionChunkUsage
|
||||
from .chat_completions_create_param import Reference
|
||||
from .code_geex.code_geex_params import CodeGeexContext, CodeGeexExtra, CodeGeexTarget
|
||||
|
||||
__all__ = [
|
||||
'AsyncTaskStatus',
|
||||
'AsyncCompletion',
|
||||
'Completion',
|
||||
'CompletionUsage',
|
||||
'Function',
|
||||
'CompletionMessageToolCall',
|
||||
'CompletionMessage',
|
||||
'CompletionChoice',
|
||||
'ChatCompletionChunk',
|
||||
'CompletionChunkUsage',
|
||||
'Choice',
|
||||
'ChoiceDelta',
|
||||
'ChoiceDeltaFunctionCall',
|
||||
'ChoiceDeltaToolCall',
|
||||
'ChoiceDeltaToolCallFunction',
|
||||
'AudioCompletionChunk',
|
||||
'Reference',
|
||||
'CodeGeexTarget',
|
||||
'CodeGeexContext',
|
||||
'CodeGeexExtra',
|
||||
]
|
||||
|
|
@ -1,9 +1,7 @@
|
|||
from typing import List, Optional
|
||||
|
||||
from ...core import BaseModel
|
||||
from .chat_completion import CompletionChoice, CompletionUsage
|
||||
|
||||
__all__ = ['AsyncTaskStatus', 'AsyncCompletion']
|
||||
from zai.core import BaseModel
|
||||
from zai.types.chat.chat_completion import CompletionChoice, CompletionUsage
|
||||
|
||||
|
||||
class AsyncTaskStatus(BaseModel):
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
from typing import List, Optional
|
||||
|
||||
from ...core import BaseModel
|
||||
|
||||
__all__ = ['Completion', 'CompletionUsage']
|
||||
from zai.core import BaseModel
|
||||
|
||||
|
||||
class Function(BaseModel):
|
||||
|
|
|
|||
|
|
@ -1,17 +1,6 @@
|
|||
from typing import Any, Dict, List, Optional
|
||||
|
||||
from ...core import BaseModel
|
||||
|
||||
__all__ = [
|
||||
'CompletionUsage',
|
||||
'ChatCompletionChunk',
|
||||
'Choice',
|
||||
'ChoiceDelta',
|
||||
'ChoiceDeltaFunctionCall',
|
||||
'ChoiceDeltaToolCall',
|
||||
'ChoiceDeltaToolCallFunction',
|
||||
'AudioCompletionChunk',
|
||||
]
|
||||
from zai.core import BaseModel
|
||||
|
||||
|
||||
class ChoiceDeltaFunctionCall(BaseModel):
|
||||
|
|
|
|||
|
|
@ -2,12 +2,6 @@ from typing import List, Optional
|
|||
|
||||
from typing_extensions import Literal, Required, TypedDict
|
||||
|
||||
__all__ = [
|
||||
'CodeGeexTarget',
|
||||
'CodeGeexContext',
|
||||
'CodeGeexExtra',
|
||||
]
|
||||
|
||||
|
||||
class CodeGeexTarget(TypedDict, total=False):
|
||||
"""
|
||||
|
|
|
|||
6
src/zai/types/embeddings/__init__.py
Normal file
6
src/zai/types/embeddings/__init__.py
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
from .embeddings import Embedding, EmbeddingsResponded
|
||||
|
||||
__all__ = [
|
||||
'Embedding',
|
||||
'EmbeddingsResponded',
|
||||
]
|
||||
|
|
@ -2,10 +2,8 @@ from __future__ import annotations
|
|||
|
||||
from typing import List, Optional
|
||||
|
||||
from ..core import BaseModel
|
||||
from .chat.chat_completion import CompletionUsage
|
||||
|
||||
__all__ = ['Embedding', 'EmbeddingsResponded']
|
||||
from zai.core import BaseModel
|
||||
from zai.types.chat.chat_completion import CompletionUsage
|
||||
|
||||
|
||||
class Embedding(BaseModel):
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
from .file_create_params import FileCreateParams
|
||||
from .file_deleted import FileDeleted
|
||||
from .file_object import FileObject, ListOfFileObject
|
||||
from .upload_detail import UploadDetail
|
||||
|
||||
__all__ = ['FileObject', 'ListOfFileObject', 'UploadDetail', 'FileDeleted']
|
||||
__all__ = ['FileObject', 'ListOfFileObject', 'UploadDetail', 'FileDeleted', 'FileCreateParams']
|
||||
|
|
|
|||
|
|
@ -4,10 +4,8 @@ from typing import List, Optional
|
|||
|
||||
from typing_extensions import Literal, Required, TypedDict
|
||||
|
||||
__all__ = ['FileCreateParams']
|
||||
|
||||
from ...core import FileTypes
|
||||
from . import UploadDetail
|
||||
from zai.core import FileTypes
|
||||
from zai.types.files.upload_detail import UploadDetail
|
||||
|
||||
|
||||
class FileCreateParams(TypedDict, total=False):
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
from typing_extensions import Literal
|
||||
|
||||
from ...core import BaseModel
|
||||
|
||||
__all__ = ['FileDeleted']
|
||||
from zai.core import BaseModel
|
||||
|
||||
|
||||
class FileDeleted(BaseModel):
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
from typing import List, Optional
|
||||
|
||||
from ...core import BaseModel
|
||||
|
||||
__all__ = ['FileObject', 'ListOfFileObject']
|
||||
from zai.core import BaseModel
|
||||
|
||||
|
||||
class FileObject(BaseModel):
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
from typing import Dict, List, Optional
|
||||
|
||||
from ...core import BaseModel
|
||||
from zai.core import BaseModel
|
||||
|
||||
|
||||
class UploadDetail(BaseModel):
|
||||
|
|
|
|||
|
|
@ -1,5 +1,16 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from .fine_tuning_job import FineTuningJob as FineTuningJob
|
||||
from .fine_tuning_job import ListOfFineTuningJob as ListOfFineTuningJob
|
||||
from .fine_tuning_job_event import FineTuningJobEvent as FineTuningJobEvent
|
||||
from .fine_tuning_job import Error, FineTuningJob, Hyperparameters, ListOfFineTuningJob
|
||||
from .fine_tuning_job_event import FineTuningJobEvent, JobEvent, Metric
|
||||
from .job_create_params import Hyperparameters as JobHyperparameters
|
||||
|
||||
__all__ = [
|
||||
'FineTuningJob',
|
||||
'Error',
|
||||
'Hyperparameters',
|
||||
'ListOfFineTuningJob',
|
||||
'FineTuningJobEvent',
|
||||
'Metric',
|
||||
'JobEvent',
|
||||
'JobHyperparameters',
|
||||
]
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
from typing import List, Optional, Union
|
||||
|
||||
from ...core import BaseModel
|
||||
|
||||
__all__ = ['FineTuningJob', 'Error', 'Hyperparameters', 'ListOfFineTuningJob']
|
||||
from zai.core import BaseModel
|
||||
|
||||
|
||||
class Error(BaseModel):
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
from typing import List, Optional, Union
|
||||
|
||||
from ...core import BaseModel
|
||||
|
||||
__all__ = ['FineTuningJobEvent', 'Metric', 'JobEvent']
|
||||
from zai.core import BaseModel
|
||||
|
||||
|
||||
class Metric(BaseModel):
|
||||
|
|
|
|||
|
|
@ -4,8 +4,6 @@ from typing import Union
|
|||
|
||||
from typing_extensions import Literal, TypedDict
|
||||
|
||||
__all__ = ['Hyperparameters']
|
||||
|
||||
|
||||
class Hyperparameters(TypedDict, total=False):
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
from typing import ClassVar
|
||||
|
||||
from ....core import PYDANTIC_V2, BaseModel, ConfigDict
|
||||
|
||||
__all__ = ['FineTunedModelsStatus']
|
||||
from zai.core import PYDANTIC_V2, BaseModel, ConfigDict
|
||||
|
||||
|
||||
class FineTunedModelsStatus(BaseModel):
|
||||
|
|
|
|||
6
src/zai/types/image/__init__.py
Normal file
6
src/zai/types/image/__init__.py
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
from .image import GeneratedImage, ImagesResponded
|
||||
|
||||
__all__ = [
|
||||
'GeneratedImage',
|
||||
'ImagesResponded',
|
||||
]
|
||||
|
|
@ -2,9 +2,7 @@ from __future__ import annotations
|
|||
|
||||
from typing import List, Optional
|
||||
|
||||
from ..core import BaseModel
|
||||
|
||||
__all__ = ['GeneratedImage', 'ImagesResponded']
|
||||
from zai.core import BaseModel
|
||||
|
||||
|
||||
class GeneratedImage(BaseModel):
|
||||
|
|
@ -1,8 +1,14 @@
|
|||
from .knowledge import KnowledgeInfo
|
||||
from .knowledge_create_params import KnowledgeBaseParams
|
||||
from .knowledge_list_params import KnowledgeListParams
|
||||
from .knowledge_list_resp import KnowledgePage
|
||||
from .knowledge_used import KnowledgeStatistics, KnowledgeUsed
|
||||
|
||||
__all__ = [
|
||||
'KnowledgeInfo',
|
||||
'KnowledgeStatistics',
|
||||
'KnowledgeUsed',
|
||||
'KnowledgeInfo',
|
||||
'KnowledgeStatistics',
|
||||
'KnowledgeUsed',
|
||||
'KnowledgeBaseParams',
|
||||
'KnowledgeListParams',
|
||||
'KnowledgePage',
|
||||
]
|
||||
|
|
|
|||
|
|
@ -1,13 +1,21 @@
|
|||
from .document import (
|
||||
DocumentData,
|
||||
DocumentFailedInfo,
|
||||
DocumentObject,
|
||||
DocumentSuccessinfo,
|
||||
DocumentData,
|
||||
DocumentDataFailInfo,
|
||||
DocumentFailedInfo,
|
||||
DocumentObject,
|
||||
DocumentSuccessinfo,
|
||||
)
|
||||
from .document_edit_params import DocumentEditParams
|
||||
from .document_list_params import DocumentListParams
|
||||
from .document_list_resp import DocumentPage
|
||||
|
||||
__all__ = [
|
||||
'DocumentData',
|
||||
'DocumentObject',
|
||||
'DocumentSuccessinfo',
|
||||
'DocumentFailedInfo',
|
||||
'DocumentData',
|
||||
'DocumentObject',
|
||||
'DocumentSuccessinfo',
|
||||
'DocumentFailedInfo',
|
||||
'DocumentDataFailInfo',
|
||||
'DocumentEditParams',
|
||||
'DocumentListParams',
|
||||
'DocumentPage',
|
||||
]
|
||||
|
|
|
|||
|
|
@ -1,13 +1,6 @@
|
|||
from typing import List, Optional
|
||||
|
||||
from ....core import BaseModel
|
||||
|
||||
__all__ = [
|
||||
'DocumentData',
|
||||
'DocumentObject',
|
||||
'DocumentSuccessinfo',
|
||||
'DocumentFailedInfo',
|
||||
]
|
||||
from zai.core import BaseModel
|
||||
|
||||
|
||||
class DocumentSuccessinfo(BaseModel):
|
||||
|
|
|
|||
|
|
@ -1,7 +1,5 @@
|
|||
from typing import Dict, List, Optional, TypedDict
|
||||
|
||||
__all__ = ['DocumentEditParams']
|
||||
|
||||
|
||||
class DocumentEditParams(TypedDict):
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -2,10 +2,8 @@ from __future__ import annotations
|
|||
|
||||
from typing import List
|
||||
|
||||
from ....core import BaseModel
|
||||
from . import DocumentData
|
||||
|
||||
__all__ = ['DocumentPage']
|
||||
from zai.core import BaseModel
|
||||
from zai.types.knowledge.document.document import DocumentData
|
||||
|
||||
|
||||
class DocumentPage(BaseModel):
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
from typing import Optional
|
||||
|
||||
from ...core import BaseModel
|
||||
|
||||
__all__ = ['KnowledgeInfo']
|
||||
from zai.core import BaseModel
|
||||
|
||||
|
||||
class KnowledgeInfo(BaseModel):
|
||||
|
|
|
|||
|
|
@ -4,8 +4,6 @@ from typing import Optional
|
|||
|
||||
from typing_extensions import Literal, TypedDict
|
||||
|
||||
__all__ = ['KnowledgeBaseParams']
|
||||
|
||||
|
||||
class KnowledgeBaseParams(TypedDict):
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -2,8 +2,6 @@ from __future__ import annotations
|
|||
|
||||
from typing_extensions import TypedDict
|
||||
|
||||
__all__ = ['KnowledgeListParams']
|
||||
|
||||
|
||||
class KnowledgeListParams(TypedDict, total=False):
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -2,10 +2,8 @@ from __future__ import annotations
|
|||
|
||||
from typing import List
|
||||
|
||||
from ...core import BaseModel
|
||||
from . import KnowledgeInfo
|
||||
|
||||
__all__ = ['KnowledgePage']
|
||||
from zai.core import BaseModel
|
||||
from zai.types.knowledge.knowledge import KnowledgeInfo
|
||||
|
||||
|
||||
class KnowledgePage(BaseModel):
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
from typing import Optional
|
||||
|
||||
from ...core import BaseModel
|
||||
|
||||
__all__ = ['KnowledgeStatistics', 'KnowledgeUsed']
|
||||
from zai.core import BaseModel
|
||||
|
||||
|
||||
class KnowledgeStatistics(BaseModel):
|
||||
|
|
|
|||
|
|
@ -0,0 +1,3 @@
|
|||
from .moderation_completion import Completion
|
||||
|
||||
__all__ = ['Completion']
|
||||
|
|
@ -1,8 +1,6 @@
|
|||
from typing import Dict, List, Optional, Union
|
||||
|
||||
from ...core import BaseModel
|
||||
|
||||
__all__ = ['Completion']
|
||||
from zai.core import BaseModel
|
||||
|
||||
|
||||
class Completion(BaseModel):
|
||||
|
|
|
|||
|
|
@ -1,15 +1,26 @@
|
|||
from .tools_web_search_params import WebSearchParams
|
||||
from .web_search import (
|
||||
SearchIntent,
|
||||
SearchRecommend,
|
||||
SearchResult,
|
||||
WebSearch,
|
||||
SearchIntent,
|
||||
SearchRecommend,
|
||||
SearchResult,
|
||||
WebSearch,
|
||||
WebSearchChoice,
|
||||
WebSearchMessage,
|
||||
WebSearchMessageToolCall,
|
||||
)
|
||||
from .web_search_chunk import WebSearchChunk
|
||||
from .web_search_chunk import Choice, ChoiceDelta, ChoiceDeltaToolCall, WebSearchChunk
|
||||
|
||||
__all__ = [
|
||||
'WebSearch',
|
||||
'SearchIntent',
|
||||
'SearchResult',
|
||||
'SearchRecommend',
|
||||
'WebSearchChunk',
|
||||
'WebSearch',
|
||||
'SearchIntent',
|
||||
'SearchResult',
|
||||
'SearchRecommend',
|
||||
'WebSearchMessageToolCall',
|
||||
'WebSearchMessage',
|
||||
'WebSearchChoice',
|
||||
'WebSearchChunk',
|
||||
'ChoiceDeltaToolCall',
|
||||
'ChoiceDelta',
|
||||
'Choice',
|
||||
'WebSearchParams',
|
||||
]
|
||||
|
|
|
|||
|
|
@ -4,8 +4,6 @@ from typing import List, Optional, Union
|
|||
|
||||
from typing_extensions import TypedDict
|
||||
|
||||
__all__ = ['WebSearchParams']
|
||||
|
||||
|
||||
class WebSearchParams(TypedDict):
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -1,13 +1,6 @@
|
|||
from typing import List, Optional
|
||||
|
||||
from ...core import BaseModel
|
||||
|
||||
__all__ = [
|
||||
'WebSearch',
|
||||
'SearchIntent',
|
||||
'SearchResult',
|
||||
'SearchRecommend',
|
||||
]
|
||||
from zai.core import BaseModel
|
||||
|
||||
|
||||
class SearchIntent(BaseModel):
|
||||
|
|
|
|||
|
|
@ -1,9 +1,7 @@
|
|||
from typing import List, Optional
|
||||
|
||||
from ...core import BaseModel
|
||||
from .web_search import SearchIntent, SearchRecommend, SearchResult
|
||||
|
||||
__all__ = ['WebSearchChunk']
|
||||
from zai.core import BaseModel
|
||||
from zai.types.tools.web_search import SearchIntent, SearchRecommend, SearchResult
|
||||
|
||||
|
||||
class ChoiceDeltaToolCall(BaseModel):
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
from .video_create_params import VideoCreateParams
|
||||
from .video_object import VideoObject, VideoResult
|
||||
|
||||
__all__ = ['VideoObject', 'VideoResult']
|
||||
__all__ = ['VideoObject', 'VideoResult', 'VideoCreateParams']
|
||||
|
|
|
|||
|
|
@ -4,9 +4,7 @@ from typing import Optional
|
|||
|
||||
from typing_extensions import TypedDict
|
||||
|
||||
__all__ = ['VideoCreateParams']
|
||||
|
||||
from ..sensitive_word_check import SensitiveWordCheckRequest
|
||||
from zai.types.sensitive_word_check import SensitiveWordCheckRequest
|
||||
|
||||
|
||||
class VideoCreateParams(TypedDict, total=False):
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
from typing import List, Optional
|
||||
|
||||
from ...core import BaseModel
|
||||
|
||||
__all__ = ['VideoObject', 'VideoResult']
|
||||
from zai.core import BaseModel
|
||||
|
||||
|
||||
class VideoResult(BaseModel):
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
from .web_search_create_params import WebSearchCreatParams
|
||||
from .web_search_resp import SearchIntentResp, SearchResultResp, WebSearchResp
|
||||
|
||||
__all__ = ['WebSearchCreatParams']
|
||||
__all__ = ['WebSearchCreatParams', 'WebSearchResp', 'SearchIntentResp', 'SearchResultResp']
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue