中文亚洲精品无码_熟女乱子伦免费_人人超碰人人爱国产_亚洲熟妇女综合网

當(dāng)前位置: 首頁 > news >正文

營銷型網(wǎng)站建設(shè)申請(qǐng)域名時(shí)公司類型的域名后綴一般是廣州今日頭條新聞

營銷型網(wǎng)站建設(shè)申請(qǐng)域名時(shí)公司類型的域名后綴一般是,廣州今日頭條新聞,怎么幫人做網(wǎng)站,有哪些做包裝設(shè)計(jì)網(wǎng)站好些前言 本文介紹「星火杯」認(rèn)知大模型場景創(chuàng)新賽中的落選項(xiàng)目- AI命理分析系統(tǒng),屬于個(gè)人娛樂練手??偨Y(jié)提煉了往期文章精華并發(fā)掘出新的知識(shí)。 包括本地部署版本和Web在線版本,兩種打包方式基于 半自動(dòng)化使用.bat手動(dòng)打包遷移python項(xiàng)目 如何把 Gradio …

前言

本文介紹「星火杯」認(rèn)知大模型場景創(chuàng)新賽中的落選項(xiàng)目- AI命理分析系統(tǒng),屬于個(gè)人娛樂練手。總結(jié)提煉了往期文章精華并發(fā)掘出新的知識(shí)。
包括本地部署版本和Web在線版本,兩種打包方式基于
半自動(dòng)化使用.bat手動(dòng)打包遷移python項(xiàng)目

如何把 Gradio 應(yīng)用上傳到 Hugging Face
往期回顧:
從零開始-與大語言模型對(duì)話學(xué)技術(shù)-gradio篇(1)

從零開始-與大語言模型對(duì)話學(xué)技術(shù)-gradio篇(2)

從零開始-與大語言模型對(duì)話學(xué)技術(shù)-gradio篇(3)

項(xiàng)目簡介

本項(xiàng)目是一個(gè)集成化的AI命理分析系統(tǒng),實(shí)現(xiàn)了星座解析、塔羅解牌、八字合婚等多種智能化命理服務(wù)。系統(tǒng)通過Python和Gradio實(shí)現(xiàn)了交互式的網(wǎng)頁界面,用戶只需要輸入必要個(gè)人信息,即可獲得智能的命理運(yùn)勢分析。
Github鏈接

使用說明

最新Web在線版本使用

Web公開版本已在Hugging Face開源,點(diǎn)擊鏈接即可在線使用,不同于本地版本,你必須配置自己的星火APl,全平臺(tái)可用
hugging face連接
在這里插入圖片描述

本地部署版本

  1. 打開AI命理分析系統(tǒng)V4.0進(jìn)入虛擬python環(huán)境,自動(dòng)檢測依賴,安裝環(huán)境并運(yùn)行程序
    顯示如下提示表示編譯運(yùn)行成功,打開這個(gè)連接即可進(jìn)入系統(tǒng)

