Skip to content

Latest commit

 

History

History
77 lines (53 loc) · 4.08 KB

OpenAI_Act_as_a_Data_Scientist.md

File metadata and controls

77 lines (53 loc) · 4.08 KB



Template request | Bug report | Generate Data Product

Tags: #ai #datascientist #predictivemodels #machinelearning #plugin

Author: Jeremy Ravenel

Description: This notebook will create a plugin to act as a Data Scientist.

References:

Input

Import libraries

import json
import naas

Setup Variables

  • name: Plugin name to be displayed on naas.
  • model: ID of the model to use. You can find a list of available models and their IDs on the OpenAI API documentation.
  • prompt: This is the text prompt that you want to send to the OpenAI API.
  • temperature (Defaults to 1): This is a value that controls the level of randomness in the generated text. A temperature of 0 will result in the most deterministic output, while higher values will result in more diverse and unpredictable output.
  • max_tokens (Defaults to 16): This is the maximum number of tokens (words or phrases) that the API should return in its response. The larger the value of max_tokens, the more text the API can generate, but it will also take longer for the API to generate the response. The token count of your prompt plus max_tokens cannot exceed the model's context length. Most models have a context length of 2048 tokens (except for the newest models, which support 4096).
  • json_path: json file path to be saved
# Inputs
name = "Act as a Data Scientist"
model = "gpt-4"
prompt = f"""Think like a Data Scientist or Analyst AI Assistant. Utilize OpenAI to solve complex data problems, create predictive models, and analyze trends. Begin your conversation by introducing yourself and the specific data-related queries or challenges you can help the user with. Pose questions regarding data analysis, modeling techniques, machine learning, or any data science-related topic."""
temperature = 1
max_tokens = 2084

# Outputs
json_path = name.lower().replace(" ", "_") + ".json"

Model

Create plugin

data = {
    "name": name,
    "prompt": prompt.replace("\n", ""),
    "model": model,
    "temperature": temperature,
    "max_tokens": max_tokens,
}
print(json.dumps(data))
{"name": "Act as a Data Scientist", "prompt": "Think like a Data Scientist or Analyst AI Assistant. Utilize OpenAI to solve complex data problems, create predictive models, and analyze trends. Begin your conversation by introducing yourself and the specific data-related queries or challenges you can help the user with. Pose questions regarding data analysis, modeling techniques, machine learning, or any data science-related topic.", "model": "gpt-4", "temperature": 1, "max_tokens": 2084}

Output

Save json

with open(json_path, "w") as f:
    json.dump(data, f)

Create naas asset

asset_link = naas.asset.add(json_path, params={"inline": True})