# RCK Python SDK - Programming Guide
An elegant Python SDK that uses RCK (Relational Calculate Kernel) as an intelligent function kernel.
[](https://badge.fury.io/py/rck-python-sdk)
[](https://python.org)
## π Quick Start
### Installation
```bash
pip install rck-python-sdk
```
### Basic Usage
```python
from rck_sdk import RCKClient
# Initialize client
client = RCKClient(api_key="your-api-key")
# Use RCK as intelligent function kernel
result = client.compute.custom_compute(
text="Spring has arrived, all things are reviving",
task="Analyze sentiment and generate corresponding poetry"
)
print(result.data)
```
## π Complete Example
Here's a comprehensive example demonstrating all major SDK features:
```python
from rck_sdk import RCKClient
# Initialize client
client = RCKClient(api_key="your-api-key")
def run_complete_example():
"""Complete SDK feature demonstration"""
print("=== RCK Python SDK Complete Example ===\n")
# 1. Test connection
print("1. Testing connection...")
connection_test = client.test_connection()
if connection_test["status"] == "success":
print("β
Connection successful")
else:
print(f"β Connection failed: {connection_test['message']}")
return
# 2. Text analysis
print("\n2. Text Analysis Example:")
poem_text = "Moonlight before my bed, looks like frost on the ground. I raise my head to see the moon, lower it to think of home."
analysis_result = client.compute.analyze(
text=poem_text,
task="Analyze the emotion and theme of this poetry",
output_format="basic_analysis"
)
print(f"Original text: {poem_text}")
print(f"Analysis result:")
for key, value in analysis_result.data.items():
print(f" {key}: {value}")
# 3. Translation functionality
print("\n3. Translation Example:")
translation_result = client.compute.translate(
text=poem_text,
target_language="French",
include_cultural_notes=True
)
print(f"French translation: {translation_result.data.get('translation', 'N/A')}")
if 'cultural_notes' in translation_result.data:
print(f"Cultural notes: {translation_result.data['cultural_notes'][:100]}...")
# 4. Custom schema computation
print("\n4. Custom Schema Example:")
custom_schema = {
"type": "object",
"properties": {
"poem": {"type": "string", "description": "Created poetry"},
"creative_process": {"type": "string", "description": "Creative thinking process"},
"style_notes": {"type": "string", "description": "Style explanation"}
},
"required": ["poem"]
}
poem_creation = client.compute.custom_compute(
text="Spring flowers blooming in the garden",
task="Create a poem based on this theme",
output_schema=custom_schema,
style="modern free verse",
mood="joyful and peaceful"
)
print(f"Created poem: {poem_creation.data.get('poem', 'N/A')}")
if 'creative_process' in poem_creation.data:
print(f"Creative process: {poem_creation.data['creative_process'][:100]}...")
# 5. Image generation
print("\n5. Image Generation Example:")
image_result = client.image.generate(
prompt="A serene mountain lake reflecting the sky",
composition="Wide panoramic view showcasing natural beauty",
lighting="Soft morning sunlight creating peaceful atmosphere",
style="Traditional Chinese landscape painting style with ink wash"
)
if image_result.success:
print(f"β
Image generation successful: {image_result.count} images created")
# Save images (optional)
try:
saved_files = client.image.save_images(image_result, "example_landscape", ".")
print(f"Images saved: {saved_files}")
except Exception as e:
print(f"Image saving failed: {e}")
else:
print("β Image generation failed")
# 6. Multi-style batch generation
print("\n6. Batch Style Generation Example:")
styles = [
"Traditional Chinese ink wash painting",
"European classical oil painting style",
"Modern abstract art style"
]
batch_results = []
for style in styles:
try:
result = client.image.generate(
prompt="Peaceful lake reflecting distant mountains",
composition="Classic composition with harmonious balance",
lighting="Natural lighting, soft and bright",
style=style
)
batch_results.append({
"style": style,
"success": result.success,
"count": result.count if result.success else 0
})
except Exception as e:
batch_results.append({
"style": style,
"success": False,
"error": str(e)
})
print("Batch generation results:")
for result in batch_results:
status = "β
" if result["success"] else "β"
print(f" {status} {result['style'][:30]}... - {result.get('count', 0)} images")
# 7. Multimodal creation with resources
print("\n7. Multimodal Creation Example:")
multimodal_result = client.compute.create_poem(
inspiration="Feel the artistic conception depicted in these images",
style="five-character quatrain",
resources=[
{"nature_scene": "https://example.com/nature.jpg"},
{"sunset_view": "https://example.com/sunset.jpg"}
]
)
if "poem" in multimodal_result.data:
print(f"Multimodal creation result: {multimodal_result.data['poem']}")
else:
print("Multimodal creation completed (check full response for details)")
# 8. Advanced workflow: Poem to Image
print("\n8. Advanced Workflow - Poem to Scene to Image:")
# Step 1: Convert poem to scene description
scene_schema = {
"type": "object",
"properties": {
"scene_description": {
"type": "object",
"properties": {
"main_subjects": {"type": "string"},
"lighting": {"type": "string"},
"composition": {"type": "string"},
"style": {"type": "string"}
}
}
}
}
original_poem = "Empty mountains, no one in sight, but hearing human voices echo. Returning light enters deep forest, again illuminating green moss."
scene_result = client.compute.custom_compute(
text=original_poem,
task="Analyze the poem content and create detailed visual scene description",
output_schema=scene_schema,
target_art_style="Traditional Chinese landscape painting"
)
if "scene_description" in scene_result.data:
scene_desc = scene_result.data["scene_description"]
print(f"Scene conversion successful:")
print(f" Main subjects: {scene_desc.get('main_subjects', 'N/A')}")
# Step 2: Generate image from scene description
workflow_image = client.image.generate(
prompt=scene_desc.get("main_subjects", "Poetic landscape scene"),
composition=scene_desc.get("composition", "Classic composition"),
lighting=scene_desc.get("lighting", "Natural lighting"),
style=scene_desc.get("style", "Traditional Chinese landscape painting")
)
if workflow_image.success:
print(f" β
Workflow completed: Poem β Scene β Image ({workflow_image.count} images)")
else:
print(f" β Image generation step failed")
else:
print("Scene description conversion failed")
print("\n=== Example Complete ===")
print("This example demonstrates:")
print("β’ Basic text analysis and translation")
print("β’ Custom schema and output formatting")
print("β’ Single and batch image generation")
print("β’ Multimodal resource processing")
print("β’ Advanced multi-step workflows")
# Run the complete example
if __name__ == "__main__":
# Replace with your actual API key
client = RCKClient(api_key="your-api-key-here")
run_complete_example()
```
### Expected Output
When you run the complete example, you should see output similar to:
```
=== RCK Python SDK Complete Example ===
1. Testing connection...
β
Connection successful
2. Text Analysis Example:
Original text: Moonlight before my bed, looks like frost on the ground. I raise my head to see the moon, lower it to think of home.
Analysis result:
emotion: nostalgic and melancholic
theme: homesickness and longing
analysis: This classical Chinese poem expresses deep feelings of homesickness...
3. Translation Example:
French translation: Devant mon lit, la clartΓ© de la lune, on dirait du givre sur le sol...
Cultural notes: This is one of the most famous poems by Li Bai, representing the classical Chinese literary tradition...
4. Custom Schema Example:
Created poem: Spring flowers dance in morning light, / Petals whisper secrets bright...
Creative process: I focused on capturing the joyful essence of spring blooms...
5. Image Generation Example:
β
Image generation successful: 1 images created
Images saved: ['example_landscape_1.png']
6. Batch Style Generation Example:
Batch generation results:
β
Traditional Chinese ink wash painting... - 1 images
β
European classical oil painting style... - 1 images
β
Modern abstract art style... - 1 images
7. Multimodal Creation Example:
Multimodal creation result: Mountain peaks touch azure sky, / River flows through valley green...
8. Advanced Workflow - Poem to Scene to Image:
Scene conversion successful:
Main subjects: Empty mountain valley with ancient forest, moss-covered rocks, filtered sunlight
β
Workflow completed: Poem β Scene β Image (1 images)
=== Example Complete ===
```
## π§ RCK Compute Engine Core Concepts
RCK compute engine is based on two core components: **Start Point** and **Path**, allowing you to encapsulate complex AI logic into simple Python functions.
### Start Point: Define Initial State
`start_point` is the input for computation, containing two parts:
- **startPoint** (string): Core text prompt
- **resource** (array, optional): Additional non-text resources like images
```python
# Pure text input
{
"start_point": {
"startPoint": "Moonlight before my bed, looks like frost on the ground"
}
}
# Multimodal input (text + images)
{
"start_point": {
"startPoint": "Please combine the desolation of 'Image One' with the vastness of 'Image Two' to describe a scene.",
"resource": [
{"Image One": "https://url.to/image1.png"},
{"Image Two": "https://url.to/image2.png"}
]
}
}
```
### Path: Apply Constraints and Define Goals
`path` is a declarative constraint on the transformation process:
- **expectPath** (string): Core instruction telling AI "what to do"
- **Custom Fields** (any): Any custom fields as auxiliary constraints
```python
{
"path": {
"expectPath": "Analyze the emotional tone of the poetry and create a modern poem with corresponding mood",
"style": "modern free verse",
"mood": "tranquil and profound",
"target_length": "4-6 lines"
}
}
```
## π― Recommended Usage Pattern: Functional Encapsulation
Use RCK as the intelligent kernel of functions, encapsulating complex AI logic into simple Python functions:
### Example 1: Sentiment Analysis Function
```python
def analyze_emotion(text, language="english"):
"""Analyze text sentiment using RCK engine"""
result = client.compute.custom_compute(
text=text,
task="Analyze the emotional tendency and intensity of the text",
output_schema={
"type": "object",
"properties": {
"emotion": {"type": "string"},
"intensity": {"type": "number"},
"keywords": {"type": "array"}
}
},
language=language,
analysis_depth="detailed"
)
return result.data
# Use the function
emotion_result = analyze_emotion("Today is sunny and I feel particularly good")
print(f"Emotion: {emotion_result['emotion']}")
print(f"Intensity: {emotion_result['intensity']}")
```
### Example 2: Intelligent Summary Generation Function
```python
def intelligent_summary(content, max_length=100, style="professional"):
"""Generate intelligent summary using RCK engine"""
result = client.compute.custom_compute(
text=content,
task=f"Generate a summary within {max_length} words",
style=style,
focus="core viewpoints",
output_format="concise and clear"
)
return result.data.get('summary', '')
# Use the function
long_text = "This is a very long article content..."
summary = intelligent_summary(long_text, max_length=50, style="academic")
print(summary)
```
### Example 3: Multimodal Creation Function
```python
def create_poem_from_image(image_url, poem_style="five-character quatrain"):
"""Create poetry based on image"""
result = client.compute.custom_compute(
text="Please create poetry based on the artistic conception of the image",
task="Observe image content, feel its artistic conception, and create poetry in corresponding style",
resources=[{"inspiration_image": image_url}],
output_schema={
"type": "object",
"properties": {
"poem": {"type": "string"},
"inspiration": {"type": "string"},
"mood": {"type": "string"}
}
},
style=poem_style,
cultural_background="classical literature"
)
return result.data
# Use the function
poem_result = create_poem_from_image(
"https://example.com/sunset.jpg",
"seven-character regulated verse"
)
print(f"Poem: {poem_result['poem']}")
print(f"Inspiration: {poem_result['inspiration']}")
```
### Example 4: Complex Logic Workflow Function
```python
def complex_analysis_workflow(data, analysis_type="comprehensive"):
"""Complex analysis workflow using Mermaid diagram to define logic"""
mermaid_flow = """
graph TD
A[Input Analysis] --> B{Determine Type}
B -->|Text| C[Text Sentiment Analysis]
B -->|Data| D[Data Pattern Recognition]
C --> E[Generate Suggestions]
D --> E[Generate Suggestions]
E --> F[Output Results]
"""
result = client.compute.custom_compute(
text=data,
task=f"Analyze according to the following workflow: {mermaid_flow}",
analysis_type=analysis_type,
depth="deep analysis",
output_schema={
"type": "object",
"properties": {
"analysis_result": {"type": "string"},
"suggestions": {"type": "array"},
"confidence": {"type": "number"}
}
}
)
return result.data
# Use the function
analysis = complex_analysis_workflow(
"User feedback data...",
"comprehensive"
)
```
## π Unlimited Flexibility in Language and Format
RCK supports extreme flexibility:
### Any Language
```python
# English processing
result = client.compute.custom_compute(
text="To be or not to be, that is the question",
task="Analyze the philosophical connotations of this Shakespeare quote"
)
# Chinese processing
result = client.compute.custom_compute(
text="ζ₯η δΈθ§ζοΌε€ε€ι»εΌιΈ",
task="Translate to English while preserving poetic sentiment"
)
# Multi-language mixing
result = client.compute.custom_compute(
text="Hello world, Bonjour le monde",
task="Identify languages and translate uniformly to English"
)
```
### Any Format
```python
# Mathematical formulas
result = client.compute.custom_compute(
text="f(x) = x^2 - 4x + 3",
task="Find the minimum value of the function and describe the graph",
custom_code="def calculate_min(x): return x**2 - 4*x + 3"
)
# Code analysis
result = client.compute.custom_compute(
text="""
def fibonacci(n):
if n <= 1:
return n
return fibonacci(n-1) + fibonacci(n-2)
""",
task="Analyze code complexity and provide optimization suggestions",
language="Python"
)
# JSON data processing
result = client.compute.custom_compute(
text='{"users": [{"name": "Alice", "age": 30}]}',
task="Analyze data structure and generate data report",
format="JSON"
)
```
## π¨ Image Generation Features
In addition to text computation, the SDK provides powerful image generation capabilities:
```python
def generate_artwork(description, art_style="modern art"):
"""Generate artwork"""
image = client.image.generate(
prompt=description,
composition="centered composition with strong visual impact",
lighting="dramatic lighting effects",
style=art_style
)
if image.success:
# Save images
saved_files = client.image.save_images(image, "artwork")
return {
"success": True,
"image_count": image.count,
"saved_files": saved_files
}
else:
return {"success": False, "error": "Image generation failed"}
# Use the function
artwork = generate_artwork(
"A lonely traveler walking under the starry sky",
"Van Gogh style oil painting"
)
print(f"Generation result: {artwork}")
```
## π§ Complete Example: Intelligent Assistant Function
```python
class IntelligentAssistant:
def __init__(self, api_key):
self.client = RCKClient(api_key=api_key)
def process_request(self, user_input, context="general"):
"""Intelligently process user requests"""
# First analyze user intent
intent_analysis = self.client.compute.custom_compute(
text=user_input,
task="Analyze user intent and categorize",
output_schema={
"type": "object",
"properties": {
"intent": {"type": "string"},
"confidence": {"type": "number"},
"required_action": {"type": "string"}
}
},
context=context
)
intent = intent_analysis.data.get('intent', 'unknown')
# Execute different processing logic based on intent
if intent == "creative_writing":
return self._handle_creative_request(user_input)
elif intent == "data_analysis":
return self._handle_analysis_request(user_input)
else:
return self._handle_general_request(user_input)
def _handle_creative_request(self, user_input):
"""Handle creative requests"""
result = self.client.compute.custom_compute(
text=user_input,
task="Create content based on user needs",
creativity_level="high",
style="engaging",
length="moderate"
)
return result.data
def _handle_analysis_request(self, user_input):
"""Handle analysis requests"""
result = self.client.compute.custom_compute(
text=user_input,
task="Conduct in-depth analysis and provide insights",
analysis_depth="detailed",
include_suggestions="yes",
format="structured"
)
return result.data
def _handle_general_request(self, user_input):
"""Handle general requests"""
result = self.client.compute.custom_compute(
text=user_input,
task="Provide helpful answers and suggestions",
tone="friendly",
detail_level="moderate"
)
return result.data
# Use intelligent assistant
assistant = IntelligentAssistant(api_key="your-api-key")
# Process different types of requests
creative_result = assistant.process_request(
"Help me write a poem about autumn",
context="creative"
)
analysis_result = assistant.process_request(
"Analyze the trends in this sales data",
context="business"
)
```
## π License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
## π Contact Support
For questions or assistance, please contact:
π§ **Email**: omorsablin@gmail.com
---
> π‘ **Core Philosophy**: Use RCK as an intelligent function kernel, describing "what to do" declaratively rather than "how to do it". Let AI handle complex logic while you only need to define inputs, constraints, and expected outputs.
```
Raw data
{
"_id": null,
"home_page": "https://github.com/rck/rck-python-sdk",
"name": "rck-python-sdk",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.7",
"maintainer_email": null,
"keywords": "rck, ai, text-analysis, image-generation, api-client",
"author": "RCK Team",
"author_email": "RCK Team <support@rck.ai>",
"download_url": "https://files.pythonhosted.org/packages/56/a7/2f8e5fed77f6b6fbb07db161b58ab8075ee6eb4324febdf705def6d90b82/rck_python_sdk-1.0.1.tar.gz",
"platform": null,
"description": "\r\n# RCK Python SDK - Programming Guide\r\n\r\nAn elegant Python SDK that uses RCK (Relational Calculate Kernel) as an intelligent function kernel.\r\n\r\n[](https://badge.fury.io/py/rck-python-sdk)\r\n[](https://python.org)\r\n\r\n## \ud83d\ude80 Quick Start\r\n\r\n### Installation\r\n\r\n```bash\r\npip install rck-python-sdk\r\n```\r\n\r\n### Basic Usage\r\n\r\n```python\r\nfrom rck_sdk import RCKClient\r\n\r\n# Initialize client\r\nclient = RCKClient(api_key=\"your-api-key\")\r\n\r\n# Use RCK as intelligent function kernel\r\nresult = client.compute.custom_compute(\r\n text=\"Spring has arrived, all things are reviving\",\r\n task=\"Analyze sentiment and generate corresponding poetry\"\r\n)\r\nprint(result.data)\r\n```\r\n\r\n## \ud83d\udccb Complete Example\r\n\r\nHere's a comprehensive example demonstrating all major SDK features:\r\n\r\n```python\r\nfrom rck_sdk import RCKClient\r\n\r\n# Initialize client\r\nclient = RCKClient(api_key=\"your-api-key\")\r\n\r\ndef run_complete_example():\r\n \"\"\"Complete SDK feature demonstration\"\"\"\r\n \r\n print(\"=== RCK Python SDK Complete Example ===\\n\")\r\n \r\n # 1. Test connection\r\n print(\"1. Testing connection...\")\r\n connection_test = client.test_connection()\r\n if connection_test[\"status\"] == \"success\":\r\n print(\"\u2705 Connection successful\")\r\n else:\r\n print(f\"\u274c Connection failed: {connection_test['message']}\")\r\n return\r\n \r\n # 2. Text analysis\r\n print(\"\\n2. Text Analysis Example:\")\r\n poem_text = \"Moonlight before my bed, looks like frost on the ground. I raise my head to see the moon, lower it to think of home.\"\r\n \r\n analysis_result = client.compute.analyze(\r\n text=poem_text,\r\n task=\"Analyze the emotion and theme of this poetry\",\r\n output_format=\"basic_analysis\"\r\n )\r\n \r\n print(f\"Original text: {poem_text}\")\r\n print(f\"Analysis result:\")\r\n for key, value in analysis_result.data.items():\r\n print(f\" {key}: {value}\")\r\n \r\n # 3. Translation functionality\r\n print(\"\\n3. Translation Example:\")\r\n translation_result = client.compute.translate(\r\n text=poem_text,\r\n target_language=\"French\",\r\n include_cultural_notes=True\r\n )\r\n \r\n print(f\"French translation: {translation_result.data.get('translation', 'N/A')}\")\r\n if 'cultural_notes' in translation_result.data:\r\n print(f\"Cultural notes: {translation_result.data['cultural_notes'][:100]}...\")\r\n \r\n # 4. Custom schema computation\r\n print(\"\\n4. Custom Schema Example:\")\r\n custom_schema = {\r\n \"type\": \"object\",\r\n \"properties\": {\r\n \"poem\": {\"type\": \"string\", \"description\": \"Created poetry\"},\r\n \"creative_process\": {\"type\": \"string\", \"description\": \"Creative thinking process\"},\r\n \"style_notes\": {\"type\": \"string\", \"description\": \"Style explanation\"}\r\n },\r\n \"required\": [\"poem\"]\r\n }\r\n \r\n poem_creation = client.compute.custom_compute(\r\n text=\"Spring flowers blooming in the garden\",\r\n task=\"Create a poem based on this theme\",\r\n output_schema=custom_schema,\r\n style=\"modern free verse\",\r\n mood=\"joyful and peaceful\"\r\n )\r\n \r\n print(f\"Created poem: {poem_creation.data.get('poem', 'N/A')}\")\r\n if 'creative_process' in poem_creation.data:\r\n print(f\"Creative process: {poem_creation.data['creative_process'][:100]}...\")\r\n \r\n # 5. Image generation\r\n print(\"\\n5. Image Generation Example:\")\r\n image_result = client.image.generate(\r\n prompt=\"A serene mountain lake reflecting the sky\",\r\n composition=\"Wide panoramic view showcasing natural beauty\",\r\n lighting=\"Soft morning sunlight creating peaceful atmosphere\",\r\n style=\"Traditional Chinese landscape painting style with ink wash\"\r\n )\r\n \r\n if image_result.success:\r\n print(f\"\u2705 Image generation successful: {image_result.count} images created\")\r\n \r\n # Save images (optional)\r\n try:\r\n saved_files = client.image.save_images(image_result, \"example_landscape\", \".\")\r\n print(f\"Images saved: {saved_files}\")\r\n except Exception as e:\r\n print(f\"Image saving failed: {e}\")\r\n else:\r\n print(\"\u274c Image generation failed\")\r\n \r\n # 6. Multi-style batch generation\r\n print(\"\\n6. Batch Style Generation Example:\")\r\n styles = [\r\n \"Traditional Chinese ink wash painting\",\r\n \"European classical oil painting style\",\r\n \"Modern abstract art style\"\r\n ]\r\n \r\n batch_results = []\r\n for style in styles:\r\n try:\r\n result = client.image.generate(\r\n prompt=\"Peaceful lake reflecting distant mountains\",\r\n composition=\"Classic composition with harmonious balance\",\r\n lighting=\"Natural lighting, soft and bright\",\r\n style=style\r\n )\r\n batch_results.append({\r\n \"style\": style,\r\n \"success\": result.success,\r\n \"count\": result.count if result.success else 0\r\n })\r\n except Exception as e:\r\n batch_results.append({\r\n \"style\": style,\r\n \"success\": False,\r\n \"error\": str(e)\r\n })\r\n \r\n print(\"Batch generation results:\")\r\n for result in batch_results:\r\n status = \"\u2705\" if result[\"success\"] else \"\u274c\"\r\n print(f\" {status} {result['style'][:30]}... - {result.get('count', 0)} images\")\r\n \r\n # 7. Multimodal creation with resources\r\n print(\"\\n7. Multimodal Creation Example:\")\r\n multimodal_result = client.compute.create_poem(\r\n inspiration=\"Feel the artistic conception depicted in these images\",\r\n style=\"five-character quatrain\",\r\n resources=[\r\n {\"nature_scene\": \"https://example.com/nature.jpg\"},\r\n {\"sunset_view\": \"https://example.com/sunset.jpg\"}\r\n ]\r\n )\r\n \r\n if \"poem\" in multimodal_result.data:\r\n print(f\"Multimodal creation result: {multimodal_result.data['poem']}\")\r\n else:\r\n print(\"Multimodal creation completed (check full response for details)\")\r\n \r\n # 8. Advanced workflow: Poem to Image\r\n print(\"\\n8. Advanced Workflow - Poem to Scene to Image:\")\r\n \r\n # Step 1: Convert poem to scene description\r\n scene_schema = {\r\n \"type\": \"object\",\r\n \"properties\": {\r\n \"scene_description\": {\r\n \"type\": \"object\",\r\n \"properties\": {\r\n \"main_subjects\": {\"type\": \"string\"},\r\n \"lighting\": {\"type\": \"string\"},\r\n \"composition\": {\"type\": \"string\"},\r\n \"style\": {\"type\": \"string\"}\r\n }\r\n }\r\n }\r\n }\r\n \r\n original_poem = \"Empty mountains, no one in sight, but hearing human voices echo. Returning light enters deep forest, again illuminating green moss.\"\r\n \r\n scene_result = client.compute.custom_compute(\r\n text=original_poem,\r\n task=\"Analyze the poem content and create detailed visual scene description\",\r\n output_schema=scene_schema,\r\n target_art_style=\"Traditional Chinese landscape painting\"\r\n )\r\n \r\n if \"scene_description\" in scene_result.data:\r\n scene_desc = scene_result.data[\"scene_description\"]\r\n print(f\"Scene conversion successful:\")\r\n print(f\" Main subjects: {scene_desc.get('main_subjects', 'N/A')}\")\r\n \r\n # Step 2: Generate image from scene description\r\n workflow_image = client.image.generate(\r\n prompt=scene_desc.get(\"main_subjects\", \"Poetic landscape scene\"),\r\n composition=scene_desc.get(\"composition\", \"Classic composition\"),\r\n lighting=scene_desc.get(\"lighting\", \"Natural lighting\"),\r\n style=scene_desc.get(\"style\", \"Traditional Chinese landscape painting\")\r\n )\r\n \r\n if workflow_image.success:\r\n print(f\" \u2705 Workflow completed: Poem \u2192 Scene \u2192 Image ({workflow_image.count} images)\")\r\n else:\r\n print(f\" \u274c Image generation step failed\")\r\n else:\r\n print(\"Scene description conversion failed\")\r\n \r\n print(\"\\n=== Example Complete ===\")\r\n print(\"This example demonstrates:\")\r\n print(\"\u2022 Basic text analysis and translation\")\r\n print(\"\u2022 Custom schema and output formatting\")\r\n print(\"\u2022 Single and batch image generation\")\r\n print(\"\u2022 Multimodal resource processing\")\r\n print(\"\u2022 Advanced multi-step workflows\")\r\n\r\n# Run the complete example\r\nif __name__ == \"__main__\":\r\n # Replace with your actual API key\r\n client = RCKClient(api_key=\"your-api-key-here\")\r\n run_complete_example()\r\n```\r\n\r\n### Expected Output\r\n\r\nWhen you run the complete example, you should see output similar to:\r\n\r\n```\r\n=== RCK Python SDK Complete Example ===\r\n\r\n1. Testing connection...\r\n\u2705 Connection successful\r\n\r\n2. Text Analysis Example:\r\nOriginal text: Moonlight before my bed, looks like frost on the ground. I raise my head to see the moon, lower it to think of home.\r\nAnalysis result:\r\n emotion: nostalgic and melancholic\r\n theme: homesickness and longing\r\n analysis: This classical Chinese poem expresses deep feelings of homesickness...\r\n\r\n3. Translation Example:\r\nFrench translation: Devant mon lit, la clart\u00e9 de la lune, on dirait du givre sur le sol...\r\nCultural notes: This is one of the most famous poems by Li Bai, representing the classical Chinese literary tradition...\r\n\r\n4. Custom Schema Example:\r\nCreated poem: Spring flowers dance in morning light, / Petals whisper secrets bright...\r\nCreative process: I focused on capturing the joyful essence of spring blooms...\r\n\r\n5. Image Generation Example:\r\n\u2705 Image generation successful: 1 images created\r\nImages saved: ['example_landscape_1.png']\r\n\r\n6. Batch Style Generation Example:\r\nBatch generation results:\r\n \u2705 Traditional Chinese ink wash painting... - 1 images\r\n \u2705 European classical oil painting style... - 1 images\r\n \u2705 Modern abstract art style... - 1 images\r\n\r\n7. Multimodal Creation Example:\r\nMultimodal creation result: Mountain peaks touch azure sky, / River flows through valley green...\r\n\r\n8. Advanced Workflow - Poem to Scene to Image:\r\nScene conversion successful:\r\n Main subjects: Empty mountain valley with ancient forest, moss-covered rocks, filtered sunlight\r\n \u2705 Workflow completed: Poem \u2192 Scene \u2192 Image (1 images)\r\n\r\n=== Example Complete ===\r\n```\r\n\r\n## \ud83e\udde0 RCK Compute Engine Core Concepts\r\n\r\nRCK compute engine is based on two core components: **Start Point** and **Path**, allowing you to encapsulate complex AI logic into simple Python functions.\r\n\r\n### Start Point: Define Initial State\r\n\r\n`start_point` is the input for computation, containing two parts:\r\n\r\n- **startPoint** (string): Core text prompt\r\n- **resource** (array, optional): Additional non-text resources like images\r\n\r\n```python\r\n# Pure text input\r\n{\r\n \"start_point\": {\r\n \"startPoint\": \"Moonlight before my bed, looks like frost on the ground\"\r\n }\r\n}\r\n\r\n# Multimodal input (text + images)\r\n{\r\n \"start_point\": {\r\n \"startPoint\": \"Please combine the desolation of 'Image One' with the vastness of 'Image Two' to describe a scene.\",\r\n \"resource\": [\r\n {\"Image One\": \"https://url.to/image1.png\"},\r\n {\"Image Two\": \"https://url.to/image2.png\"}\r\n ]\r\n }\r\n}\r\n```\r\n\r\n### Path: Apply Constraints and Define Goals\r\n\r\n`path` is a declarative constraint on the transformation process:\r\n\r\n- **expectPath** (string): Core instruction telling AI \"what to do\"\r\n- **Custom Fields** (any): Any custom fields as auxiliary constraints\r\n\r\n```python\r\n{\r\n \"path\": {\r\n \"expectPath\": \"Analyze the emotional tone of the poetry and create a modern poem with corresponding mood\",\r\n \"style\": \"modern free verse\",\r\n \"mood\": \"tranquil and profound\",\r\n \"target_length\": \"4-6 lines\"\r\n }\r\n}\r\n```\r\n\r\n## \ud83c\udfaf Recommended Usage Pattern: Functional Encapsulation\r\n\r\nUse RCK as the intelligent kernel of functions, encapsulating complex AI logic into simple Python functions:\r\n\r\n### Example 1: Sentiment Analysis Function\r\n\r\n```python\r\ndef analyze_emotion(text, language=\"english\"):\r\n \"\"\"Analyze text sentiment using RCK engine\"\"\"\r\n \r\n result = client.compute.custom_compute(\r\n text=text,\r\n task=\"Analyze the emotional tendency and intensity of the text\",\r\n output_schema={\r\n \"type\": \"object\",\r\n \"properties\": {\r\n \"emotion\": {\"type\": \"string\"},\r\n \"intensity\": {\"type\": \"number\"},\r\n \"keywords\": {\"type\": \"array\"}\r\n }\r\n },\r\n language=language,\r\n analysis_depth=\"detailed\"\r\n )\r\n \r\n return result.data\r\n\r\n# Use the function\r\nemotion_result = analyze_emotion(\"Today is sunny and I feel particularly good\")\r\nprint(f\"Emotion: {emotion_result['emotion']}\")\r\nprint(f\"Intensity: {emotion_result['intensity']}\")\r\n```\r\n\r\n### Example 2: Intelligent Summary Generation Function\r\n\r\n```python\r\ndef intelligent_summary(content, max_length=100, style=\"professional\"):\r\n \"\"\"Generate intelligent summary using RCK engine\"\"\"\r\n \r\n result = client.compute.custom_compute(\r\n text=content,\r\n task=f\"Generate a summary within {max_length} words\",\r\n style=style,\r\n focus=\"core viewpoints\",\r\n output_format=\"concise and clear\"\r\n )\r\n \r\n return result.data.get('summary', '')\r\n\r\n# Use the function\r\nlong_text = \"This is a very long article content...\"\r\nsummary = intelligent_summary(long_text, max_length=50, style=\"academic\")\r\nprint(summary)\r\n```\r\n\r\n### Example 3: Multimodal Creation Function\r\n\r\n```python\r\ndef create_poem_from_image(image_url, poem_style=\"five-character quatrain\"):\r\n \"\"\"Create poetry based on image\"\"\"\r\n \r\n result = client.compute.custom_compute(\r\n text=\"Please create poetry based on the artistic conception of the image\",\r\n task=\"Observe image content, feel its artistic conception, and create poetry in corresponding style\",\r\n resources=[{\"inspiration_image\": image_url}],\r\n output_schema={\r\n \"type\": \"object\",\r\n \"properties\": {\r\n \"poem\": {\"type\": \"string\"},\r\n \"inspiration\": {\"type\": \"string\"},\r\n \"mood\": {\"type\": \"string\"}\r\n }\r\n },\r\n style=poem_style,\r\n cultural_background=\"classical literature\"\r\n )\r\n \r\n return result.data\r\n\r\n# Use the function\r\npoem_result = create_poem_from_image(\r\n \"https://example.com/sunset.jpg\", \r\n \"seven-character regulated verse\"\r\n)\r\nprint(f\"Poem: {poem_result['poem']}\")\r\nprint(f\"Inspiration: {poem_result['inspiration']}\")\r\n```\r\n\r\n### Example 4: Complex Logic Workflow Function\r\n\r\n```python\r\ndef complex_analysis_workflow(data, analysis_type=\"comprehensive\"):\r\n \"\"\"Complex analysis workflow using Mermaid diagram to define logic\"\"\"\r\n \r\n mermaid_flow = \"\"\"\r\n graph TD\r\n A[Input Analysis] --> B{Determine Type}\r\n B -->|Text| C[Text Sentiment Analysis]\r\n B -->|Data| D[Data Pattern Recognition]\r\n C --> E[Generate Suggestions]\r\n D --> E[Generate Suggestions]\r\n E --> F[Output Results]\r\n \"\"\"\r\n \r\n result = client.compute.custom_compute(\r\n text=data,\r\n task=f\"Analyze according to the following workflow: {mermaid_flow}\",\r\n analysis_type=analysis_type,\r\n depth=\"deep analysis\",\r\n output_schema={\r\n \"type\": \"object\",\r\n \"properties\": {\r\n \"analysis_result\": {\"type\": \"string\"},\r\n \"suggestions\": {\"type\": \"array\"},\r\n \"confidence\": {\"type\": \"number\"}\r\n }\r\n }\r\n )\r\n \r\n return result.data\r\n\r\n# Use the function\r\nanalysis = complex_analysis_workflow(\r\n \"User feedback data...\", \r\n \"comprehensive\"\r\n)\r\n```\r\n\r\n## \ud83c\udf1f Unlimited Flexibility in Language and Format\r\n\r\nRCK supports extreme flexibility:\r\n\r\n### Any Language\r\n```python\r\n# English processing\r\nresult = client.compute.custom_compute(\r\n text=\"To be or not to be, that is the question\",\r\n task=\"Analyze the philosophical connotations of this Shakespeare quote\"\r\n)\r\n\r\n# Chinese processing \r\nresult = client.compute.custom_compute(\r\n text=\"\u6625\u7720\u4e0d\u89c9\u6653\uff0c\u5904\u5904\u95fb\u557c\u9e1f\",\r\n task=\"Translate to English while preserving poetic sentiment\"\r\n)\r\n\r\n# Multi-language mixing\r\nresult = client.compute.custom_compute(\r\n text=\"Hello world, Bonjour le monde\",\r\n task=\"Identify languages and translate uniformly to English\"\r\n)\r\n```\r\n\r\n### Any Format\r\n```python\r\n# Mathematical formulas\r\nresult = client.compute.custom_compute(\r\n text=\"f(x) = x^2 - 4x + 3\",\r\n task=\"Find the minimum value of the function and describe the graph\",\r\n custom_code=\"def calculate_min(x): return x**2 - 4*x + 3\"\r\n)\r\n\r\n# Code analysis\r\nresult = client.compute.custom_compute(\r\n text=\"\"\"\r\n def fibonacci(n):\r\n if n <= 1:\r\n return n\r\n return fibonacci(n-1) + fibonacci(n-2)\r\n \"\"\",\r\n task=\"Analyze code complexity and provide optimization suggestions\",\r\n language=\"Python\"\r\n)\r\n\r\n# JSON data processing\r\nresult = client.compute.custom_compute(\r\n text='{\"users\": [{\"name\": \"Alice\", \"age\": 30}]}',\r\n task=\"Analyze data structure and generate data report\",\r\n format=\"JSON\"\r\n)\r\n```\r\n\r\n## \ud83c\udfa8 Image Generation Features\r\n\r\nIn addition to text computation, the SDK provides powerful image generation capabilities:\r\n\r\n```python\r\ndef generate_artwork(description, art_style=\"modern art\"):\r\n \"\"\"Generate artwork\"\"\"\r\n \r\n image = client.image.generate(\r\n prompt=description,\r\n composition=\"centered composition with strong visual impact\",\r\n lighting=\"dramatic lighting effects\",\r\n style=art_style\r\n )\r\n \r\n if image.success:\r\n # Save images\r\n saved_files = client.image.save_images(image, \"artwork\")\r\n return {\r\n \"success\": True,\r\n \"image_count\": image.count,\r\n \"saved_files\": saved_files\r\n }\r\n else:\r\n return {\"success\": False, \"error\": \"Image generation failed\"}\r\n\r\n# Use the function\r\nartwork = generate_artwork(\r\n \"A lonely traveler walking under the starry sky\", \r\n \"Van Gogh style oil painting\"\r\n)\r\nprint(f\"Generation result: {artwork}\")\r\n```\r\n\r\n## \ud83d\udd27 Complete Example: Intelligent Assistant Function\r\n\r\n```python\r\nclass IntelligentAssistant:\r\n def __init__(self, api_key):\r\n self.client = RCKClient(api_key=api_key)\r\n \r\n def process_request(self, user_input, context=\"general\"):\r\n \"\"\"Intelligently process user requests\"\"\"\r\n \r\n # First analyze user intent\r\n intent_analysis = self.client.compute.custom_compute(\r\n text=user_input,\r\n task=\"Analyze user intent and categorize\",\r\n output_schema={\r\n \"type\": \"object\",\r\n \"properties\": {\r\n \"intent\": {\"type\": \"string\"},\r\n \"confidence\": {\"type\": \"number\"},\r\n \"required_action\": {\"type\": \"string\"}\r\n }\r\n },\r\n context=context\r\n )\r\n \r\n intent = intent_analysis.data.get('intent', 'unknown')\r\n \r\n # Execute different processing logic based on intent\r\n if intent == \"creative_writing\":\r\n return self._handle_creative_request(user_input)\r\n elif intent == \"data_analysis\":\r\n return self._handle_analysis_request(user_input)\r\n else:\r\n return self._handle_general_request(user_input)\r\n \r\n def _handle_creative_request(self, user_input):\r\n \"\"\"Handle creative requests\"\"\"\r\n result = self.client.compute.custom_compute(\r\n text=user_input,\r\n task=\"Create content based on user needs\",\r\n creativity_level=\"high\",\r\n style=\"engaging\",\r\n length=\"moderate\"\r\n )\r\n return result.data\r\n \r\n def _handle_analysis_request(self, user_input):\r\n \"\"\"Handle analysis requests\"\"\"\r\n result = self.client.compute.custom_compute(\r\n text=user_input,\r\n task=\"Conduct in-depth analysis and provide insights\",\r\n analysis_depth=\"detailed\",\r\n include_suggestions=\"yes\",\r\n format=\"structured\"\r\n )\r\n return result.data\r\n \r\n def _handle_general_request(self, user_input):\r\n \"\"\"Handle general requests\"\"\"\r\n result = self.client.compute.custom_compute(\r\n text=user_input,\r\n task=\"Provide helpful answers and suggestions\",\r\n tone=\"friendly\",\r\n detail_level=\"moderate\"\r\n )\r\n return result.data\r\n\r\n# Use intelligent assistant\r\nassistant = IntelligentAssistant(api_key=\"your-api-key\")\r\n\r\n# Process different types of requests\r\ncreative_result = assistant.process_request(\r\n \"Help me write a poem about autumn\", \r\n context=\"creative\"\r\n)\r\n\r\nanalysis_result = assistant.process_request(\r\n \"Analyze the trends in this sales data\", \r\n context=\"business\"\r\n)\r\n```\r\n\r\n## \ud83d\udcc4 License\r\n\r\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\r\n\r\n## \ud83d\udcde Contact Support\r\n\r\nFor questions or assistance, please contact:\r\n\r\n\ud83d\udce7 **Email**: omorsablin@gmail.com\r\n\r\n---\r\n\r\n> \ud83d\udca1 **Core Philosophy**: Use RCK as an intelligent function kernel, describing \"what to do\" declaratively rather than \"how to do it\". Let AI handle complex logic while you only need to define inputs, constraints, and expected outputs.\r\n```\r\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "\u4f18\u96c5\u7684RCK (Relational Calculate Kernel) Python SDK",
"version": "1.0.1",
"project_urls": {
"Bug Reports": "https://github.com/rck/rck-python-sdk/issues",
"Documentation": "https://rck-python-sdk.readthedocs.io/",
"Homepage": "https://github.com/rck/rck-python-sdk",
"Repository": "https://github.com/rck/rck-python-sdk"
},
"split_keywords": [
"rck",
" ai",
" text-analysis",
" image-generation",
" api-client"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "32c66fed8968fd6e8036d355a829fe1c65eaf41d12008f9769fb30ee7ade6966",
"md5": "a39d88b3f35919487cd6554919256b53",
"sha256": "9156581a5aa57b782510b6c0809db3374f2989b907c0de7d0a29f805452ae3b1"
},
"downloads": -1,
"filename": "rck_python_sdk-1.0.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "a39d88b3f35919487cd6554919256b53",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7",
"size": 22494,
"upload_time": "2025-07-20T06:24:51",
"upload_time_iso_8601": "2025-07-20T06:24:51.320879Z",
"url": "https://files.pythonhosted.org/packages/32/c6/6fed8968fd6e8036d355a829fe1c65eaf41d12008f9769fb30ee7ade6966/rck_python_sdk-1.0.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "56a72f8e5fed77f6b6fbb07db161b58ab8075ee6eb4324febdf705def6d90b82",
"md5": "0a4df29ccfd9456adb3102971319517e",
"sha256": "9ef746818933bb61cdfdd8e1f2e5cbeb266d0ed075cc89b7a915593633ff23ea"
},
"downloads": -1,
"filename": "rck_python_sdk-1.0.1.tar.gz",
"has_sig": false,
"md5_digest": "0a4df29ccfd9456adb3102971319517e",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7",
"size": 22447,
"upload_time": "2025-07-20T06:24:52",
"upload_time_iso_8601": "2025-07-20T06:24:52.949621Z",
"url": "https://files.pythonhosted.org/packages/56/a7/2f8e5fed77f6b6fbb07db161b58ab8075ee6eb4324febdf705def6d90b82/rck_python_sdk-1.0.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-07-20 06:24:52",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "rck",
"github_project": "rck-python-sdk",
"github_not_found": true,
"lcname": "rck-python-sdk"
}