在這里插入圖片描述

  1. 你也可以打開GUI.py在末尾將demo.launch()修改為 demo.launch(share=True)
    那么你會(huì)額外獲取一個(gè)隨機(jī)的公開鏈接,你可以在任何設(shè)備上輸入網(wǎng)址訪問這個(gè)AI命理分析系統(tǒng)
    Running on local URL: http://127.0.0.1:7860
    Running on public URL: https://436fda53710f62fbbc.gradio.live
    This share link expires in 72 hours. For free permanent hosting and GPU upgrades,
    run gradio deploy from Terminal to deploy to Spaces (https://huggingface.co/spaces)

功能列表

  • 接入星火認(rèn)知大模型:你可以選擇使用我的API或者自行配置 配置好API才能使用后續(xù)功能!
    在這里插入圖片描述

  • AI星座解讀:輸入個(gè)人信息,獲得當(dāng)前月星座運(yùn)勢解析
    在這里插入圖片描述

  • AI塔羅牌解讀:用戶提問,系統(tǒng)抽取塔羅牌進(jìn)行占卜
    在這里插入圖片描述

  • AI八字合婚分析:輸入雙方八字,智能匹配分析婚姻
    在這里插入圖片描述

  • AI兔年運(yùn)勢預(yù)測:基于八字分析未來財(cái)運(yùn)、事業(yè)等在這里插入圖片描述

  • AI公司命理解析:根據(jù)個(gè)人信息以及公司名稱和行業(yè),分析公司運(yùn)勢。在這里插入圖片描述

  • AI姓名配對(duì):評(píng)估兩人姓名匹配程度
    在這里插入圖片描述

  • AI月老姻緣:分析最佳配對(duì)對(duì)象
    在這里插入圖片描述

  • AI八字精批:輸入八字信息獲得對(duì)應(yīng)運(yùn)勢的專業(yè)精批。
    在這里插入圖片描述

  • AI姓名分析:分析輸入的姓名對(duì)個(gè)人命運(yùn)的影響。
    在這里插入圖片描述

  • AI紫薇斗數(shù)解析:根據(jù)八字信息計(jì)算紫薇數(shù)值并進(jìn)行解讀
    在這里插入圖片描述

完整代碼

app.py

# -*- coding = utf-8 -*-
"""
# @Time : 2023/7/31 19:33
# @Author : CSDN:FriKlogff
# @File : app.py
# @Software: PyCharm
# @Function: 請(qǐng)輸入項(xiàng)目功能
"""
import os
os.system("""python -m pip install -i https://mirrors.aliyun.com/pypi/simple/ --upgrade pip setuptools
pip install -i https://mirrors.aliyun.com/pypi/simple/ websocket
pip install -i https://mirrors.aliyun.com/pypi/simple/ websocket-client
pip install -i https://mirrors.aliyun.com/pypi/simple/ gradio
pip install -i https://mirrors.aliyun.com/pypi/simple/ sxtwl
""")
from PublicFunctions import *
import gradio as gr# 定義星座選項(xiàng)
signs = ["白羊座", "金牛座", "雙子座", "巨蟹座", "獅子座", "處女座","天秤座", "天蝎座", "射手座", "摩羯座", "水瓶座", "雙魚座"]
cards_num = [1, 2, 3, 4, 5]
months = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
days = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31]
hours = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23]
# 使用 Gradio 的模塊化組件,構(gòu)建包含五個(gè)選項(xiàng)卡的界面
with gr.Blocks() as demo:with gr.Tab("星火api配置"):xh_input = [gr.components.Textbox(label="appid"),gr.components.Textbox(label="api_secret"),gr.components.Textbox(label="api_key"),gr.components.Textbox(label="gpt_url")]xh_output = gr.components.Textbox(label="點(diǎn)擊提交返回配置情況,請(qǐng)自行配置星火大模型API再使用后續(xù)功能")xh_button = gr.components.Button("提交")xh_button.click(xh_api, inputs=xh_input, outputs=xh_output)with gr.Tab("AI星座解讀"):horoscope_input = [gr.components.Radio(choices=["男", "女"], label="性別"),gr.components.Textbox(label="姓名"),gr.components.Number(label="出生年份"),gr.components.Dropdown(months, label="出生月份"),gr.components.Dropdown(days, label="出生日"),gr.components.Dropdown(hours, label="出生時(shí)辰"),gr.components.Dropdown(signs, label="選擇您的星座")]horoscope_output = gr.components.Textbox(label="星座解讀(由于我們的解析是由AI生成的,結(jié)果僅供娛樂,如果不成功請(qǐng)多試幾次)")horoscope_button = gr.components.Button("提交")horoscope_button.click(horoscope_reading, inputs=horoscope_input, outputs=horoscope_output)with gr.Tab("AI塔羅牌解讀"):tarot_input = [gr.components.Textbox(label="你想問的問題"),gr.components.Dropdown(cards_num, label="你想抽幾張牌"),]tarot_output = gr.components.Textbox(label="塔羅牌解析(由于我們的解析是由AI生成的,結(jié)果僅供娛樂,如果不成功請(qǐng)多試幾次)")upload_button = gr.components.Button("抽取")upload_button.click(tarot_reading, inputs=tarot_input, outputs=tarot_output)with gr.Tab("AI八字合婚分析"):marriage_input = [gr.components.Textbox(label="新郎姓名"),gr.components.Number(label="出生年份"),gr.components.Dropdown(months, label="出生月份"),gr.components.Dropdown(days, label="出生日"),gr.components.Dropdown(hours, label="出生時(shí)辰"),gr.components.Textbox(label="新娘姓名"),gr.components.Number(label="出生年份"),gr.components.Dropdown(months, label="出生月份"),gr.components.Dropdown(days, label="出生日"),gr.components.Dropdown(hours, label="出生時(shí)辰"),]marriage_analysis_output = gr.components.Textbox(label="婚姻分析(由于我們的解析是由AI生成的,結(jié)果僅供娛樂,如果不成功請(qǐng)多試幾次)")analyze_button = gr.components.Button("馬上測算")analyze_button.click(marriage_bazi_analysis,inputs=marriage_input,outputs=marriage_analysis_output)with gr.Tab("AI兔年運(yùn)程預(yù)測"):birth_year_input = [gr.components.Radio(choices=["男", "女"], label="性別"),gr.components.Textbox(label="姓名"),gr.components.Number(label="出生年份"),gr.components.Dropdown(months, label="出生月份"),gr.components.Dropdown(days, label="出生日"),gr.components.Dropdown(hours, label="出生時(shí)辰"),]prediction_output = gr.components.Textbox(label="運(yùn)程預(yù)測(由于我們的解析是由AI生成的,結(jié)果僅供娛樂,如果不成功請(qǐng)多試幾次)")predict_button = gr.components.Button("預(yù)測運(yùn)勢")predict_button.click(rabbit_year_prediction,inputs=birth_year_input,outputs=prediction_output)with gr.Tab("AI公司命理解析"):company_name_input = [gr.components.Radio(choices=["男", "女"], label="性別"),gr.components.Textbox(label="姓名"),gr.components.Number(label="出生年份"),gr.components.Dropdown(months, label="出生月份"),gr.components.Dropdown(days, label="出生日"),gr.components.Dropdown(hours, label="出生時(shí)辰"),gr.components.Textbox(label="公司名稱"),gr.components.Textbox(label="所屬行業(yè)")]name_analysis_output = gr.components.Textbox(label="命理分析(由于我們的解析是由AI生成的,結(jié)果僅供娛樂,如果不成功請(qǐng)多試幾次)")analyze_button = gr.components.Button("分析")analyze_button.click(company_name_analysis,inputs=company_name_input,outputs=name_analysis_output)with gr.Tab("AI姓名配對(duì)"):name1_input = [gr.components.Textbox(label="姓名1"),gr.components.Textbox(label="姓名2"),]matching_output = gr.components.Textbox(label="配對(duì)結(jié)果(由于我們的解析是由AI生成的,結(jié)果僅供娛樂,如果不成功請(qǐng)多試幾次)")match_button = gr.components.Button("分析配對(duì)")match_button.click(name_compatibility,inputs=name1_input,outputs=matching_output)with gr.Tab("AI月老姻緣"):yue_lau_input = [gr.components.Radio(choices=["男", "女"], label="性別"),gr.components.Textbox(label="姓名"),gr.components.Number(label="出生年份"),gr.components.Dropdown(months, label="出生月份"),gr.components.Dropdown(days, label="出生日"),gr.components.Dropdown(hours, label="出生時(shí)辰"),]affinity_output = gr.components.Textbox(label="姻緣分析(由于我們的解析是由AI生成的,結(jié)果僅供娛樂,如果不成功請(qǐng)多試幾次)")analyze_button = gr.components.Button("分析姻緣")analyze_button.click(yue_lau_affinity,inputs=yue_lau_input,outputs=affinity_output)with gr.Tab("AI八字精批"):bazi_input = [gr.components.Radio(choices=["男", "女"], label="性別"),gr.components.Textbox(label="姓名"),gr.components.Number(label="出生年份"),gr.components.Dropdown(months, label="出生月份"),gr.components.Dropdown(days, label="出生日"),gr.components.Dropdown(hours, label="出生時(shí)辰"),]analysis_output = gr.components.Textbox(label="精批結(jié)果(由于我們的解析是由AI生成的,結(jié)果僅供娛樂,如果不成功請(qǐng)多試幾次)")batch_button = gr.components.Button("八字精批")batch_button.click(bazi_analysis,inputs=bazi_input,outputs=analysis_output)with gr.Tab("AI姓名分析"):name_input = [gr.components.Radio(choices=["男", "女"], label="性別"),gr.components.Textbox(label="姓名")]name_output = gr.components.Textbox(label="命理分析(由于我們的解析是由AI生成的,結(jié)果僅供娛樂,如果不成功請(qǐng)多試幾次)")analyze_button = gr.components.Button("分析姓名")analyze_button.click(name_analysis,inputs=name_input,outputs=name_output)with gr.Tab("AI紫薇斗數(shù)解析"):zhiwei_input = [gr.components.Radio(choices=["男", "女"], label="性別"),gr.components.Textbox(label="姓名"),gr.components.Number(label="出生年份"),gr.components.Dropdown(months, label="出生月份"),gr.components.Dropdown(days, label="出生日"),gr.components.Dropdown(hours, label="出生時(shí)辰"),]zhiwei_output = gr.components.Textbox(label="紫薇解讀(由于我們的解析是由AI生成的,結(jié)果僅供娛樂,如果不成功請(qǐng)多試幾次)")zhiwei_button = gr.components.Button("解讀運(yùn)勢")zhiwei_button.click(zhiwei_analysis,inputs=zhiwei_input,outputs=zhiwei_output)
demo.launch()
# demo.launch(share=True)

