Sure, here is the translation of the English text into simplified Chinese, while keeping the HTML structure: ```html 通过外部访问集成从snowflake调用OpenAI GPT-4O模型API ``` In this HTML snippet: - `` is used to encapsulate the translated Chinese text for styling or formatting purposes in HTML. - The Chinese text translates to "通过外部访问集成从snowflake调用OpenAI GPT-4O模型API", which means "Call OpenAI GPT-4O model API from snowflake using External Access Integration" in English.

Here is the text translated into simplified Chinese while preserving the HTML structure: ```html 感谢Snowflake团队发布外部访问集成功能,这将允许Snowflake用户从Snowflake环境中调用任何API。 ```

Sure, here is the translated text in simplified Chinese, while keeping the HTML structure: ```html

本教程将向您展示如何设置调用OpenAI API版本大于1.x.x以调用GPT-4O模型的步骤。我假设您在Snowflake中拥有ACCOUNTADMIN角色来进行设置。

``` This HTML snippet translates the English text into Chinese and preserves the structural integrity of an HTML paragraph (`

`).

To translate "Step 1: Run the below query in Snowflake console to create a network rule which will allow Snowflake to access external URLs" into simplified Chinese while keeping the HTML structure, you can use the following: ```html

步骤 1:在Snowflake控制台中运行以下查询以创建一个网络规则,允许Snowflake访问外部URL。

``` This HTML snippet retains the structure necessary for displaying formatted text on a web page, while the Chinese translation conveys the original meaning accurately.
CREATE OR REPLACE NETWORK RULE openai_network_rule
MODE = EGRESS
TYPE = HOST_PORT
VALUE_LIST = ('api.openai.com');

Certainly! Here's how you can structure that sentence in HTML with the translated text in simplified Chinese: ```html

步骤2:在Snowflake中创建一个密钥,用于存储你的OpenAI API密钥,该密钥用于OpenAI身份验证。将你的OpenAI API密钥粘贴到SECRET_STRING变量的单引号内。

``` This HTML snippet preserves the structure while providing the translated text in simplified Chinese.
CREATE OR REPLACE SECRET open_ai_api_secret
TYPE = GENERIC_STRING
SECRET_STRING = '';

Certainly! Here's the translated text in simplified Chinese: **步骤 3:** 使用步骤 1 和步骤 2 中创建的网络规则和密钥,创建外部访问集成对象。

 CREATE OR REPLACE EXTERNAL ACCESS INTEGRATION openai_ext_access_int
ALLOWED_NETWORK_RULES = (openai_network_rule)
ALLOWED_AUTHENTICATION_SECRETS = (open_ai_api_secret)
ENABLED = true;

Certainly! Here is the translation of "step 4: run the below query to create a python UDF" in simplified Chinese while keeping the HTML structure intact: ```html

步骤 4:运行以下查询以创建一个 Python UDF

```
CREATE OR REPLACE FUNCTION ML_APP.ML_MODELS.open_ai_api(sentence STRING)
RETURNS STRING
LANGUAGE PYTHON
RUNTIME_VERSION = 3.11
HANDLER = 'get_response'
EXTERNAL_ACCESS_INTEGRATIONS = (openai_ext_access_int)
PACKAGES = ('openai')
SECRETS = ('cred' = open_ai_api_secret )
AS
$$
import _snowflake
from openai import OpenAI
import json

secret_object = _snowflake.get_generic_secret_string('cred');

client = OpenAI( api_key = str(secret_object) )

prompt = """ Answer questions asked by user """

def chat(system, user_assistant):
assert isinstance(system, str), "`system` should be a string"
assert isinstance(user_assistant, list), "`user_assistant` should be a list"
system_msg = [{"role": "system", "content": system}]
user_assistant_msgs = [
{"role": "assistant", "content": user_assistant[i]} if i % 2 else {"role": "user", "content": user_assistant[i]}
for i in range(len(user_assistant))]

msgs = system_msg + user_assistant_msgs

try:
completion = client.chat.completions.create(model="gpt-4o",
messages=msgs,
temperature=0, # Control the randomness of the generated response
n=1, # Generate a single response
stop=None )
except client.OpenAIError as e:
return "Failed to fetch response from OpenAI"

return completion.choices[0].message.content

def get_response(sentence):

response_fn_test = chat(prompt,['''question is - ''' + '''"''' + sentence + '''"'''+ '''.'''])
return response_fn_test
$$;

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

您可以使用以下方法调用第4步中创建的函数:

``` This HTML snippet translates to: "您可以使用以下方法调用第4步中创建的函数:"
select open_ai_api('Tell me a joke');

在保留HTML结构的情况下,将以下英文文本翻译成简体中文: 以下是示例输出

2024-06-27 04:26:21 AI中文站翻译自原文