diff --git a/server/urls.py b/server/urls.py index 46eb93e..00ad701 100644 --- a/server/urls.py +++ b/server/urls.py @@ -45,6 +45,7 @@ urlpatterns = [ path('bianji', JsMindbianjiView.as_view()), # 跳转到协同编辑页面 path('qunti', to_qunti), # 群体感知 + path('gptfenxi', to_gpt), # gpt分析 path('pinglun', JsMindpinglunView.as_view()), # 跳转到评论页面 # --------------------------------------------------- path('register', MindUserView.as_view()), # 用户注册 diff --git a/server/views/jump.py b/server/views/jump.py index e8fd0bd..b5fef81 100644 --- a/server/views/jump.py +++ b/server/views/jump.py @@ -7,6 +7,35 @@ import matplotlib.pyplot as plt from django.shortcuts import render from server.models import Task,StudentandTercher,Comment,Liuyan,CooperationMind,Jiaoben,Chat_info from server_auth.models import MindUser +from zhipuai import ZhipuAI +def gml_chat(name,messages): + print("--------------------") + print(messages) + client = ZhipuAI(api_key="92a0e4868cda21d22fe6fd0f4c0bf6fb.oZ4IE9PPDOhsLKPp") + + response = client.chat.completions.create( + model="glm-3-turbo", + # messages=[ + # { + # "role": "user", + # "content": prompt + # } + # ], + messages =[{ + "role": "user", + "content": "你现在是一名教育领域专家,请你从清晰性、完整性、布鲁姆认知层级三个方面对学小组作品内容进行分析,给我相应的返回结果即可。小组作品标题是:" + name + "小组作品内容是:" + messages + + }], + top_p=0.7, + temperature=0.95, + max_tokens=1024, + stream=True, + ) + content = "" + for trunk in response: + # print(trunk.choices[0].delta) + content = content + trunk.choices[0].delta.content + return content def front_comment(type): front_datas = [] @@ -211,7 +240,7 @@ def to_qunti(request): print("-----------------------------------------------") print(pinglun_info) # chat_content.append() - data.append([random.uniform(110,150),random.uniform(100,150),random.uniform(100,150)]) + data.append([random.uniform(110,150),random.uniform(100,150),random.uniform(100,150),random.uniform(120,150)]) data_time.append([random.uniform(10,20),random.uniform(20,40),random.uniform(40,60),random.uniform(60,80),random.uniform(80,100)]) xyz.append(random.uniform(300,800)) xyz2.append(random.uniform(200,600)) @@ -255,6 +284,15 @@ def to_qunti(request): return render(request, "html/echats.html", {"param":param,"name":name,"student":student,"datas":datas,"datas2":datas2,"datas3":datas3,"student4" :student4,"sui1":sui1,"sui2":sui2,"sui3":sui3,"sui4":sui4,"sui5":sui5,"sui6":sui6,"sui7":sui7,"sui8":sui8,"sui9":sui9,"datas4":datas4}) +def to_gpt(request): + name = CooperationMind.objects.get(id=request.GET.get('id')).coop_mind_name + content = CooperationMind.objects.get(id=request.GET.get('id')).snapshot_data + gpt_content = gml_chat(name,content) + print(gpt_content) + return render(request, "html/gpt.html", {"gpt_content":gpt_content}) + + + def share_to_detail(request): """ diff --git a/static/html/dashboard.html b/static/html/dashboard.html index cd9e09f..963c31a 100644 --- a/static/html/dashboard.html +++ b/static/html/dashboard.html @@ -109,6 +109,7 @@ 协同脑图 协同编辑 群体感知 + GPT课程分析 评论 删除` diff --git a/static/html/echats.html b/static/html/echats.html index a01909b..c251706 100644 --- a/static/html/echats.html +++ b/static/html/echats.html @@ -642,6 +642,7 @@ option = { { name: '积极', max: 200 }, { name: '消极', max: 200 }, { name: '中立', max: 200 }, + { name: '困惑', max: 200 }, ] }, series: [