PublicFunctions.py

# -*- coding = utf-8 -*-
"""
# @Time : 2023/7/31 19:35
# @Author : CSDN:FriKlogff
# @File : PublicFunctions.py
# @Software: PyCharm
# @Function: 請(qǐng)輸入項(xiàng)目功能
"""import os
os.system("""python -m pip install -i https://mirrors.aliyun.com/pypi/simple/ --upgrade pip setuptools
pip install -i https://mirrors.aliyun.com/pypi/simple/ websocket
pip install -i https://mirrors.aliyun.com/pypi/simple/ websocket-client
pip install -i https://mirrors.aliyun.com/pypi/simple/ gradio
pip install -i https://mirrors.aliyun.com/pypi/simple/ sxtwl
""")
import sxtwl
from XhApi import *
import XhApi# print(XhApi.response_content)
Gan = ["甲", "乙", "丙", "丁", "戊", "己", "庚", "辛", "壬", "癸"]
Zhi = ["子", "丑", "寅", "卯", "辰", "巳", "午", "未", "申", "酉", "戌", "亥"]
appid = ''
api_secret = ''
api_key = ''
gpt_url = ''def generate_bazi(year, month, day, hour):year = int(year)month = int(month)day = int(day)hour = int(hour)date = sxtwl.fromSolar(year, month, day)# 獲取年柱yTG = date.getYearGZ()ganzhi_year = Gan[yTG.tg] + Zhi[yTG.dz]# 獲取月柱mTG = date.getMonthGZ()ganzhi_month = Gan[mTG.tg] + Zhi[mTG.dz]# 獲取日柱dTG = date.getDayGZ()ganzhi_day = Gan[dTG.tg] + Zhi[dTG.dz]# 獲取時(shí)柱dayGan = dTG.tghTG = sxtwl.getShiGz(dayGan, hour)ganzhi_hour = Gan[hTG.tg] + Zhi[hTG.dz]return f"{ganzhi_year}{ganzhi_month}{ganzhi_day}{ganzhi_hour}時(shí)"def xh_api( user_appid, user_api_secret, user_api_key, user_gpt_url):global appid, api_secret, api_key, gpt_urlif user_appid == '' or user_api_secret == '' or user_api_key == '' or user_gpt_url == '':return "any api cannot be empty!"appid = str(user_appid)api_secret = str(user_api_secret)api_key = str(user_api_key)gpt_url = str(user_gpt_url)# print(type(appid), type(api_secret), type(api_key), type(gpt_url))# print(appid, api_secret, api_key, gpt_url)return "appid = "+appid+"\napi_secret = "+api_secret+"\napi_key = "+api_key+"\ngpt_url = "+gpt_urldef horoscope_reading(sex, name, birth_year, birth_month, birth_day, birth_hour, star):XhApi.response_content = ''global appid, api_secret, api_key, gpt_urlbirth_year = str(int(birth_year))if sex is None:return "sex cannot be empty!"if name == '' or birth_year == '' or birth_month == '' or birth_day == '' or birth_hour == '' or star == '':return "Name or birth_year or birth_month or birth_day or star cannot be empty!"if birth_year == "0":return "0 is not a suitable value of birth_year!"template = "假設(shè)你是一位專業(yè)的星座運(yùn)勢分析師,根據(jù)客戶提供的出生日期和時(shí)間,你需要進(jìn)行以下幾方面的詳細(xì)分析工作:\n" \"1. 分析用戶的星座及性格特點(diǎn)\n" \"2. 根據(jù)月球周期判斷事業(yè)和學(xué)業(yè)趨勢\n" \"3. 提供維持提升感情的建議\n" \"4. 預(yù)測財(cái)務(wù)收入和投資趨勢\n" \"5. 提出健康保健建議\n" \"作為專業(yè)分析師,你需要用通俗語言解釋理論,并提供專業(yè)建議\n"template += "客戶信息:\n"template += "性別:{sex}\n"template += "姓名:{name}\n"template += "星座:{star}\n"template += "出生日期:{birth_year}-{birth_month}-{birth_day}-{birth_hour}"question = template.format(sex=sex, name=name, birth_year=birth_year, birth_month=birth_month, birth_day=birth_day,birth_hour=birth_hour,star=star)# print(appid, api_secret, api_key, gpt_url)return main(appid=appid,api_secret=api_secret,api_key=api_key,gpt_url=gpt_url,question=question)def tarot_reading(question, num_cards):XhApi.response_content = ''global appid, api_secret, api_key, gpt_urlif question == '' or num_cards is None or num_cards == 0:return "question ornum_cards cannot be empty!"template = "假設(shè)你是一位專業(yè)的塔羅牌占卜師。用戶提出的問題是:{question}。"template += "根據(jù)用戶的問題,你需要為TA抽取{num_cards}張塔羅牌,"template += "解讀每張塔羅牌的含義,"template += "綜合牌面分析用戶所問的問題,"template += "并根據(jù)占卜結(jié)果給予專業(yè)的建議。"template += "具體來說,你需要:\n"template += "1. 為用戶抽取指定數(shù)量的塔羅牌\n"template += "2. 逐一解析每張塔羅牌的符號(hào)和含義\n"template += "3. 綜合各牌面意義,對(duì)用戶提問進(jìn)行占卜分析\n"template += "4. 根據(jù)占卜結(jié)果,給出專業(yè)建議或預(yù)言"question = template.format(question=question, num_cards=int(num_cards))return main(appid=appid,api_secret=api_secret,api_key=api_key,gpt_url=gpt_url,question=question)def marriage_bazi_analysis(name_husband, birth_year_husband, birth_month_husband, birth_day_husband, birth_hour_husband,name_wife, birth_year_wife, birth_month_wife, birth_day_wife, birth_hour_wife):XhApi.response_content = ''global appid, api_secret, api_key, gpt_urlbirth_year_husband = int(birth_year_husband)birth_year_wife = int(birth_year_wife)if name_husband == '' or birth_year_husband == '' or birth_month_husband == '' or birth_day_husband == '' or birth_hour_husband == '' \or name_wife == '' or birth_year_wife == '' or birth_month_wife == '' or birth_day_wife == '' or birth_hour_wife == '':return "Name or birth_year or birth_month or birth_day  cannot be empty!"if birth_year_husband == 0 or birth_year_wife == 0:return "0 is not a suitable value of birth_year!"bazi_husband = generate_bazi(birth_year_husband, birth_month_husband, birth_day_husband, birth_hour_husband)bazi_wife = generate_bazi(birth_year_wife, birth_month_wife, birth_day_wife, birth_hour_wife)# print(bazi_wife, bazi_husband)template = "假設(shè)你是一位專業(yè)的八字合婚分析師,你正在為一對(duì)新人進(jìn)行八字合婚分析。" \"分析基于八字五行、十神、四柱的原理判斷兩人姻緣。重點(diǎn)看天格、年格五行相生相克。" \"以下是他們的基本信息\n"template += "新郎信息:\n"template += "姓名:{name_husband}\n"template += "出生日期:{birth_year_husband}-{birth_month_husband}-{birth_day_husband}\n"  # 根據(jù)用戶的選擇生成問題template += "八字:{bazi_husband}\n"template += "新娘信息:\n"template += "姓名:{name_wife}\n"template += "出生日期:{birth_year_wife}-{birth_month_wife}-{birth_day_wife}\n"  # 根據(jù)用戶的選擇生成問題template += "八字:{bazi_wife}\n"template += "作為資深的合婚分析師,你需要:\n"template += "1. 分析兩人八字五行相生相克關(guān)系\n"template += "2. 比較兩人十神是否匹配\n"template += "3. 檢查四柱運(yùn)勢是否協(xié)調(diào)\n"template += "4. 給出姻緣匹配度及建議\n"question = template.format(name_husband=name_husband, name_wife=name_wife, bazi_husband=bazi_husband,bazi_wife=bazi_wife, birth_year_husband=birth_year_husband,birth_month_husband=birth_month_husband, birth_day_husband=birth_day_husband,birth_year_wife=birth_year_wife, birth_month_wife=birth_month_wife,birth_day_wife=birth_day_wife)return main(appid=appid,api_secret=api_secret,api_key=api_key,gpt_url=gpt_url,question=question)# 兔年運(yùn)程
def rabbit_year_prediction(sex, name, birth_year, birth_month, birth_day, birth_hour):XhApi.response_content = ''global appid, api_secret, api_key, gpt_urlbirth_year = int(birth_year)bazi = generate_bazi(int(birth_year), int(birth_month), int(birth_day), int(birth_hour))if sex is None:return "sex cannot be empty!"if name == '' or birth_year == '' or birth_month == '' or birth_day == '' or birth_hour == '':return "Name or birth_year or birth_month or birth_day cannot be empty!"if birth_year == 0:return "0 is not a suitable value of birth_year!"template = "假設(shè)你是一位專業(yè)的命理師,仔細(xì)分析客戶信息,結(jié)合通勝原理,考量客戶的五行八字、天干合化等,對(duì)在兔年客戶的事業(yè)、財(cái)富、姻緣等命局進(jìn)行預(yù)測,并給出建議。"template += "\n客戶信息:\n"template += "性別:{sex}\n"template += "姓名:{name}\n"template += "出生日期:{birth_year}-{birth_month}-{birth_day}-{birth_hour}\n"template += "八字:{bazi}\n"template += "具體來說,你需要:\n"template += "1. 檢查客戶八字和五行屬性\n"template += "2. 分析天干合化對(duì)命局的影響\n"template += "3. 考量通勝原理對(duì)運(yùn)勢的作用\n"template += "4. 對(duì)事業(yè)、財(cái)富、姻緣等命局給出預(yù)測\n"template += "5. 提供專業(yè)建議"question = template.format(sex=sex, name=name, birth_year=birth_year, birth_month=birth_month, birth_day=birth_day,birth_hour=birth_hour, bazi=bazi)return main(appid=appid,api_secret=api_secret,api_key=api_key,gpt_url=gpt_url,question=question)# 公司測名
def company_name_analysis(sex, name, birth_year, birth_month, birth_day, birth_hour, company_name, industry):XhApi.response_content = ''global appid, api_secret, api_key, gpt_urlbirth_year = int(birth_year)if sex is None:return "sex cannot be empty!"if name == '' or birth_year == '' or birth_month == '' or birth_day == '' or birth_hour == '' or company_name == '' or industry == '':return "Name or birth_year or birth_month or birth_day  or company_name  or industry cannot be empty!"if birth_year == 0:return "0 is not a suitable value of birth_year!"template = "假設(shè)你是一位公司命理專家,根據(jù)立命八字學(xué)說,姓名、公司名與行業(yè)之間存在相生相克的關(guān)系," \"需要綜合考量五行、八卦、吉兇等理論,分析它們之間的互動(dòng)對(duì)企業(yè)發(fā)展的影響," \"發(fā)掘其中蘊(yùn)含的福祿文星,提出建議以改善財(cái)運(yùn)。"template += "\n客戶信息:\n"template += "性別:{sex}\n"template += "姓名:{name}\n"template += "出生日期:{birth_year}-{birth_month}-{birth_day}-{birth_hour}\n"template += "公司名:{company_name}\n"template += "行業(yè):{industry}\n"template += "具體來說,你需要:\n"template += "1. 分析客戶姓名五行屬性\n"template += "2. 考量公司名五行與行業(yè)五行關(guān)系\n"template += "3. 判斷相生相克對(duì)企業(yè)運(yùn)勢的影響\n"template += "4. 發(fā)掘姓名、公司名蘊(yùn)含的福星\n"template += "5. 提出改善企業(yè)財(cái)運(yùn)的專業(yè)建議"question = template.format(sex=sex, name=name, birth_year=birth_year, birth_month=birth_month, birth_day=birth_day,birth_hour=birth_hour,company_name=company_name, industry=industry)return main(appid=appid,api_secret=api_secret,api_key=api_key,gpt_url=gpt_url,question=question)# 姓名配對(duì)
def name_compatibility(name1, name2):XhApi.response_content = ''global appid, api_secret, api_key, gpt_urlif name1 == '' or name2 == '':return "name1 or name2 cannot be empty!"template = "假設(shè)你是一位姓名學(xué)專家。用戶提供了兩人的姓名:{name1}和{name2}。"template += "作為專家,你需要分析他們兩人姓名的五行、筆畫等特征,"template += "判斷姓名間的五行關(guān)系是否協(xié)調(diào)、筆畫關(guān)系是否匹配,"template += "從姓名學(xué)角度出發(fā),分析這兩人的姓名是否配對(duì)。"template += "具體來說,你需要:\n"template += "1. 分析{name1}的五行屬性和筆畫數(shù)\n"template += "2. 分析{name2}的五行屬性和筆畫數(shù)\n"template += "3. 判斷兩人姓名的五行相生相克關(guān)系\n"template += "4. 判斷兩人姓名筆畫數(shù)差是否合適\n"template += "5. 從姓名學(xué)角度給出配對(duì)建議\n"template += "最后要給出專業(yè)建議,說明這對(duì)姓名的搭配優(yōu)劣勢。"question = template.format(name1=name1, name2=name2)return main(appid=appid,api_secret=api_secret,api_key=api_key,gpt_url=gpt_url,question=question)# 月老姻緣
def yue_lau_affinity(sex, name, birth_year, birth_month, birth_day, birth_hour):XhApi.response_content = ''global appid, api_secret, api_key, gpt_urlbirth_year = int(birth_year)bazi = generate_bazi(int(birth_year), int(birth_month), int(birth_day), int(birth_hour))if sex is None:return "sex cannot be empty!"if name == '' or birth_year == '' or birth_month == '' or birth_day == '' or birth_hour == '':return "Name or birth_year or birth_month or birth_day cannot be empty!"if birth_year == 0:return "0 is not a suitable value of birth_year!"template = "假設(shè)你是一位月老姻緣專家。有客戶需要你的幫助,其信息如下:\n"template += "性別:{sex}\n"template += "姓名:{name}\n"template += "出生日期:{birth_year}-{birth_month}-{birth_day}-{birth_hour}\n"template += "八字:{bazi}\n"template += "作為月老專家,你需要基于客戶的姓名、性別、出生日期等信息,"template += "來分析其感情運(yùn)勢、最佳配對(duì)對(duì)象,"template += "給出專業(yè)的建議,幫助客戶找到適合的另一半。"template += "具體來說,你需要:\n"template += "1. 分析客戶八字姻緣格局\n"template += "2. 考量姓名數(shù)字對(duì)婚姻的影響\n"template += "3. 判斷最佳配對(duì)對(duì)象的特征\n"template += "4. 提出改善感情運(yùn)勢的建議"question = template.format(sex=sex, name=name, birth_year=birth_year, birth_month=birth_month, birth_day=birth_day,birth_hour=birth_hour, bazi=bazi)return main(appid=appid,api_secret=api_secret,api_key=api_key,gpt_url=gpt_url,question=question)# 八字精批
def bazi_analysis(sex, name, birth_year, birth_month, birth_day, birth_hour):XhApi.response_content = ''global appid, api_secret, api_key, gpt_urlbirth_year = int(birth_year)if sex is None:return "sex cannot be empty!"if name == '' or birth_year == '' or birth_month == '' or birth_day == '':return "Name or birth_year or birth_month or birth_day cannot be empty!"if birth_year == 0:return "0 is not a suitable value of birth_year!"bazi = generate_bazi(int(birth_year), int(birth_month), int(birth_day), int(birth_hour))template = "假設(shè)你是一位資深的八字命理師。有客戶需要你對(duì)其八字進(jìn)行專業(yè)精批,其信息如下:\n"template += "性別:{sex}\n"template += "姓名:{name}\n"template += "八字:{bazi}\n"template += "作為八字命理專家,你需要根據(jù)客戶的八字,"template += "分析事業(yè)財(cái)運(yùn)、健康等方面的運(yùn)勢趨勢,"template += "具體來說,你需要:\n"template += "1. 檢查天干五行對(duì)事業(yè)財(cái)運(yùn)的影響\n"template += "2. 分析八字各宮協(xié)調(diào)性和局部格局\n"template += "3. 指出八字優(yōu)勢和劣勢\n"template += "4. 提出合理的改善建議"question = template.format(sex=sex, name=name, bazi=bazi)return main(appid=appid,api_secret=api_secret,api_key=api_key,gpt_url=gpt_url,question=question)def zhiwei_analysis(sex, name, birth_year, birth_month, birth_day, birth_hour):XhApi.response_content = ''global appid, api_secret, api_key, gpt_urlbirth_year = int(birth_year)if sex is None:return "sex cannot be empty!"if name == '' or birth_year == '' or birth_month == '' or birth_day == '':return "Name or birth_year or birth_month or birth_day cannot be empty!"if birth_year == 0:return "0 is not a suitable value of birth_year!"# print(sex, name, birth_year, birth_month, birth_day)bazi = generate_bazi(int(birth_year), int(birth_month), int(birth_day), int(birth_hour))template = "假設(shè)你是一位紫薇斗數(shù)專家,接收到客戶的出生八字后,你會(huì)依次完成以下步驟:\n" \"1. 計(jì)算該八字的紫微星位置,代表其總體運(yùn)勢\n" \"2. 分析年柱運(yùn)程,判斷事業(yè)財(cái)運(yùn)\n" \"3. 分析月柱運(yùn)程,判斷感情運(yùn)\n" \"4. 分析日柱運(yùn)程,判斷健康運(yùn)\n" \"5. 綜合四柱運(yùn)勢對(duì)該客戶的綜合運(yùn)勢做出詳細(xì)的預(yù)言分析\n" \"客戶信息:\n" \"性別:{sex}\n" \"姓名:{name}\n" \"八字為:{bazi}"question = template.format(sex=sex, name=name, bazi=bazi)return main(appid=appid,api_secret=api_secret,api_key=api_key,gpt_url=gpt_url,question=question)# 姓名分析def name_analysis(sex, name):XhApi.response_content = ''global appid, api_secret, api_key, gpt_urlif sex is None:return "sex cannot be empty!"if name == '':return "Name cannot be empty!"template = "假設(shè)你是一位姓名學(xué)專家,請(qǐng)根據(jù)客戶的姓名,分析其一生運(yùn)勢。\n"template += "要點(diǎn)包括:\n"template += "- 姓名的諧音是否吉利\n"template += "- 姓名筆畫多寡對(duì)品性的影響\n"template += "- 單名雙名優(yōu)劣\n"template += "客戶的姓名為 {name},性別為{sex},分析對(duì)其事業(yè)、婚姻、健康等方面的影響,并提出建議。"template += "具體來說,你需要\n"template += "1. 分析客戶姓名諧音\n"template += "2. 判斷姓名筆畫數(shù)命理含義\n"template += "3. 討論單名雙名特點(diǎn)\n"template += "4. 分析姓名對(duì)運(yùn)勢各方面的影響\n"template += "5. 提出改善命運(yùn)的專業(yè)建議"question = template.format(name=name, sex=sex)return main(appid=appid,api_secret=api_secret,api_key=api_key,gpt_url=gpt_url,question=question)

