Mercurial > repos > bgruening > chatgpt_openai_api
comparison chatgpt.xml @ 3:7770a4bd42e2 draft default tip
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit c21d9a2cb410ee30dc47f4a13247862481816266
author | bgruening |
---|---|
date | Wed, 11 Sep 2024 16:36:21 +0000 |
parents | dab494dce303 |
children |
comparison
equal
deleted
inserted
replaced
2:dab494dce303 | 3:7770a4bd42e2 |
---|---|
1 <tool id="chatgpt_openai_api" name="chatGPT" version="@TOOL_VERSION@+galaxy@VERSION_SUFFIX@" profile="23.0"> | 1 <tool id="chatgpt_openai_api" name="chatGPT" version="@TOOL_VERSION@+galaxy@VERSION_SUFFIX@" profile="23.0"> |
2 <description>Integrating OpenAI's ChatGPT into Galaxy</description> | 2 <description>Integrating OpenAI's ChatGPT into Galaxy</description> |
3 <macros> | 3 <macros> |
4 <token name="@TOOL_VERSION@">2024</token> | 4 <token name="@TOOL_VERSION@">2024</token> |
5 <token name="@VERSION_SUFFIX@">1</token> | 5 <token name="@VERSION_SUFFIX@">2</token> |
6 </macros> | 6 </macros> |
7 <requirements> | 7 <requirements> |
8 <requirement type="package" version="3.12">python</requirement> | 8 <requirement type="package" version="3.12">python</requirement> |
9 <requirement type="package" version="1.35.13">openai</requirement> | 9 <requirement type="package" version="1.35.13">openai</requirement> |
10 </requirements> | 10 </requirements> |
11 <command detect_errors="exit_code"><![CDATA[ | 11 <command detect_errors="exit_code"><![CDATA[ |
12 #import os | 12 #import json |
13 #import re | 13 #import os |
14 #set $LINK_LIST = [] | 14 #import re |
15 #for $input in $context: | 15 #set LINK_LIST = [] |
16 #set file_name, ext = os.path.splitext($input.element_identifier) | 16 #for $input in $context |
17 #if ext == '' | 17 #set file_name = os.path.splitext($input.element_identifier)[0] |
18 #set ext = '.'+$input.ext | 18 ## list of supported filetypes in OpenAI. If Galaxy has a filetype that is not in this list, just use the generic `txt`. |
19 #end if | 19 #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' |
20 #set LINK = re.sub('[^\w\-]', '_', str($file_name))+$ext | 20 #set LINK = re.sub('[^\w\-]', '_', $file_name)+'.'+$ext |
21 ln -s '$input' '$LINK' && | 21 ln -s '$input' '$LINK' && |
22 $LINK_LIST.append($LINK) | 22 ## OpenAI has some special handling of "images", so let's annotate this here and pass it to the script |
23 #end for | 23 #set type = 'image' if $input.ext in ['jpg', 'jpeg', 'png', 'webp', 'gif'] else 'text' |
24 $LINK_LIST.append([$LINK, $type]) | |
25 #end for | |
26 #set context_files = json.dumps($LINK_LIST) | |
24 | 27 |
25 python '$__tool_directory__/chatgpt.py' | 28 python '$__tool_directory__/chatgpt.py' |
26 '$str(",".join($LINK_LIST))' | 29 '$context_files' |
27 '$question' | 30 '$prompt' |
28 '$model' | 31 '$model' |
29 '$openai_api_key_file' | 32 '$openai_api_key_file' |
30 ]]></command> | 33 ]]></command> |
31 <configfiles> | 34 <configfiles> |
32 <configfile name="openai_api_key_file"><![CDATA[ | 35 <configfile name="openai_api_key_file"><![CDATA[ |
38 <param name="input_type_selector" type="select" label="Choose the model" help="Vision models are capable to have image as input."> | 41 <param name="input_type_selector" type="select" label="Choose the model" help="Vision models are capable to have image as input."> |
39 <option value="vision" selected="true">Vision models</option> | 42 <option value="vision" selected="true">Vision models</option> |
40 <option value="all">All models</option> | 43 <option value="all">All models</option> |
41 </param> | 44 </param> |
42 <when value="vision"> | 45 <when value="vision"> |
43 <param name="model" type="select" optional="false" label="Model" help="Select the model you want to use"> | 46 <param name="model" type="select" optional="false" label="Model" help="Select the model you want to use."> |
44 <option value="gpt-4o-mini" selected="true">Affordable and intelligent small model for fast, lightweight tasks (gpt-4o-mini)</option> | 47 <option value="gpt-4o-mini" selected="true">Affordable and intelligent small model for fast, lightweight tasks (gpt-4o-mini)</option> |
45 <option value="gpt-4o">High-intelligence flagship model for complex, multi-step tasks (gpt-4o)</option> | 48 <option value="gpt-4o">High-intelligence flagship model for complex, multi-step tasks (gpt-4o)</option> |
46 <option value="gpt-4-turbo">The previous set of high-intelligence model with vision capabilities (gpt-4-turbo)</option> | 49 <option value="gpt-4-turbo">The previous set of high-intelligence model with vision capabilities (gpt-4-turbo)</option> |
47 </param> | 50 </param> |
48 <param name="context" type="data" multiple="true" optional="false" format="doc,docx,html,json,pdf,txt,jpg,jpeg,png,webp,gif" label="Context" max="500" help="This data will be uploaded to OpenAI's servers for processing."/> | 51 <param name="context" type="data" multiple="true" optional="false" format="doc,docx,html,json,pdf,txt,jpg,jpeg,png,webp,gif" label="Context" max="500" help="This data will be uploaded to OpenAI's servers for processing."/> |
49 </when> | 52 </when> |
50 <when value="all"> | 53 <when value="all"> |
51 <param name="model" type="select" optional="false" label="Model" help="Select the model you want to use"> | 54 <param name="model" type="select" optional="false" label="Model" help="Select the model you want to use."> |
52 <option value="gpt-4o-mini" selected="true">Affordable and intelligent small model for fast, lightweight tasks (gpt-4o-mini)</option> | 55 <option value="gpt-4o-mini" selected="true">Affordable and intelligent small model for fast, lightweight tasks (gpt-4o-mini)</option> |
53 <option value="gpt-4o">High-intelligence flagship model for complex, multi-step tasks (gpt-4o)</option> | 56 <option value="gpt-4o">High-intelligence flagship model for complex, multi-step tasks (gpt-4o)</option> |
54 <option value="gpt-4-turbo">The previous set of high-intelligence model with vision capabilities (gpt-4-turbo)</option> | 57 <option value="gpt-4-turbo">The previous set of high-intelligence model with vision capabilities (gpt-4-turbo)</option> |
55 <option value="gpt-4" selected="true">The previous set of high-intelligence model (gpt-4)</option> | 58 <option value="gpt-4" selected="true">The previous set of high-intelligence model (gpt-4)</option> |
56 <option value="gpt-3.5-turbo">A fast, inexpensive model for simple tasks (GPT-3.5-turbo)</option> | 59 <option value="gpt-3.5-turbo">A fast, inexpensive model for simple tasks (GPT-3.5-turbo)</option> |
57 </param> | 60 </param> |
58 <param name="context" type="data" multiple="true" optional="false" format="doc,docx,html,json,pdf,txt" label="Context" max="500" help="This data will be uploaded to OpenAI's servers for processing."/> | 61 <param name="context" type="data" multiple="true" optional="false" format="doc,docx,html,json,pdf,txt" label="Context" max="500" help="This data will be uploaded to OpenAI's servers for processing."/> |
59 </when> | 62 </when> |
60 </conditional> | 63 </conditional> |
61 <param name="question" type="text" optional="false" label="Question" help="Question about the text provided." area="true"> | 64 <param name="prompt" type="text" optional="false" label="Prompt" help="Prompts or tasks you want ChatGPT to perform." area="true"> |
62 <validator type="empty_field"/> | 65 <validator type="empty_field"/> |
63 </param> | 66 </param> |
64 </inputs> | 67 </inputs> |
65 <outputs> | 68 <outputs> |
66 <data name="output" format="txt" label="${tool.name} on ${on_string}" from_work_dir="./output.txt"/> | 69 <data name="output" format="txt" label="${tool.name} on ${on_string}" from_work_dir="./output.txt"/> |
67 </outputs> | 70 </outputs> |
68 <tests> | 71 <tests> |
69 <test expect_failure="true" expect_exit_code="1"> | 72 <test expect_failure="true" expect_exit_code="1"> |
70 <param name="context" value="chatgpt_test.txt" ftype="txt"/> | 73 <param name="context" value="chatgpt_test.txt" ftype="txt"/> |
71 <param name="question" value="What is this?"/> | 74 <param name="prompt" value="What is this?"/> |
72 <param name="model" value="gpt-4o-mini"/> | 75 <param name="model" value="gpt-4o-mini"/> |
73 <assert_stdout> | 76 <assert_stdout> |
74 <has_text text="OpenAI API key is not provided in user preferences!"/> | 77 <has_text text="OpenAI API key is not provided in user preferences!"/> |
75 </assert_stdout> | 78 </assert_stdout> |
76 </test> | 79 </test> |
79 | 82 |
80 .. class:: infomark | 83 .. class:: infomark |
81 | 84 |
82 **What it does** | 85 **What it does** |
83 | 86 |
84 This tool leverages OpenAI's ChatGPT API to generate responses based on user-provided context and questions. | 87 This tool leverages OpenAI's ChatGPT API to generate responses based on user-provided context and prompt. |
85 Users can upload context data in various formats and ask questions related to that data. | 88 Users can upload context data in various formats and ask questions or execute prompts related to that data. |
86 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. | 89 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. |
87 | 90 |
88 To utilize this tool, users need to input their OpenAI API key in the user preferences. To obtain an API key, visit API keys page in your OpenAI Dashboard. | 91 To utilize this tool, users need to input their OpenAI API key in the user preferences. To obtain an API key, visit API keys page in your OpenAI Dashboard. |
92 Make sure to setup the payment method in your OpenAI account to use the API key. | |
89 | 93 |
90 When you run this tool, your input data is sent to OpenAI's servers using your API-key. | 94 When you run this tool, your input data is sent to OpenAI's servers using your API-key. |
91 OpenAI's models process the data and generate a response based on the context and question provided. | 95 OpenAI's models process the data and generate a response based on the context and prompt provided. |
92 After receiving the response from the OpenAI server, the tool returns it to Galaxy and puts it in your history. | 96 After receiving the response from the OpenAI server, the tool returns it to Galaxy and puts it in your history. |
93 The files that have been uploaded are then deleted from the OpenAI's server, so they are not stored beyond their necessary use. | 97 The files that have been uploaded are then deleted from the OpenAI's server, so they are not stored beyond their necessary use. |
94 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. | 98 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. |
95 | 99 |
96 For more information on the tool refer to GitHub README_ file. | 100 For more information on the tool refer to GitHub README_ file. |
101 ..... | 105 ..... |
102 | 106 |
103 **Input** | 107 **Input** |
104 | 108 |
105 1. **Upload Context Data**: Users can upload up to 500 files in formats such as DOC, DOCX, HTML, JSON, PDF, TXT, JPG, JPEG, PNG, WEBP, or GIF. | 109 1. **Upload Context Data**: Users can upload up to 500 files in formats such as DOC, DOCX, HTML, JSON, PDF, TXT, JPG, JPEG, PNG, WEBP, or GIF. |
106 This context data serves as the background information for the question you wish to ask. | 110 This context data serves as the input for the prompt you wish to execute. |
107 | 111 |
108 2. **Ask a Question**: Once the context data is added, users can pose a question related to the content. | 112 2. **Provide a Prompt**: Once the context data is added, users can provide a prompt for a task ChatGPT should execute. |
109 The more specific the question, the more tailored the response will be. | 113 The more specific the prompt, the more tailored the response will be. |
110 | 114 |
111 3. **Select a Model**: Choose the ChatGPT model that best fits your needs. | 115 3. **Select a Model**: Choose the ChatGPT model that best fits your needs. |
112 Information about different models and their pricing can be found on the OpenAI website. | 116 Information about different models and their pricing can be found on the OpenAI website. |
113 | 117 |
114 | 118 |
115 **Output** | 119 **Output** |
116 | 120 |
117 The output is a response generated by ChatGPT, crafted based on the provided context data and the question posed. | 121 The output is a response generated by ChatGPT, crafted based on the provided context data and the prompt posed. |
118 This response is saved in the `output.txt` file. | 122 This response is saved in the `output.txt` file. |
119 | 123 |
120 | 124 |
121 ]]></help> | 125 ]]></help> |
122 <citations> | 126 <citations> |