chatgpt API扫盲贴

temperature 是什么?

温度(Temperature)是一个介于 0 和 1 之间的值,基本上可以让你控制模型在进行这些预测时的置信度。降低温度(Temperature)意味着它将承担更少的风险,并且完成将更加准确和确定。提高温度(Temperature)将导致更多样化的完成。

token 限制?

在给定的 API 请求中处理的 Token 数量取决于您的输入和输出长度。对于英文文本,1 个Token大约相当于 4 个字符或 0.75 个单词。要记住的一个限制是,您的文本提示词和生成的补全合起来不能超过模型的最大上下文长度(对于大多数模型,这是 2048 个 Token,或大约 1500 个单词)。

官方提示词

语法更正:You will be provided with statements, and your task is to convert them to standard English.

解释复杂代码:You will be provided with a piece of code, and your task is to explain it in a concise way.

计算代码的时间复杂度:You will be provided with Python code, and your task is to calculate its time complexity.

从非结构化文本创建表格:You will be provided with unstructured data, and your task is to parse it into CSV format.

提取关键字:You will be provided with a block of text, and your task is to extract a list of keywords from it.

产品名称生成器:You will be provided with a product description and seed words, and your task is to generate product names.

创建面试问题:Create a list of 8 questions for an interview with a science fiction author.

像苏格拉底一样回复学生:

You are a Socratic tutor. Use the following principles in responding to students:

复制代码
- Ask thought-provoking, open-ended questions that challenge students' preconceptions and encourage them to engage in deeper reflection and critical thinking.
- Facilitate open and respectful dialogue among students, creating an environment where diverse viewpoints are valued and students feel comfortable sharing their ideas.
- Actively listen to students' responses, paying careful attention to their underlying thought processes and making a genuine effort to understand their perspectives.
- Guide students in their exploration of topics by encouraging them to discover answers independently, rather than providing direct answers, to enhance their reasoning and analytical skills.
- Promote critical thinking by encouraging students to question assumptions, evaluate evidence, and consider alternative viewpoints in order to arrive at well-reasoned conclusions.
- Demonstrate humility by acknowledging your own limitations and uncertainties, modeling a growth mindset and exemplifying the value of lifelong learning.

将自然语言转换为 SQL 查询:

Given the following SQL tables, your job is to write queries given a user's request.

复制代码
CREATE TABLE Orders (
  OrderID int,
  CustomerID int,
  OrderDate datetime,
  OrderTime varchar(8),
  PRIMARY KEY (OrderID)
);

CREATE TABLE OrderDetails (
  OrderDetailID int,
  OrderID int,
  ProductID int,
  Quantity int,
  PRIMARY KEY (OrderDetailID)
);

CREATE TABLE Products (
  ProductID int,
  ProductName varchar(50),
  Category varchar(50),
  UnitPrice decimal(10, 2),
  Stock int,
  PRIMARY KEY (ProductID)
);

CREATE TABLE Customers (
  CustomerID int,
  FirstName varchar(50),
  LastName varchar(50),
  Email varchar(100),
  Phone varchar(20),
  PRIMARY KEY (CustomerID)
);

总结会议记录,包括总体讨论、行动项目和未来主题:

You will be provided with meeting notes, and your task is to summarize the meeting as follows:

复制代码
-Overall summary of discussion
-Action items (what needs to be done and who is doing it)
-If applicable, a list of topics that need to be discussed more fully in the next meeting.

分析给定主题的优缺点:Analyze the pros and cons of remote work vs. office work。

chat Completitions API 调用示例:

复制代码
from openai import OpenAI
client = OpenAI()

response = client.chat.completions.create(
  model="gpt-3.5-turbo",
  messages=[
    {"role": "system", "content": "You are a helpful assistant."},
    {"role": "user", "content": "Who won the world series in 2020?"},
    {"role": "assistant", "content": "The Los Angeles Dodgers won the World Series in 2020."},
    {"role": "user", "content": "Where was it played?"}
  ]
)
  • 主要输入是 messages 参数。消息必须是消息对象的数组,其中每个对象都有一个角色("系统"、"用户"或"助手")和内容。对话可以短至一条消息,也可以是多次来回切换。
  • 通常,对话的格式首先使用系统消息,然后是交替的用户和助手消息。
  • 系统消息有助于设置助手的行为。例如,您可以修改助手的个性,或提供有关其在整个对话中应如何表现的具体说明。但是,请注意,系统消息是可选的,没有系统消息的模型的行为可能类似于使用通用消息,例如"你是一个有用的助手"。
  • -用户消息提供请求或评论,供助手响应。助理消息存储以前的助理回复,但也可以由您编写,以提供所需行为的示例
相关推荐
没有梦想的咸鱼185-1037-166312 小时前
【降尺度】ChatGPT+DeepSeek+python+CMIP6数据分析与可视化、降尺度技术与气候变化的区域影响、极端气候分析
python·chatgpt·数据分析
2301_7875528715 小时前
AI-Browser适用于 ChatGPT、Gemini、Claude、DeepSeek、Grok的客户端开源应用程序,集成了 Monaco 编辑器。
人工智能·chatgpt·自动化·编辑器·deepseek
没有梦想的咸鱼185-1037-166316 小时前
解锁空间数据新质生产力暨:AI(DeepSeek、ChatGPT)、Python、ArcGIS Pro多技术融合下的空间数据分析、建模与科研绘图及论文写作
人工智能·python·深度学习·机器学习·arcgis·chatgpt·数据分析
量子位1 天前
o3 猜照片位置深度思考 6 分 48 秒全程高能,范围精确到 “这么近那么美”
人工智能·chatgpt
Want5952 天前
从ChatGPT到GPT-4:大模型如何重塑人类认知边界?
chatgpt·aigc
Awesome Baron2 天前
《Learning Langchain》阅读笔记8-RAG(4)在vector store中存储embbdings
python·jupyter·chatgpt·langchain·llm
张申傲2 天前
多模态(3):实战 GPT-4o 视频理解
人工智能·chatgpt·aigc·多模态
SLY司赖2 天前
大模型应用开发之LLM入门
语言模型·chatgpt·llm
古希腊掌管学习的神3 天前
[LangGraph教程]LangGraph04——支持人机协作的聊天机器人
人工智能·语言模型·chatgpt·机器人·agent
鸿蒙布道师3 天前
OpenAI为何觊觎Chrome?AI时代浏览器争夺战背后的深层逻辑
前端·人工智能·chrome·深度学习·opencv·自然语言处理·chatgpt