XhApi.py

# -*- coding = utf-8 -*-
"""
# @Time : 2023/7/20 12:37
# @Author : CSDN:FriKlogff
# @File : XhApi.py
# @Software: PyCharm
# @Function: 星火大模型API
"""
import os
os.system("""python -m pip install -i https://mirrors.aliyun.com/pypi/simple/ --upgrade pip setuptools
pip install -i https://mirrors.aliyun.com/pypi/simple/ websocket
pip install -i https://mirrors.aliyun.com/pypi/simple/ websocket-client
pip install -i https://mirrors.aliyun.com/pypi/simple/ gradio
pip install -i https://mirrors.aliyun.com/pypi/simple/ sxtwl
""")
import _thread as thread  # 導(dǎo)入線程模塊
import base64  # 導(dǎo)入base64編碼模塊
import datetime  # 導(dǎo)入datetime模塊
import hashlib  # 導(dǎo)入hashlib模塊
import hmac  # 導(dǎo)入hmac模塊
import json  # 導(dǎo)入json模塊
from urllib.parse import urlparse  # 從urllib.parse導(dǎo)入urlparse用于url解析
import ssl  # 導(dǎo)入ssl模塊
from datetime import datetime  # 從datetime導(dǎo)入datetime類
from time import mktime  # 從time導(dǎo)入mktime用于生成時(shí)間戳
from urllib.parse import urlencode  # 從urllib.parse導(dǎo)入urlencode用于編碼請(qǐng)求參數(shù)
from wsgiref.handlers import format_date_time  # 從wsgiref.handlers導(dǎo)入format_date_time用于格式化時(shí)間import websocket  # 導(dǎo)入websocket模塊response_content = ""# 請(qǐng)求參數(shù)類
class Ws_Param:# 初始化def __init__(self, APPID, APIKey, APISecret, gpt_url):self.APPID = APPID  # 應(yīng)用IDself.APIKey = APIKey  # API Keyself.APISecret = APISecret  # API Secretself.host = urlparse(gpt_url).netloc  # 從url解析出hostself.path = urlparse(gpt_url).path  # 從url解析出pathself.gpt_url = gpt_url  # 完整的url# 生成簽名和url的方法def create_url(self):now = datetime.now()  # 當(dāng)前時(shí)間date = format_date_time(mktime(now.timetuple()))  # 格式化的時(shí)間戳# 拼接簽名原文signature_origin = "host: " + self.host + "\n"signature_origin += "date: " + date + "\n"signature_origin += "GET " + self.path + " HTTP/1.1"# 生成簽名signature_sha = hmac.new(self.APISecret.encode('utf-8'), signature_origin.encode('utf-8'),digestmod=hashlib.sha256).digest()signature_sha_base64 = base64.b64encode(signature_sha).decode(encoding='utf-8')# 生成授權(quán)headerauthorization_origin = f'api_key="{self.APIKey}", algorithm="hmac-sha256", headers="host date request-line", signature="{signature_sha_base64}"'authorization = base64.b64encode(authorization_origin.encode('utf-8')).decode(encoding='utf-8')# 生成url參數(shù)字典v = {"authorization": authorization,"date": date,"host": self.host}# 構(gòu)造最終urlurl = self.gpt_url + '?' + urlencode(v)return url# 收到websocket錯(cuò)誤的處理
def on_error(ws, error):print("### error:", error)# 收到websocket關(guān)閉的處理
def on_close(ws):print("### closed ###")# 收到websocket連接建立的處理
def on_open(ws):thread.start_new_thread(run, (ws,))# 發(fā)送請(qǐng)求的方法
def run(ws, *args):data = json.dumps(gen_params(appid=ws.appid, question=ws.question))ws.send(data)# 收到websocket消息的處理
def on_message(ws, message):print(message)data = json.loads(message)code = data['header']['code']if code != 0:print(f'請(qǐng)求錯(cuò)誤: {code}, {data}')ws.close()else:choices = data["payload"]["choices"]status = choices["status"]content = choices["text"][0]["content"]print(content, end='')global response_contentresponse_content += contentif status == 2:ws.close()# 生成請(qǐng)求參數(shù)
def gen_params(appid, question):"""通過appid和用戶的提問來生成請(qǐng)參數(shù)"""data = {"header": {"app_id": appid,"uid": "1234"},"parameter": {"chat": {"domain": "general","random_threshold": 0.5,"max_tokens": 2048,"auditing": "default"}},"payload": {"message": {"text": [{"role": "user", "content": question}]}}}return datadef main(appid, api_key, api_secret, gpt_url, question):wsParam = Ws_Param(appid, api_key, api_secret, gpt_url)websocket.enableTrace(False)wsUrl = wsParam.create_url()ws = websocket.WebSocketApp(wsUrl, on_message=on_message, on_error=on_error, on_close=on_close, on_open=on_open)ws.appid = appidws.question = questionws.run_forever(sslopt={"cert_reqs": ssl.CERT_NONE})return response_content
http://www.risenshineclean.com/news/53871.html

