Enhance Your App's Intelligence with Yuan 2.0 Cognitive Actions

In today's fast-paced world of artificial intelligence, integrating advanced language models can significantly enhance the capabilities of your applications. The Yuan 2.0 Cognitive Actions, part of the ieit-yuan/yuan2.0-2b spec, empower developers to leverage a next-generation large language model by IEIT System. These actions facilitate improved semantics, mathematics, reasoning, coding, and knowledge comprehension. By using these pre-built actions, you can enhance user interactions, automate responses, and generate content seamlessly.
Prerequisites
To get started with the Yuan 2.0 Cognitive Actions, ensure you have:
- An API key for accessing the Cognitive Actions platform.
- Basic knowledge of JSON and HTTP requests.
- A development environment set up for making API calls.
Authentication typically involves passing your API key in the request headers to grant access to the actions.
Cognitive Actions Overview
Enhance Comprehension with Yuan 2.0
This action allows developers to utilize the Yuan 2.0 model for a variety of text-processing tasks, enhancing comprehension and generating meaningful content based on user prompts.
Category: Text Processing
- Purpose: The action leverages a sophisticated language model to provide enhanced understanding and generation capabilities for a given prompt.
Input
The action requires the following parameters:
- prompt (required): A string that serves as the input query or instruction.
Example:"你是一个在中国菜肴方面的资深厨师,请你详细介绍下宫保鸡丁的做法?" - topK (optional): An integer specifying the number of highest probability tokens to consider when generating output. Default is 50.
Example:50 - topP (optional): A float that sets a probability threshold for generating output using nucleus sampling. Default is 1.0.
Example:1 - temperature (optional): A float that adjusts the randomness of predictions. Default is 1.
Example:1 - maxNewTokens (optional): An integer defining the maximum number of tokens in the generated output. Default is 4096.
Example:1024
Here is a sample input JSON payload for invoking this action:
{
"topK": 50,
"topP": 1,
"prompt": "你是一个在中国菜肴方面的资深厨师,请你详细介绍下宫保鸡丁的做法?",
"temperature": 1,
"maxNewTokens": 1024
}
Output
The action returns a generated text response based on the provided prompt. The output will typically be a string that contains coherent and contextually relevant information.
Example Output:
宫保鸡丁是一道传统的中国菜肴,以鸡肉、花生和蔬菜为主要材料。以下是宫保鸡丁的做法:
所需材料:
- 鸡胸肉 250克
- 花生米 50克
- 青椒 1个
- 红椒 1个
- 葱姜蒜适量
- 料酒 适量
- 生抽 适量
- 盐 适量
- 糖 适量
- 鸡精 适量
- 淀粉 适量
- 鸡蛋清 1个
- 食用油 适量
Conceptual Usage Example (Python)
Below is a conceptual Python code snippet demonstrating how to call the Yuan 2.0 action:
import requests
import json
# Replace with your Cognitive Actions API key and endpoint
COGNITIVE_ACTIONS_API_KEY = "YOUR_COGNITIVE_ACTIONS_API_KEY"
COGNITIVE_ACTIONS_EXECUTE_URL = "https://api.cognitiveactions.com/actions/execute" # Hypothetical endpoint
action_id = "27ec06db-9005-4cfe-8076-3e3fc8b04b09" # Action ID for Enhance Comprehension with Yuan 2.0
# Construct the input payload based on the action's requirements
payload = {
"topK": 50,
"topP": 1,
"prompt": "你是一个在中国菜肴方面的资深厨师,请你详细介绍下宫保鸡丁的做法?",
"temperature": 1,
"maxNewTokens": 1024
}
headers = {
"Authorization": f"Bearer {COGNITIVE_ACTIONS_API_KEY}",
"Content-Type": "application/json"
}
try:
response = requests.post(
COGNITIVE_ACTIONS_EXECUTE_URL,
headers=headers,
json={"action_id": action_id, "inputs": payload} # Hypothetical structure
)
response.raise_for_status() # Raise an exception for bad status codes (4xx or 5xx)
result = response.json()
print("Action executed successfully:")
print(json.dumps(result, indent=2))
except requests.exceptions.RequestException as e:
print(f"Error executing action {action_id}: {e}")
if e.response is not None:
print(f"Response status: {e.response.status_code}")
try:
print(f"Response body: {e.response.json()}")
except json.JSONDecodeError:
print(f"Response body: {e.response.text}")
In this snippet, replace YOUR_COGNITIVE_ACTIONS_API_KEY with your actual API key. The action_id should match the ID of the action you are invoking. The input payload is structured to meet the requirements of the action, ensuring that your request is valid.
Conclusion
The Yuan 2.0 Cognitive Actions provide a powerful toolset for developers looking to enhance their applications with advanced language understanding capabilities. By integrating these actions, you can automate complex content generation, enhance user interactions, and significantly improve the overall functionality of your applications. Explore the potential of Yuan 2.0 and take your projects to the next level!