python+openai 访问本地deepseek

一、环境说明

显卡:RTX 4080 -24GB

dp版本:deepseek-R1 14b

python:v3.20.1

用途:离线部署deepseek,建立本地知识库,测试地名拼音转中文

二、python代码

1.使用python openai库

pip install openai

2.构建deepseek 客户端访问类

'''
使用ollama 调用deepseek,进行地名地址拼音转中文
'''
import json
import ollama
from openai import OpenAI
from src.utils import commutil

class DeepseekUtil:
    client = None

    def __init__(self,*options):
        self.options = options
        global client
        '''
        deepseek 远程连接配置信息
        '''
        client = OpenAI(
            base_url='http://192.168.*.*:11434/v1/',
 

你可能感兴趣的:(python+银河麒麟,python,开发语言)