相關(guān)文章:

  • 凡科做網(wǎng)站有什么用軟文代寫費(fèi)用
  • wordpress qq聯(lián)系代碼app優(yōu)化排名
  • 網(wǎng)站后臺(tái)統(tǒng)計(jì)代碼福州網(wǎng)站seo公司
  • 專做藥材的網(wǎng)站有哪些東莞優(yōu)化網(wǎng)站關(guān)鍵詞優(yōu)化
  • 網(wǎng)站開發(fā)算前端嗎合肥網(wǎng)站建設(shè)
  • 網(wǎng)站建設(shè)項(xiàng)目經(jīng)理考題怎么seo網(wǎng)站關(guān)鍵詞優(yōu)化
  • 網(wǎng)站排名易下拉教程app推廣在哪里可以接單
  • 東莞美食網(wǎng)站建設(shè)報(bào)價(jià)承德網(wǎng)絡(luò)推廣
  • 網(wǎng)站建設(shè)截圖中國女排聯(lián)賽排名
  • 商贏網(wǎng)站建設(shè)百度注冊(cè)
  • 免費(fèi)自制主題app滕州seo
  • 用護(hù)衛(wèi)神做共享網(wǎng)站優(yōu)化課程設(shè)置
  • 建設(shè)網(wǎng)站個(gè)人簡介范文短視頻入口seo
  • 網(wǎng)站目錄管理系統(tǒng)模板aso搜索排名優(yōu)化
  • 電子商務(wù)網(wǎng)站的建設(shè)收益seo做的比較牛的公司
  • 網(wǎng)站建設(shè)尺寸金華網(wǎng)站推廣
  • 如何讓網(wǎng)站被百度收入如何優(yōu)化網(wǎng)站快速排名
  • 學(xué)院網(wǎng)站建設(shè) 需求分析百度自己的宣傳廣告
  • 高端網(wǎng)站優(yōu)化公司專業(yè)制作網(wǎng)站的公司哪家好
  • 金寨縣建設(shè)規(guī)劃局網(wǎng)站企業(yè)管理軟件排名
  • 云建設(shè)平臺(tái)seo快速排名外包
  • 純div css做網(wǎng)站簡潔版商丘seo排名
  • 網(wǎng)站建設(shè)nuoweb什么是搜索引擎推廣
  • wordpress獲取文章id方法手機(jī)網(wǎng)站怎么優(yōu)化關(guān)鍵詞
  • 訪問網(wǎng)站人多的時(shí)候很慢是服務(wù)器問題還是帶寬pageadmin建站系統(tǒng)
  • 襄陽做網(wǎng)站公司電話簡單的html網(wǎng)頁制作
  • 新鄉(xiāng)谷雨網(wǎng)絡(luò)公司做的網(wǎng)站怎么樣seo外鏈要做些什么
  • Wordpress做APP后端徐州關(guān)鍵詞優(yōu)化排名
  • 武漢通官網(wǎng)網(wǎng)站建設(shè)如何用手機(jī)免費(fèi)創(chuàng)建網(wǎng)站
  • oa系統(tǒng)品牌seo效果檢測步驟