view chatgpt.xml @ 4:3803ed45745c draft default tip

planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit 81bb45731241a082de7b44430afc97a8491a9e47
author bgruening
date Wed, 07 Jan 2026 13:00:53 +0000
parents 430ece17fc20
children
line wrap: on
line source

<tool id="chatgpt_openai_api" name="chatGPT" version="@TOOL_VERSION@+galaxy@VERSION_SUFFIX@" profile="25.1">
    <description>Integrating OpenAI's ChatGPT into Galaxy</description>
    <macros>
        <token name="@TOOL_VERSION@">2025</token>
        <token name="@VERSION_SUFFIX@">1</token>
    </macros>
    <requirements>
        <requirement type="package" version="3.13">python</requirement>
        <requirement type="package" version="2.7.1">openai</requirement>
        <credentials name="openai_credentials" version="1.0" label="OpenAI Credentials" description="Credentials for accessing OpenAI's API.">
            <secret name="openai_api_key" inject_as_env="OPENAI_API_KEY" optional="false" label="OpenAI API Key" description="Your OpenAI API key is required to use this tool. You can obtain it from your OpenAI account dashboard."/>
        </credentials>
    </requirements>
    <command detect_errors="exit_code"><![CDATA[
#import json
#import os
#import re
#set LINK_LIST = []
#if $context
    #for $input in $context
        #set file_name = os.path.splitext($input.element_identifier)[0]
        ## list of supported filetypes in OpenAI. If Galaxy has a filetype that is not in this list, just use the generic `txt`.
        #set ext = $input.ext if $input.ext in ['c', 'cpp', 'css', 'csv', 'docx', 'gif', 'html', 'java', 'jpeg', 'jpg', 'js', 'json', 'md', 'pdf', 'php', 'pkl', 'png', 'pptx', 'py', 'rb', 'tar', 'tex', 'ts', 'txt', 'webp', 'xlsx', 'xml', 'zip'] else 'txt'
        #set LINK = re.sub('[^\w\-]', '_', $file_name)+'.'+$ext
        ln -s '$input' '$LINK' &&
        ## OpenAI has some special handling of "images", so let's annotate this here and pass it to the script
        #set type = 'image' if $input.ext in ['jpg', 'jpeg', 'png', 'webp', 'gif'] else 'text'
        $LINK_LIST.append([$LINK, $type])
    #end for
#end if
#set context_files = json.dumps($LINK_LIST)

python '$__tool_directory__/chatgpt.py'
'$context_files'
'$prompt'
'$model'
    ]]></command>
    <inputs>
        <param name="model" type="select" optional="false" label="Model" help="Select the model you want to use.">
            <option value="gpt-5" selected="true">Flagship model for coding, reasoning, and agentic tasks across domains. (gpt-5)</option>
            <option value="gpt-5-mini">Faster, more cost-efficient version of GPT-5. It's great for well-defined tasks and precise prompts. (gpt-5-mini)</option>
            <option value="gpt-5-nano">Fastest, cheapest version of GPT-5. It's great for summarization and classification tasks. (gpt-5-nano)</option>
            <option value="gpt-4.1">Excels at instruction following and tool calling, with broad knowledge across domains (gpt-4.1)</option>
            <option value="gpt-4o">High-intelligence flagship model for complex, multi-step tasks (gpt-4o)</option>
        </param>
        <param name="context" type="data" multiple="true" optional="true" format="docx,html,json,pdf,txt,jpg,png,gif" label="Context" max="500" help="Optional context data that will be uploaded to OpenAI's servers for processing."/>
        <param name="prompt" type="text" optional="false" label="Prompt" help="Prompts or tasks you want ChatGPT to perform." area="true">
            <validator type="empty_field"/>
        </param>
    </inputs>
    <outputs>
        <data name="output" format="markdown" label="${tool.name} (${model}) #if $on_string then ' on ' + $on_string else ''#" from_work_dir="./output.md"/>
    </outputs>
    <tests>
        <test expect_failure="true" expect_exit_code="1">
            <param name="model" value="gpt-5"/>
            <param name="context" value="chatgpt_test.txt" ftype="txt"/>
            <param name="prompt" value="What is this?"/>
            <assert_stdout>
                <has_text text="OpenAI API key is not provided in credentials!"/>
            </assert_stdout>
        </test>
    </tests>
    <help><![CDATA[

.. class:: infomark

**What it does**

This tool leverages OpenAI's ChatGPT API to generate responses based on user-provided context and prompt.
Users can upload context data in various formats and ask questions or execute prompts related to that data.
The tool then uploads the data to a OpenAI server and processes them using the selected ChatGPT model, returning an AI-generated response tailored to the context provided.

To utilize this tool, users need to input their OpenAI API key in the credentials section. To obtain an API key, visit API keys page in your OpenAI Dashboard.
Make sure to setup the payment method in your OpenAI account to use the API key.

When you run this tool, your input data is sent to OpenAI's servers using your API-key. 
OpenAI's models process the data and generate a response based on the context and prompt provided. 
After receiving the response from the OpenAI server, the tool returns it to Galaxy and puts it in your history. 
The files that have been uploaded are then deleted from the OpenAI's server, so they are not stored beyond their necessary use. 
If the tool fails to delete your uploaded files automatically, you can manually delete them in your openai account page. You might want to check your OpenAI storage from time to time as they also have a quota.

For more information on the tool refer to GitHub README_ file.

.. _README: https://github.com/bgruening/galaxytools/blob/master/tools/chatgpt/README.md

Usage
.....

**Input**

1. **Upload Context Data** (Optional): You can optionally upload up to 500 files in formats such as DOC, DOCX, HTML, JSON, PDF, TXT, JPG, JPEG, PNG, WEBP, or GIF. 
This context data serves as the input for the prompt you wish to execute. If no context is provided, ChatGPT will respond based solely on the prompt.

2. **Provide a Prompt**: Provide a prompt or task for ChatGPT to execute.
The more specific the prompt, the more tailored the response will be.

3. **Select a Model**: Choose the ChatGPT model that best fits your needs. 
Information about different models and their pricing can be found on the OpenAI website.


**Output**

The output is a response generated by ChatGPT, crafted based on the provided context data and the prompt posed.
This response is saved in the `output.txt` file.


    ]]></help>
    <citations>
        <citation type="bibtex">
            @misc{openai,
                author = {OpenAI},
                title = {OpenAI's ChatGPT},
                howpublished = {\url{https://openai.com/chatgpt}},
                year = {2024},
                note = {Accessed: 2024-07-26}
            }
        </citation>
    </citations>
</tool>