当前位置: 首页 > wzjs >正文

手机网站建设动态杭州最好的seo公司

手机网站建设动态,杭州最好的seo公司,seo简单速排名软件,广州一起做网站批发flask_app/ # 项目根目录 │ ├── app.py # Flask 主程序 ├── templates/ # 存放 HTML 模板文件 │ └── index.html # 前端页面 ├── static/ # 存放静态文件 │ └── script.js …


flask_app/                  # 项目根目录

├── app.py                  # Flask 主程序
├── templates/              # 存放 HTML 模板文件
│   └── index.html          # 前端页面
├── static/                 # 存放静态文件
│   └── script.js           # JavaScript 文件
└── requirements.txt        # 项目依赖文件


requirements.txt


PyMySQL~=1.1.1
flask~=3.1.0
openai~=1.65.4



$(document).ready(function() {// 加载系统列表$.get('/get_systems', function(data) {data.forEach(function(system) {// 检查是否已经存在相同的选项if (!$('#system-select option[value="' + system.id + '"]').length) {$('#system-select').append(`<option value="${system.id}">${system.systm}</option>`);}});});// 当选择系统时,加载对应的用户内容$('#system-select').change(function() {const systemId = $(this).val();$('#user-select').empty().append('<option value="">--Select a User Content--</option>');if (systemId) {$.get(`/get_users/${systemId}`, function(data) {data.forEach(function(user) {// 检查是否已经存在相同的选项if (!$('#user-select option[value="' + user.content + '"]').length) {$('#user-select').append(`<option value="${user.content}">${user.content}</option>`);}});});}});// 当选择用户内容时,将其放入文本框$('#user-select').change(function() {const userContent = $(this).val();$('#message-box').val(userContent);});// 发送消息到 DeepSeek$('#send-button').click(function() {const systemId = $('#system-select').val();const userMessage = $('#message-box').val();if (!systemId || !userMessage) {alert('请选择系统和输入消息内容!');return;}// 清空响应区域$('#response-text').text('');$.ajax({url: '/ask_deepseek',method: 'POST',contentType: 'application/json',data: JSON.stringify({system_id: systemId,user_message: userMessage}),success: function(data) {const htmlContent = marked.parse(data.response);$('#response-text').text(htmlContent);document.getElementById('response-text').innerHTML = htmlContent;},error: function(xhr, status, error) {console.error('Error:', error);alert('请求失败,请稍后重试!');}});});
});
<!DOCTYPE html>
<html lang="en">
<head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>Flask App</title><script src="https://code.jquery.com/jquery-3.6.0.min.js"></script><script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script><script src="{{ url_for('static', filename='script.js') }}"></script></head>
<body><h1>准备咨询的内容:</h1><label for="system-select">选择大类:</label><select id="system-select"><option value="">--请选择--</option></select><br><br><label for="user-select">选择细节:</label><select id="user-select" multiple size="10"><option value="">--请选择--</option></select><br><br><textarea id="message-box"  rows = 10,  placeholder="在这里输入您的信息..."></textarea><button id="send-button">Send</button><div id="response-area" width ="80%"><h2>反馈[请稍等]:</h2><div id="response-text"> </div></div><script src="{{ url_for('static', filename='script.js') }}"></script>
</body>
</html>
from flask import Flask, render_template, request, jsonify
import pymysql
from openai import OpenAIapp = Flask(__name__)# MySQL数据库配置
DB_CONFIG = {'host': 'mysql.sqlpub.com','port': 3306,'user': 'laocooon','password': 'fc12f7a5215e8e0a',  # 替换为你的密码'database': 'huangjin','cursorclass': pymysql.cursors.DictCursor  # 返回字典格式的结果
}def get_db_connection():return pymysql.connect(**DB_CONFIG)@app.route('/')
def index():return render_template('index.html')@app.route('/get_systems')
def get_systems():conn = get_db_connection()try:with conn.cursor() as cursor:cursor.execute('SELECT id, systm FROM systm')systems = cursor.fetchall()# print(systems)return jsonify(systems)finally:conn.close()@app.route('/get_users/<int:system_id>')
def get_users(system_id):conn = get_db_connection()try:with conn.cursor() as cursor:cursor.execute('SELECT id, content FROM user WHERE systemid = %s', (system_id,))users = cursor.fetchall()return jsonify(users)finally:conn.close()@app.route('/ask_deepseek', methods=['POST'])
def ask_deepseek():# print(request.json)system_id = request.json.get('system_id')user_message = request.json.get('user_message')conn = get_db_connection()try:with conn.cursor() as cursor:cursor.execute('SELECT systm FROM systm where id = %s', (system_id,))systems = cursor.fetchall()system_name = systems[0]['systm']finally:conn.close()# 这里调用DeepSeek的API# 假设你有一个函数 `call_deepseek_api(system_name, user_message)` 来处理API调用response = call_deepseek_api(system_id, user_message)# 假设response是DeepSeek的API返回的结果# print(response)return jsonify({'response': response})def call_deepseek_api(system_name, user_message):# 这里是调用DeepSeek API的逻辑# 你需要根据DeepSeek的API文档来实现# 这里只是一个示例client = OpenAI(api_key="sk-382a17fc1a914b4e804332c46a41ba46", base_url="https://api.deepseek.com")response = client.chat.completions.create(model="deepseek-chat",messages=[{"role": "system", "content": system_name},{"role": "user", "content": user_message},],stream=False)return response.choices[0].message.contentif __name__ == '__main__':# print(get_systems())app.run(debug=True)

http://www.dtcms.com/wzjs/311396.html

相关文章:

  • 门户网站 移动端沪指重上3000点
  • 网站上文章字体部分复制怎么做国内搜索引擎排行榜
  • 福州网站建设流程温岭网络推广
  • 青岛开发区网站建设公司windows优化大师官方网站
  • 国家市场监督管理总局反垄断局保定百度seo排名
  • 流动党员网站建设目标短视频营销成功的案例
  • 有没有做任务的网站吗谷歌关键词
  • 网站开发工程师简历深圳网络推广的公司
  • 关于文化的网站模板seo服务深圳
  • 巩义专业网站建设价格友链购买有效果吗
  • 根据网站集约化建设的要求百度搜索排行
  • 东莞品牌网站制作公司指数基金定投技巧
  • 唐山做网站企业网络搜索引擎有哪些
  • 抖音优化排名上海优化营商环境
  • seo顾问咨询谷歌seo顾问
  • 网站公安备案必须么知乎关键词排名优化
  • wordpress设置登录可见网站推广优化技巧
  • 六安手机网站建设seo网站关键词优化哪家好
  • c语言做网站后端真正免费的网站建站平台有哪些
  • 网站建设有哪些公司nba排名榜
  • 做网站小程序16种营销模型
  • 科技类网站简介怎么做宁波百度快照优化排名
  • 买个网站空间营销策划与运营
  • asp.net个人网站空间经典软文案例分析
  • 济宁专业网站开发公司公司宣传网页怎么做
  • 工厂 电商网站建设seo入门教程视频
  • 编程游戏杭州seo排名公司
  • 个人做网站多少钱百度推广有哪些推广方式
  • word在线编辑seo查询
  • 太原网站建设培训著名营销策划公司