ChatGPT
Pricing
Pay per usage
Go to Store
ChatGPT
You can use this Actor to transform scraped results, such as reviews from restaurants, by rephrasing the sentences. Additionally, translation is also supported. You can also use it to generate new website descriptions, keywords, and other similar metadata.
0.0 (0)
Pricing
Pay per usage
6
Total users
133
Monthly users
6
Runs succeeded
>99%
Last modified
7 months ago
.actor/Dockerfile
# First, specify the base Docker image.# You can see the Docker images from Apify at https://hub.docker.com/r/apify/.# You can also use any other image from Docker Hub.FROM apify/actor-python:3.9
# Second, copy just requirements.txt into the actor image,# since it should be the only file that affects the dependency install in the next step,# in order to speed up the buildCOPY requirements.txt ./
# Install the packages specified in requirements.txt,# Print the installed Python version, pip version# and all installed packages with their versions for debuggingRUN echo "Python version:" \ && python --version \ && echo "Pip version:" \ && pip --version \ && echo "Installing dependencies:" \ && pip install -r requirements.txt \ && echo "All installed Python packages:" \ && pip freeze
# Next, copy the remaining files and directories with the source code.# Since we do this after installing the dependencies, quick build will be really fast# for most source file changes.COPY . ./
# Specify how to launch the source code of your actor.# By default, the "python3 -m src" command is runCMD ["python3", "-m", "src"]
.actor/README.md
1# Getting started2
3If you are new to ChatGPT, you can sign up at https://platform.openai.com/signup to get your API-KEY.4You can use this Actor to transform scraped results, such as reviews from restaurants, by rephrasing the sentences. Additionally, translation is also supported.5
6
7## ChatGPT 3.5 Turbo Announced!8
9###ChatGPT API 10The new Chat API calls gpt-3.5-turbo, the same model used in the ChatGPT product. It’s also our best model for many non-chat use cases; we’ve seen early testers migrate from text-davinci-003 to gpt-3.5-turbo with only a small amount of adjustment needed to their prompts. Learn more about the Chat API in our documentation.11
12###Pricing13It’s priced at $0.002 per 1K tokens, which is 10x cheaper than the existing GPT-3.5 models.14
15###Model updates16We are constantly improving our Chat models, and want to make these improvements available to developers as well. Developers who use the gpt-3.5-turbo model will always get our recommended stable model, while still having the flexibility to opt for a specific model version.17 18For example, today we’re releasing “gpt-3.5-turbo-0301”, which will be supported through at least June 1st, and we’ll update gpt-3.5-turbo to a new stable release in April. The models page will provide switchover updates.
.actor/actor.json
{ "actorSpecification": 1, "name": "chatgpt", "title": "ChatGPT Actor", "description": "The ChatGPT Actor for your integrations.", "version": "0.1", "input": "./input-schema.json", "readme": "./README.md", "dockerfile": "./Dockerfile", "storages": { "dataset": { "actorSpecification": 1, "title": "Question and Answers", "views": { "Answers": { "title": "Answers", "transformation": { "fields": [ "answer" ] }, "display": { "component": "table", "properties": { "question": { "label": "Question", "format": "textarea" }, "answer": { "label": "Answer", "format": "textarea" } } } } } } }}
.actor/input-schema.json
{ "title": "Ask to ChatGPT", "type": "object", "schemaVersion": 1, "properties": { "openai_token": { "title": "OpenAI Token", "type": "string", "description": "You can get an API key from https://platform.openai.com/signup", "editor": "textfield" }, "question": { "title": "Question?", "type": "string", "description": "Create one paragraph crime story.", "editor": "textarea" } }, "required": ["openai_token", "question"]}
src/__init__.py
1
src/__main__.py
1from .main import main2
3main()
src/main.py
1import os2import openai3from apify_client import ApifyClient4
5def main():6 # Initialize the main ApifyClient instance7 client = ApifyClient(os.environ['APIFY_TOKEN'], api_url=os.environ['APIFY_API_BASE_URL'])8
9 # Get the resource subclient for working with the default key-value store of the actor10 default_kv_store_client = client.key_value_store(os.environ['APIFY_DEFAULT_KEY_VALUE_STORE_ID'])11
12 # Get the value of the actor input and print it13 actor_input = default_kv_store_client.get_record(os.environ['APIFY_INPUT_KEY'])['value']14
15 # Structure of input is defined in INPUT_SCHEMA.json16 openai.api_key = actor_input["openai_token"]17 question = actor_input["question"]18 try:19 response = openai.ChatCompletion.create(20 model="gpt-3.5-turbo",21 messages=[22 {"role": "user", "content": question},23 ]24 )25 answer = response.choices[0]["message"]["content"]26 except:27 answer = ""28 29 # Get the resource subclient for working with the default dataset of the actor30 default_dataset_client = client.dataset(os.environ['APIFY_DEFAULT_DATASET_ID'])31
32 # Structure of output is defined in .actor/actor.json33 default_dataset_client.push_items([34 {35 'question': question,36 'answer': answer37 },38 ])
.dockerignore
# configurations.idea
# crawlee and apify storage foldersapify_storagecrawlee_storagestorage
# installed files.venv
# git folder.git
.editorconfig
root = true
[*]indent_style = spaceindent_size = 4charset = utf-8trim_trailing_whitespace = trueinsert_final_newline = trueend_of_line = lf
.gitignore
# This file tells Git which files shouldn't be added to source control
.idea.DS_Store
apify_storagestorage
.venv/.env/__pypackages__dist/build/*.egg-info/*.egg
__pycache__
.mypy_cache.dmypy.jsondmypy.json
.pytest_cache
.scrapy
requirements.txt
1# Add your dependencies here.2# See https://pip.pypa.io/en/latest/reference/requirements-file-format/3# for how to format them4apify-client~=0.6.05openai