Sure, here's the translation: 如何获取 Chat GPT 3.5 或 4.0 的 API 密钥

Sure, here's the translated text in simplified Chinese, keeping the HTML structure: ```html 在这个场合,我将教你如何获取API密钥以及如何测试它! ```

获取您的 API 密钥

首先,在 https://openai.com/ 创建一个账户。然后,进入产品页面,点击“API登录”,你将被重定向。

Sure, here's the HTML structure with the translated text: ```html

你可以选择“API”而不是ChatGPT。

```

Sure, here's the translation of "Then, go to profile and show the right-side menu bar" in simplified Chinese while keeping the HTML structure: ```html 然后,转到个人资料并显示右侧菜单栏: ``` This HTML code will display the translated text in simplified Chinese while maintaining the structure of your document.

去账单页面,添加支付方式(最低5美元),然后进入您的个人资料:

选择“用户API密钥”,在这里您可以创建您的API密钥。只有在您已经添加了至少5美元的情况下,此API密钥才有效。您可以在那里检查定价和使用限制。

Here's the translated text in simplified Chinese within the HTML structure: ```html

就这些了,祝你创建和使用ChatGPT好运。我建议使用“gpt-3.5-turbo”模型,每分钟使用40000个令牌,每分钟请求200000次,成本低至0.5美元至1.5美元。

```

Sure, here's the translation in simplified Chinese while keeping the HTML structure: ```html

测试您的API密钥

```

Certainly! Here's the HTML structure with the translated text in simplified Chinese: ```html

这里我将分享一个简单的代码,用来尝试你的 API 密钥在 Python 3.9.0 中。你需要安装 openai==0.28。你可以在这里选择任何可用的模型,但你应该检查每个模型的价格。要使用 ChatGPT4,只需将 “gpt-3.5-turbo” 更改为 “gpt-4o”。

``` In simplified Chinese: 这里我将分享一个简单的代码,用来尝试你的 API 密钥在 Python 3.9.0 中。你需要安装 openai==0.28。你可以在这里选择任何可用的模型,但你应该检查每个模型的价格。要使用 ChatGPT4,只需将 “gpt-3.5-turbo” 更改为 “gpt-4o”。
import openai
import pandas as pd

openai.api_key = 'API-Key'

def extract_information(text):

prompt_template = """
Extract the following information from the text:
1. Name
2. Date
3. Location
4. Description

Text: {text}

Extracted Information:
"""
prompt_request = prompt_template.format(text=text)
print(prompt_request, len(prompt_request))

response = openai.ChatCompletion.create(
model="gpt-3.5-turbo", # Use a supported model
messages=[
{"role": "system", "content": "You are an information extraction assistant."},
{"role": "user", "content": prompt_request},
],
max_tokens=500,
temperature=0.5,
)

return response, response['choices'][0]['message']['content'].strip()



texts = [
"John Doe attended a meeting on 5th June 2024 in New York. The meeting was about AI advancements.",
"Jane Smith gave a lecture on 10th May 2024 in San Francisco. The lecture was focused on machine learning trends."
]

data = []

for text in texts:
_, extracted_info = extract_information(text)
print(_)
name, date, location, description = extracted_info.split('\n')
data.append({
'Name': name.split(': ')[1],
'Date': date.split(': ')[1],
'Location': location.split(': ')[1],
'Description': description.split(': ')[1]
})

df = pd.DataFrame(data)
df.to_csv('extracted_information.csv', index=False)

Sure, here's the translated text in simplified Chinese within an HTML structure: ```html

此代码将从文本中提取信息并保存到CSV文件中。

```

Sure, here's the translation: ```html

感谢阅读!!!

感谢阅读!!!

```

2024-06-11 03:42:52 AI中文站翻译自原文