xx-net chatgpt 使用

import pandas as pd
import numpy as np
import openai
import re
import time

# 查看宿主机IP
# cat /etc/resolv.conf
# 测试本地端口是否打开
# 配置中允许远程访问
# tcping 172.20.80.1 8085
# 防火墙新增8085端口的入站规则
# 认证API密钥
with open('/etc/resolv.conf') as file:
    resolv_conf_data = file.read()
ip_regex = r'\b(?:\d{1,3}\.){3}\d{1,3}\b'
host_ip=re.search(ip_regex, resolv_conf_data).group(0)

openai.api_key = "abc"
# openai.api_base = "http://172.20.80.1:8085/openai/v1"
openai.api_base = f"http://{host_ip}:8085/openai/v1"

completion = openai.ChatCompletion.create(
    model="gpt-3.5-turbo",
    messages=[{"role": "user", "content": "感冒最可能的ICD10的诊断编码"}])
print(completion.choices[0].message.content)

评论

此博客中的热门博文

V2ray websocket(ws)+tls+nginx分流

Rstudio 使用代理