-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Update APIpie components with the following: #16810
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
c75d023
Update APIpie components with the following:
Toocky 860974d
Merge branch 'master' into master
Toocky 889292d
Fixed Typo and URL / issue
Toocky 4d485b4
Merge branch 'master' of https://github.com/Toocky/pipedream
Toocky 92f4ee3
Update list generation to be unique and sorted
Toocky 07b7160
made code rabbit suggested changes
Toocky 83f4701
Reverted model look up to simplifed direct calls
Toocky 8ef1f36
Merge branch 'master' into master
Toocky 8ad8401
correct range
Toocky 3803778
Merge branch 'master' of https://github.com/Toocky/pipedream
Toocky b38a10c
Added error handling
Toocky 0b7444c
fixed error importing
Toocky eb98535
removed tools output formating
Toocky 2cb8fb5
Merge branch 'master' into master
Toocky c0590f8
adjust chat completions error handling
Toocky 7942a9c
Merge branch 'master' of https://github.com/Toocky/pipedream
Toocky 3867049
Merge branch 'master' into master
Toocky ab723db
Merge branch 'master' into master
Toocky File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# Overview | ||
|
||
[APIpie.ai](https://apipie.ai) connects developers with open-source and commercial AI models via a unified API. With zero infrastructure setup, you can send requests to popular models, switch providers instantly, and explore a growing catalog of AI models—all through one endpoint. Here's an overview of the services offered by [APIpie's API](https://apipie.ai): | ||
|
||
- **Model Discovery**: List and explore available LLM models, image models, voice models, and voices from various providers as seen on the [APIpie Dashboard](https://apipie.ai/dashboard) | ||
- **Chat Completions**: Send messages to any supported model and receive AI-generated responses | ||
- **Image Generation**: Create images using AI image generation models | ||
- **Text-to-Speech**: Convert text to speech using various voice models and voices | ||
|
||
Use Python or Node.js code to make fully authenticated API requests with your APIpie account, enabling you to prototype, test, or integrate AI-generated content including text, images, and speech into apps, emails, alerts, dashboards, and more. | ||
|
||
# Example Use Cases | ||
|
||
The [APIpie API](https://apipie.ai) can be leveraged in a wide range of business contexts to drive efficiency, enhance customer experiences, and innovate product offerings through unified access to multiple AI models. Here are some specific business use cases for utilizing the APIpie API: | ||
|
||
## **Customer Support Automation** | ||
|
||
Significantly reduce response times and free up human agents to tackle more complex issues by automating customer support ticket responses. Use the List Models actions to dynamically select the most appropriate AI model based on ticket complexity or language requirements, then leverage Chat Completions to generate contextual, helpful responses that can be reviewed before sending to customers. | ||
|
||
## **Content Creation and Management** | ||
|
||
Utilize AI to generate high-quality content for blogs, articles, product descriptions, and marketing material. Create workflows that automatically test different models using the same prompt to compare writing styles, then select the best output for your brand voice. Generate accompanying images and convert text to speech for multimedia content creation. APIpie's unified interface lets you experiment with various open-source and commercial models without managing multiple API integrations. | ||
|
||
## **Creative Asset Generation** | ||
|
||
Generate visual content and audio assets for marketing campaigns, presentations, and social media. Use image generation models to create custom graphics, illustrations, and visual content that align with your brand. Convert written content to speech using different voice models to create podcasts, audiobooks, or accessibility features for your applications. | ||
|
||
## **Multi-Model AI Experimentation Framework** | ||
|
||
Build intelligent systems that automatically compare AI model performance across different use cases and modalities. Set up workflows that test text generation, image creation, and voice synthesis across multiple models simultaneously, collect responses in databases, and analyze quality, cost, and latency differences. This enables data-driven decisions about which AI models work best for specific business scenarios, while maintaining the flexibility to switch providers as new models become available. | ||
|
||
# Getting Started | ||
|
||
First, sign up for an APIpie account, then in a new workflow step open the APIpie app and select one of the available actions: | ||
|
||
- **Retrieve Available Image Models**: Fetch the current catalog of available language models | ||
- **Retrieve Available LLM Models**: Fetch the current catalog of available image generation models | ||
- **Retrieve Available TTS Models**: Fetch the current catalog of available voice models | ||
- **Retrieve Available TTS Voices**: Fetch the available voices for text-to-speech | ||
- **Send Chat Completion Request**: Send messages to any supported language model and receive responses | ||
- **Create Image**: Generate images using AI image generation models | ||
- **Convert Text to Speech (TTS)**: Convert text to speech using various voice models and voices | ||
|
||
Then connect your APIpie account to Pipedream. Visit [APIpie.ai](https://apipie.ai) and navigate to your profile to generate your [API key.](https://apipie.ai/profile/api-keys) | ||
|
||
Copy your API key and paste it into Pipedream when prompted. Now you're all set to use pre-built actions like `Chat`, `Create Image`, `Create Text to Speech`, or any of the list actions, or use your APIpie API key directly in Node.js or Python code to access the unified AI model interface. |
122 changes: 122 additions & 0 deletions
122
components/apipie_ai/actions/convert-text-to-speech/convert-text-to-speech.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
import fs from "fs"; | ||
import apipieAi from "../../apipie_ai.app.mjs"; | ||
import { ConfigurationError } from "@pipedream/platform"; | ||
|
||
export default { | ||
key: "apipie_ai-convert-text-to-speech", | ||
name: "Convert Text to Speech (TTS)", | ||
description: "Generates audio from the input text. [See the documentation](https://apipie.ai/docs/Features/Voices)", | ||
version: "0.0.1", | ||
type: "action", | ||
props: { | ||
apipieAi, | ||
model: { | ||
propDefinition: [ | ||
apipieAi, | ||
"ttsModelId", | ||
], | ||
reloadProps: true, | ||
}, | ||
input: { | ||
propDefinition: [ | ||
apipieAi, | ||
"input", | ||
], | ||
}, | ||
responseFormat: { | ||
propDefinition: [ | ||
apipieAi, | ||
"audioResponseFormat", | ||
], | ||
}, | ||
speed: { | ||
propDefinition: [ | ||
apipieAi, | ||
"speed", | ||
], | ||
}, | ||
outputFile: { | ||
type: "string", | ||
label: "Output Filename", | ||
description: "The filename of the output audio file that will be written to the `/tmp` folder, e.g. `/tmp/myFile.mp3`", | ||
}, | ||
}, | ||
async additionalProps() { | ||
try { | ||
const props = {}; | ||
if (this.model) { | ||
// Parse the model JSON to get id and route | ||
const modelData = JSON.parse(this.model); | ||
const { route } = modelData; | ||
|
||
// Get all voices and filter by the model route | ||
const { data } = await this.apipieAi.listVoices(); | ||
const filteredVoices = data.filter(voice => voice.model === route); | ||
|
||
const uniqueVoices = new Map(); | ||
filteredVoices.forEach(({ voice_id, name }) => { | ||
if (!uniqueVoices.has(voice_id)) { | ||
uniqueVoices.set(voice_id, name); | ||
} | ||
}); | ||
|
||
props.voice = { | ||
type: "string", | ||
label: "Voice", | ||
description: "The voice to use when generating the audio.", | ||
options: Array.from(uniqueVoices.entries()) | ||
.map(([value, name]) => ({ | ||
label: name, | ||
value, | ||
})) | ||
.sort((a, b) => a.label.localeCompare(b.label)), | ||
}; | ||
} | ||
return props; | ||
} catch (e) { | ||
$.export("Error fetching voices", e); | ||
throw new ConfigurationError(e.message || "Failed to fetch voices"); | ||
} | ||
}, | ||
async run({ $ }) { | ||
// Parse the model JSON to get the actual model id for the API call | ||
try { | ||
const modelData = JSON.parse(this.model); | ||
const { id: modelId } = modelData; | ||
const response = await this.apipieAi.createSpeech({ | ||
$, | ||
data: { | ||
model: modelId, | ||
input: this.input, | ||
voice: this.voice, | ||
response_format: this.responseFormat, | ||
speed: this.speed, | ||
}, | ||
responseType: "arraybuffer", | ||
}); | ||
|
||
if (response.error) { | ||
$.export("Error creating audio", response.error); | ||
throw new ConfigurationError(response.error.message || "Failed to create audio"); | ||
} | ||
const outputFilePath = this.outputFile.includes("tmp/") | ||
? this.outputFile | ||
: `/tmp/${this.outputFile}`; | ||
|
||
try { | ||
await fs.promises.writeFile(outputFilePath, Buffer.from(response)); | ||
} catch (e) { | ||
$.export("Error saving audio file", e); | ||
throw new ConfigurationError(e.message || "Failed to save audio file"); | ||
} | ||
$.export("$summary", "Generated audio successfully"); | ||
return { | ||
outputFilePath, | ||
response, | ||
}; | ||
} catch (e) { | ||
$.export("Error creating audio", e); | ||
throw new ConfigurationError(e.message || "Failed to create audio"); | ||
} | ||
}, | ||
}; |
84 changes: 84 additions & 0 deletions
84
components/apipie_ai/actions/create-image/create-image.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
import apipieAi from "../../apipie_ai.app.mjs"; | ||
import { ConfigurationError } from "@pipedream/platform"; | ||
|
||
export default { | ||
name: "Create Image", | ||
version: "0.0.1", | ||
key: "apipie_ai-create-image", | ||
description: "Creates an image given a prompt returning a URL to the image. [See the documentation](https://apipie.ai/docs/Features/Images)", | ||
type: "action", | ||
props: { | ||
apipieAi, | ||
model: { | ||
propDefinition: [ | ||
apipieAi, | ||
"imageModelId", | ||
], | ||
}, | ||
prompt: { | ||
propDefinition: [ | ||
apipieAi, | ||
"prompt", | ||
], | ||
}, | ||
responseFormat: { | ||
propDefinition: [ | ||
apipieAi, | ||
"imageResponseFormat", | ||
], | ||
}, | ||
size: { | ||
propDefinition: [ | ||
apipieAi, | ||
"size", | ||
], | ||
}, | ||
n: { | ||
propDefinition: [ | ||
apipieAi, | ||
"n", | ||
], | ||
}, | ||
quality: { | ||
propDefinition: [ | ||
apipieAi, | ||
"quality", | ||
], | ||
}, | ||
style: { | ||
propDefinition: [ | ||
apipieAi, | ||
"style", | ||
], | ||
}, | ||
}, | ||
async run({ $ }) { | ||
try { | ||
const response = await this.apipieAi.createImage({ | ||
$, | ||
data: { | ||
prompt: this.prompt, | ||
n: this.n, | ||
size: this.size, | ||
...(this.responseFormat && { response_format: this.responseFormat }), | ||
model: this.model, | ||
quality: this.quality, | ||
style: this.style, | ||
}, | ||
}); | ||
if (response.error) { | ||
$.export("Error creating Image", response.error); | ||
throw new ConfigurationError(response.error.message || "Failed to create Image"); | ||
} | ||
if (response.data.length) { | ||
$.export("$summary", `Successfully created ${response.data.length} image${response.data.length === 1 | ||
? "" | ||
: "s"}`); | ||
} | ||
return response; | ||
} catch (e) { | ||
$.export("Error creating Image", e); | ||
throw new ConfigurationError(e.message || "Failed to create Image"); | ||
} | ||
}, | ||
}; |
25 changes: 25 additions & 0 deletions
25
...nts/apipie_ai/actions/retrieve-available-image-models/retrieve-available-image-models.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import apipieAi from "../../apipie_ai.app.mjs"; | ||
import { ConfigurationError } from "@pipedream/platform"; | ||
|
||
export default { | ||
key: "apipie_ai-retrieve-available-image-models", | ||
name: "Retrieve Available Image Models", | ||
version: "0.0.1", | ||
description: "Returns a list of Image models available through the API. [See the dashboard](https://apipie.ai/dashboard)", | ||
type: "action", | ||
props: { | ||
apipieAi, | ||
}, | ||
async run({ $ }) { | ||
try { | ||
const response = await this.apipieAi.listImageModels({ | ||
$, | ||
}); | ||
$.export("$summary", `Successfully retrieved ${response.data.length} available Image model(s)!`); | ||
return response; | ||
} catch (e) { | ||
$.export("Error fetching Image Models", e); | ||
throw new ConfigurationError(e.message || "Failed to fetch Image Models"); | ||
} | ||
}, | ||
}; |
25 changes: 25 additions & 0 deletions
25
components/apipie_ai/actions/retrieve-available-llm-models/retrieve-available-llm-models.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import apipieAi from "../../apipie_ai.app.mjs"; | ||
import { ConfigurationError } from "@pipedream/platform"; | ||
|
||
export default { | ||
key: "apipie_ai-retrieve-available-llm-models", | ||
name: "Retrieve Available LLM Models", | ||
version: "0.0.1", | ||
description: "Returns a list of LLM models available through the API. [See the dashboard](https://apipie.ai/dashboard)", | ||
type: "action", | ||
props: { | ||
apipieAi, | ||
}, | ||
async run({ $ }) { | ||
try { | ||
const response = await this.apipieAi.listLlmModels({ | ||
$, | ||
}); | ||
$.export("$summary", `Successfully retrieved ${response.data.length} available LLM model(s)!`); | ||
return response; | ||
} catch (e) { | ||
$.export("Error fetching LLM Models", e); | ||
throw new ConfigurationError(e.message || "Failed to fetch LLM Models"); | ||
} | ||
}, | ||
}; |
25 changes: 25 additions & 0 deletions
25
components/apipie_ai/actions/retrieve-available-tts-models/retrieve-available-tts-models.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import apipieAi from "../../apipie_ai.app.mjs"; | ||
import { ConfigurationError } from "@pipedream/platform"; | ||
|
||
export default { | ||
key: "apipie_ai-retrieve-available-tts-models", | ||
name: "Retrieve Available TTS Models", | ||
version: "0.0.1", | ||
description: "Returns a list of TTS models available through the API. [See the dashboard](https://apipie.ai/dashboard)", | ||
type: "action", | ||
props: { | ||
apipieAi, | ||
}, | ||
async run({ $ }) { | ||
try { | ||
const response = await this.apipieAi.listTtsModels({ | ||
$, | ||
}); | ||
$.export("$summary", `Successfully retrieved ${response.data.length} available TTS model(s)!`); | ||
return response; | ||
} catch (e) { | ||
$.export("Error fetching TTS Models", e); | ||
throw new ConfigurationError(e.message || "Failed to fetch TTS models"); | ||
} | ||
}, | ||
}; |
25 changes: 25 additions & 0 deletions
25
components/apipie_ai/actions/retrieve-available-tts-voices/retrieve-available-tts-voices.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import apipieAi from "../../apipie_ai.app.mjs"; | ||
import { ConfigurationError } from "@pipedream/platform"; | ||
|
||
export default { | ||
key: "apipie_ai-retrieve-available-tts-voices", | ||
name: "Retrieve Available TTS Voices", | ||
version: "0.0.1", | ||
description: "Returns a list of TTS Voices available through the API. [See the dashboard](https://apipie.ai/dashboard)", | ||
type: "action", | ||
props: { | ||
apipieAi, | ||
}, | ||
async run({ $ }) { | ||
try { | ||
const response = await this.apipieAi.listVoices({ | ||
$, | ||
}); | ||
$.export("$summary", `Successfully retrieved ${response.data.length} available TTS Voices!`); | ||
return response; | ||
} catch (e) { | ||
$.export("Error fetching Voices", e); | ||
throw new ConfigurationError(e.message || "Failed to fetch Voices"); | ||
} | ||
}, | ||
}; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.