办公场景的使用

genAI在办公场景中有着广泛的应用,以下是主要的应用场景:

  • 文档处理与创作场景: 自动生成各类商务文档,包括商业计划书、项目提案、市场分析报告等专业文档,智能处理和整理各类会议记录和会议纪要,协助撰写新闻稿、公告、内部通知等公司通讯文件,提供文档翻译和本地化服务,确保多语言文档的准确性,自动生成数据分析报告,将复杂数据转化为易懂的叙述性文本。

  • 邮件与沟通场景: 智能撰写各类商务邮件,包括日常沟通、客户联络、销售跟进等,自动处理和分类收件箱中的邮件,提供快速回复建议,协助制定邮件处理优先级,生成会议邀请和日程安排的标准化文本,提供邮件模板和个性化定制服务。

  • 人力资源管理场景: 自动生成招聘信息和职位描述,智能筛选和评估求职者简历,生成员工培训材料和课程内容,编写绩效评估报告和反馈意见,制作员工手册和公司政策文档,处理常见的人事咨询问题。

  • 客户服务与支持场景: 开发智能客服系统,提供24/7的自动化服务,生成标准化的客户回复模板,处理客户投诉和反馈,创建产品使用说明和常见问题解答,提供个性化的客户服务建议等。

本节将从以下几个使用场景来介绍DeepSeek的能力:

  • 客服邮件自动回复

  • 自动生成简历

  • 生成会议纪要

客服邮件自动回复

prompt:

 prompt = f"Generate an {tone} email as a response from the cutomer support team to the customer for the following email:\n\n{email_content}\n\n" \
             "Ensure the response is polite, clear, and professional."

python代码:

import requests

# DeepSeek API 接口地址
OLLAMA_URL = "http://localhost:11434/api/generate"

def generate_email_response(email_content, tone="Formal"):
    """
    使用 DeepSeek AI 生成适当的电子邮件回复
    参数:
        email_content: 需要回复的邮件内容
        tone: 回复的语气,默认为正式语气
    返回:
        生成的邮件回复内容
    """
    # 构建提示词,要求AI生成客服团队的邮件回复
    prompt = f"Generate an {tone} email as a response from the cutomer support team to the customer for the following email:\n\n{email_content}\n\n" \
             "Ensure the response is polite, clear, and professional."

    # 多语言邮件回复提示词
    # prompt = f"Write an email response in {language}:\n\n{email_content}"

    # 构建请求参数
    payload = {
        "model": "deepseek-r1",  # 使用 deepseek-r1 模型
        "prompt": prompt,         # 提示词
        "stream": False          # 不使用流式响应
    }

    # 发送 POST 请求到 DeepSeek API
    response = requests.post(OLLAMA_URL, json=payload)

    # 处理响应结果
    if response.status_code == 200:
        return response.json().get("response", "No response generated.")
    else:
        return f"Error: {response.text}"


# 测试 AI 邮件回复功能
if __name__ == "__main__":
    # 测试邮件内容
    test_email = "I have a problem with my account. I can't log in. Please help me."

    print("### AI-Generated Email Response ###")
    print(generate_email_response(test_email))

测试结果:

image-20250211133254925

使用gradio生成web页面:

import requests
import gradio as gr
# DeepSeek API 接口地址
OLLAMA_URL = "http://localhost:11434/api/generate"

def generate_email_response(email_content, tone="Formal"):
    """
    使用 DeepSeek AI 生成适当的电子邮件回复
    参数:
        email_content: 需要回复的邮件内容
        tone: 回复的语气,默认为正式语气
    返回:
        生成的邮件回复内容
    """
    # 构建提示词,要求AI生成客服团队的邮件回复
    prompt = f"Generate an {tone} email as a response from the cutomer support team to the customer for the following email:\n\n{email_content}\n\n" \
             "Ensure the response is polite, clear, and professional."

    # 多语言邮件回复提示词
    # prompt = f"Write an email response in {language}:\n\n{email_content}"

    # 构建请求参数
    payload = {
        "model": "deepseek-r1",  # 使用 deepseek-r1 模型
        "prompt": prompt,         # 提示词
        "stream": False          # 不使用流式响应
    }

    # 发送 POST 请求到 DeepSeek API
    response = requests.post(OLLAMA_URL, json=payload)

    # 处理响应结果
    if response.status_code == 200:
        return response.json().get("response", "No response generated.")
    else:
        return f"Error: {response.text}"

# 创建 Gradio 界面
interface = gr.Interface(
    fn=generate_email_response,  # 调用邮件回复生成函数
    inputs=[
        gr.Textbox(lines=5, placeholder="在此粘贴邮件内容"),  # 文本输入框,5行
        gr.Radio(["Formal", "Casual", "Friendly"], label="语气"),  # 单选按钮选择语气
    ],
    outputs=gr.Textbox(label="AI生成的邮件回复"),  # 输出文本框
    title="AI邮件回复助手",  # 界面标题
    description="粘贴邮件内容,让AI生成专业的回复。"  # 界面描述
)

# 启动Web应用
if __name__ == "__main__":
    interface.launch()  # 启动Gradio界面

启动后进行测试:

image-20250211133740203

自动生成简历

prompt如下:

    prompt = f"Generate a professional resume based on the following details:\n\n" \
             f"Name: {name}\nJob Role: {job_role}\nExperience: {experience} years\n" \
             f"Skills: {skills}\nEducation: {education}\nSummary: {summary}\n\n" \
             f"Ensure the resume is ATS-friendly, well-formatted, and professional."

