Enhance Your App's Text Generation with Poro-34B Cognitive Actions

Integrating advanced AI capabilities into your applications can significantly enhance user experience and engagement. The intentface/poro-34b-gguf-checkpoint offers a powerful Cognitive Action that leverages the akx/Poro-34B-gguf model for text generation tasks. This action allows developers to generate coherent and contextually relevant text based on user-defined prompts. In this blog post, we will explore how to effectively use this Cognitive Action to enrich your applications.
Prerequisites
Before you get started, ensure you have the following:
- An API key for accessing the Cognitive Actions platform, which you will pass in the request headers for authentication.
- Basic knowledge of JSON structure, as the input and output for the actions will be in this format.
Cognitive Actions Overview
Run Poro-34B-gguf Prediction
The Run Poro-34B-gguf Prediction action utilizes the Q5_K 1000B checkpoint model for generating predictions based on the input prompt. This action falls under the category of text-generation and is designed to produce creative and contextually appropriate responses.
Input
The input for this action requires the following fields based on the provided schema:
- prompt (required): A clear instruction or question that you want the AI to process.
- temperature (optional): A parameter that controls the randomness of the output. It ranges from 0 to 1, with lower values producing more deterministic responses.
- maxNewTokens (optional): This specifies the maximum number of new tokens to generate. A value of -1 indicates no limit.
Example Input:
{
"prompt": "Q: Hei\nA: Hei\nQ: Mikä on suomen pääkaupunki?\nA: Suomen pääkaupunki on Helsinki\nQ: Kerro satu kissoista\nA:",
"temperature": 0.5,
"maxNewTokens": -1
}
Output
The action returns a list of tokens generated by the model, which can include responses, questions, or additional context based on the input prompt.
Example Output:
[
" Kiss",
"at",
" ovat",
" pieniä",
" eläimiä",
",",
" jotka",
" asuvat",
" yleensä",
" taloissa",
".",
" Niillä",
" ei",
" ole",
" hän",
"tää",
" eikä",
" korvia",
".",
"Q:",
" Mitä",
" tarkoittaa",
" sana",
" \"",
"kor",
"kea",
"\"",
"?\n",
"A:",
" Korkea",
" on",
" iso",
" tai",
" pitkä",
" asia",
" kuten",
" rakennus",
" tai",
" vuori",
".",
"Q:",
" Missä",
" asuu",
" joulupukki",
"?\n",
"A:",
" Joulup",
"ukki",
" asuu",
" Kor",
"vat",
"unt",
"urilla",
" Suomen",
" Lapissa",
" Nap",
"apiirin",
" pohjoispuolella",
".",
" Siellä",
" missä",
" asuu",
" joulupukki",
"?",
" Ei",
" missään",
" muualla",
"!\n",
"Q:",
" Mikä",
" oli",
" ensimmäinen",
" eläin",
",",
" jonka",
" sinä",
" keksit",
"\n",
"A",
" :",
" Koira",
""
]
Conceptual Usage Example (Python)
Here is a conceptual example of how to call the Run Poro-34B-gguf Prediction action using Python:
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 = "90829035-7d18-4e84-b9be-e0990e78b841" # Action ID for Run Poro-34B-gguf Prediction
# Construct the input payload based on the action's requirements
payload = {
"prompt": "Q: Hei\nA: Hei\nQ: Mikä on suomen pääkaupunki?\nA: Suomen pääkaupunki on Helsinki\nQ: Kerro satu kissoista\nA:",
"temperature": 0.5,
"maxNewTokens": -1
}
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 code snippet, you can see how to specify the action ID and input payload. The endpoint URL and request structure are illustrative and should be adapted to your specific implementation.
Conclusion
The Poro-34B-gguf Cognitive Action enables developers to harness powerful text generation capabilities in their applications. By utilizing prompts effectively and adjusting parameters like temperature and max new tokens, you can tailor the AI's responses to suit your needs. Explore the possibilities of integrating this action into your projects and enhance your user experience with engaging and contextually aware AI interactions!