代码:

import requests
# DeepSeek API URL
# Ollama API的URL地址
OLLAMA_URL = "http://localhost:11434/api/generate"

def generate_resume(name, job_role, experience, skills, education, summary):
    """
    使用DeepSeek AI生成结构化的专业简历。
    """
    # 构建提示词,包含简历所需的所有信息
    prompt = f"Generate a professional resume based on the following details:\n\n" \
             f"Name: {name}\nJob Role: {job_role}\nExperience: {experience} years\n" \
             f"Skills: {skills}\nEducation: {education}\nSummary: {summary}\n\n" \
             f"Ensure the resume is ATS-friendly, well-formatted, and professional."


    # 旧的提示词模板,已注释掉
    # prompt = f"Generate a resume in {language}:\n\n{name}, {job_role}, {experience} years, {skills}, {education}"

    # 准备发送给API的数据
    payload = {
        "model": "deepseek-r1",
        "prompt": prompt,
        "stream": False
    }

    # 发送POST请求到Ollama API
    response = requests.post(OLLAMA_URL, json=payload)

    # 检查响应状态并返回结果
    if response.status_code == 200:
        return response.json().get("response", "No resume generated.")
    else:
        return f"Error: {response.text}"



# 测试简历生成器
if __name__ == "__main__":
    test_resume = generate_resume("John Doe", "Software Engineer", "3", 
                                  "Python, AI, Web Development", "B.Sc. CS", "Experienced in AI and cloud computing.")
    print("### AI-Generated Resume ###")
    print(test_resume)

image-20250211144953451

使用gradio做成webapp:

import requests
import gradio as gr

# Ollama API的URL地址
OLLAMA_URL = "http://localhost:11434/api/generate"

def generate_resume(name, job_role, experience, skills, education, summary):
    """
    使用DeepSeek AI生成结构化的专业简历。
    """
    # 构建提示词,包含简历所需的所有信息
    prompt = f"Generate a professional resume based on the following details:\n\n" \
             f"Name: {name}\nJob Role: {job_role}\nExperience: {experience} years\n" \
             f"Skills: {skills}\nEducation: {education}\nSummary: {summary}\n\n" \
             f"Ensure the resume is ATS-friendly, well-formatted, and professional."


    # 旧的提示词模板,已注释掉
    # prompt = f"Generate a resume in {language}:\n\n{name}, {job_role}, {experience} years, {skills}, {education}"

    # 准备发送给API的数据
    payload = {
        "model": "deepseek-r1",
        "prompt": prompt,
        "stream": False
    }

    # 发送POST请求到Ollama API
    response = requests.post(OLLAMA_URL, json=payload)

    # 检查响应状态并返回结果
    if response.status_code == 200:
        return response.json().get("response", "No resume generated.")
    else:
        return f"Error: {response.text}"


# 创建Gradio界面
interface = gr.Interface(
    fn=generate_resume,  # 指定处理函数
    inputs=[  # 定义输入组件
        gr.Textbox(label="Full Name"),  # 姓名输入框
        gr.Textbox(label="Job Role"),  # 职位输入框
        gr.Slider(0, 50, label="Years of Experience"),  # 工作年限滑块
        gr.Textbox(label="Skills (comma-separated)"),  # 技能输入框(逗号分隔)
        gr.Textbox(label="Education"),  # 教育经历输入框
        gr.Textbox(label="Summary (Optional)"),  # 个人总结输入框(可选)
    ],
    outputs=gr.Textbox(label="Generated Resume"),  # 定义输出组件为文本框
    title="AI-Powered Resume Generator",  # 设置应用标题
    description="Enter your details to generate a professional resume."  # 设置应用描述
)


# Launch the web app
if __name__ == "__main__":
    interface.launch()

运行后的效果:

image-20250211150055496

会议纪要

prompt:

    # 构建提示词,包含会议记录内容和要求提取的关键信息
    prompt = f"Summarize the following meeting transcript into structured meeting minutes:\n\n{transcript}\n\n" \
             "Extract key discussions, decisions made, and action items."

代码:

import requests

# Ollama API的URL地址
OLLAMA_URL = "http://localhost:11434/api/generate"

def generate_meeting_minutes(transcript):
    """
    使用DeepSeek AI生成结构化的会议纪要。
    """
    # 构建提示词,包含会议记录内容和要求提取的关键信息
    prompt = f"Summarize the following meeting transcript into structured meeting minutes:\n\n{transcript}\n\n" \
             "Extract key discussions, decisions made, and action items."

             
    # 准备发送给API的数据
    payload = {
        "model": "deepseek-r1",
        "prompt": prompt,
        "stream": False
    }

    # 发送POST请求到Ollama API
    response = requests.post(OLLAMA_URL, json=payload)

    # 检查响应状态并返回结果
    if response.status_code == 200:
        return response.json().get("response", "No summary generated.")
    else:
        return f"Error: {response.text}"


# 测试会议纪要生成器
if __name__ == "__main__":
    test_transcript = "John: Q4 sales increased by 15%. Sarah: We need to increase the marketing budget. Decision: Approve higher budget."
    print("### AI-Generated Meeting Minutes ###")
    print(generate_meeting_minutes(test_transcript))

效果:

image-20250211150754819