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

网站服务器建设的三种方法邯郸网站建设费用

网站服务器建设的三种方法,邯郸网站建设费用,仿第四城地方门户网站模板,平面设计培训班教程最近工作上遇到了要接入gpt相关内容的需求#xff0c;简单实现了一个安卓端接入讯飞星火的UnitySDK。 或者也可以接入WebSocket接口的。本文只讲安卓实现 我使用的Unity版本为2021.3.27f1c2 Android版本为4.2.2 1.下载SDK 登陆讯飞开放平台下载如图所示SDK 2.新建安卓工程…最近工作上遇到了要接入gpt相关内容的需求简单实现了一个安卓端接入讯飞星火的UnitySDK。 或者也可以接入WebSocket接口的。本文只讲安卓实现 我使用的Unity版本为2021.3.27f1c2 Android版本为4.2.2 1.下载SDK 登陆讯飞开放平台下载如图所示SDK 2.新建安卓工程 新建安卓工程在工程下创建libs文件夹 下载的SDK解压后的aar文件至安卓工程的libs文件夹下 打开工程的build.gradle 复制以下代码 上面红框部分是引用aar下面是打jar包的逻辑 3.根据原来的demo工程修改代码 package com.rayneo.sparklib; import android.app.Activity; import com.iflytek.sparkchain.core.LLM; import com.iflytek.sparkchain.core.LLMCallbacks; import com.iflytek.sparkchain.core.LLMConfig; import com.iflytek.sparkchain.core.SparkChain; import com.iflytek.sparkchain.core.SparkChainConfig;public class SparkTool {private static final String TAG SparkLLM;private Activity _unityActivity;private String domain general;private String url wss://spark-api.xf-yun.com/v1.1/chat;public int initSDK(String appid,String apiKey,String apiSecret,int logLevel,String domain,String url) {// 初始化SDKAppid等信息在清单中配置SparkChainConfig sparkChainConfig SparkChainConfig.builder();sparkChainConfig.appID(appid).apiKey(apiKey).apiSecret(apiSecret)//应用申请的appid三元组.logLevel(logLevel);int ret SparkChain.getInst().init(getActivity(),sparkChainConfig);this.domain domain;this.url url;return ret;}public void unInitSDK() {SparkChain.getInst().unInit();}Activity getActivity(){if(null _unityActivity) {try {Class? classtype Class.forName(com.unity3d.player.UnityPlayer);Activity activity (Activity) classtype.getDeclaredField(currentActivity).get(classtype);_unityActivity activity;} catch (ClassNotFoundException e) {} catch (IllegalAccessException e) {} catch (NoSuchFieldException e) {}}return _unityActivity;}public int startChat(ISparkLLMProxy unityProxy,String msg) {LLMConfig llmConfig LLMConfig.builder();llmConfig.domain(domain).url(url);LLM llm new LLM(llmConfig);LLMCallbacks llmCallbacks new SparkLLMCallbacks(unityProxy);llm.registerLLMCallbacks(llmCallbacks);String myContext myContext;int ret llm.arun(msg,myContext);return ret;}} 这几个接口分别是初始化释放获取Unity的Activity开始gpt。 package com.rayneo.sparklib;public interface ISparkLLMProxy {void onLLMResult(int status, String Content);void onLLMEvent(int eventID, String eventMsg);void onLLMError(int errorCode, String var2);} package com.rayneo.sparklib;import android.util.Log;import com.iflytek.sparkchain.core.LLMCallbacks; import com.iflytek.sparkchain.core.LLMError; import com.iflytek.sparkchain.core.LLMEvent; import com.iflytek.sparkchain.core.LLMResult;public class SparkLLMCallbacks implements LLMCallbacks {private static final String TAG SparkLLMCallbacks;private ISparkLLMProxy unityProxy;public SparkLLMCallbacks(ISparkLLMProxy unityProxy) {this.unityProxy unityProxy;}Overridepublic void onLLMResult(LLMResult llmResult, Object usrContext) {Log.d(TAG, onLLMResult\n);String content llmResult.getContent();Log.e(TAG, onLLMResult: content);int status llmResult.getStatus();if (unityProxy ! null) {unityProxy.onLLMResult(status, content);}}Overridepublic void onLLMEvent(LLMEvent event, Object usrContext) {Log.d(TAG, onLLMEvent\n);Log.w(TAG, onLLMEvent: event.getEventID() event.getEventMsg());if (unityProxy ! null) {unityProxy.onLLMEvent(event.getEventID(), event.getEventMsg());}}Overridepublic void onLLMError(LLMError error, Object usrContext) {Log.d(TAG, onLLMError\n);Log.e(TAG, errCode: error.getErrCode() errDesc: error.getErrMsg());if (unityProxy ! null) {unityProxy.onLLMError(error.getErrCode(), error.getErrMsg());}} } 实现回调接口让Unity可以注册 点击此处导出jar包 4.导入Unity工程 拷贝jar包和aar包至Unity工程此目录下 Androidmanifest增加 权限 using System; using UnityEngine; using UnityEngine.UI; //using FfalconXR;public class IFlyLLMHandler : MonoBehaviour {public InputField input;public Button button;public Text text;private AndroidJavaObject sparkToolInstance;private void Start(){Loom.Initialize();sparkToolInstance new AndroidJavaObject(com.rayneo.sparklib.SparkTool);InitializeSDK();button.onClick.AddListener(() {text.text ;StartChat(input.text);});}public void InitializeSDK(){if (sparkToolInstance ! null){//输入开放平台的apikey等数据appid,apiKey,apiSecret,logLevel,domain,urlint ret sparkToolInstance.Callint(initSDK, 9e803172, e4045501df3916cad0c4137d43db8b3b, ZWFiZGYwMjllNTkyYTFmNjE1YTNiMWRk, 0, general, );Debug.Log(initializeSDK error code is ret);}else{Debug.LogError(SparkTool instance is null. Make sure the Android plugin is properly imported.);}}public void StartChat(string msg){if (sparkToolInstance ! null){int ret sparkToolInstance.Callint(startChat, new SparkLLMProxy(onLLMResult, onLLMEvent, onLLMError), msg);Debug.Log(startChat error code is ret);}else{Debug.LogError(SparkTool instance is null. Make sure the Android plugin is properly imported.);}}private void onLLMError(int errorCode, string error){Debug.Log(onLLMError errorCode errorCode error message error);}private void onLLMEvent(int eventID, string eventMsg){Debug.Log(onLLMError eventID eventID eventMsg eventMsg);}private void onLLMResult(int status, string content){Loom.QueueOnMainThread((p) {text.text content;}, null);Debug.Log(onLLMResult status status content content);}public void UninitializeSDK(){if (sparkToolInstance ! null){sparkToolInstance.Call(unInitSDK);}else{Debug.LogError(SparkTool instance is null. Make sure the Android plugin is properly imported.);}} } public class SparkLLMProxy : AndroidJavaProxy {private Actionint, string onLLMResultCallback;private Actionint, string onLLMEventCallback;private Actionint, string onLLMErrorCallback;public SparkLLMProxy(Actionint, string onLLMResult, Actionint, string onLLMEvent, Actionint, string onLLMError) : base(com.rayneo.sparklib.ISparkLLMProxy){onLLMResultCallback onLLMResult;onLLMEventCallback onLLMEvent;onLLMErrorCallback onLLMError;}public void onLLMResult(int status, string content){if (onLLMResultCallback ! null){onLLMResultCallback(status, content);}}public void onLLMEvent(int eventID, string eventMsg){if (onLLMEventCallback ! null){onLLMEventCallback(eventID, eventMsg);}}public void onLLMError(int errorCode, string error){if (onLLMErrorCallback ! null){onLLMErrorCallback(errorCode, error);}}}接入安卓接口 打包运行至手机上 左边输入栏输入文本点击按钮发送。收到返回即代表成功。 工程仓库地址为:https://github.com/oneSitDown/spark-unity
http://www.pierceye.com/news/807781/

相关文章:

  • 可在哪些网站做链接郑州展厅设计公司
  • 怎么可以黑网站域名做网页的心得体会
  • 设计素材免费下载网站做广告牌子
  • 名师工作室网站建设 意义常州网站建设专业的公司
  • 中国建设银行官网站预定红念币天元建设集团有限公司地址
  • wix做网站教程网站建设 销售提成
  • 长安网站建设费用开天猫旗舰店网站建设
  • 网页游戏网站哪个最好专业建站公司建站系统该规划哪些内容
  • 青岛网站建设公司大全在那些网站上做企业宣传好
  • 天河定制型网站建设中国科技成就的例子
  • 网站报备查询android安卓软件下载
  • 百度站长平台网站验证wordpress关闭略缩图
  • 网站怎么做qq微信登陆界面设计的有趣的网站推荐
  • 设计logo网站赚钱注册域名怎么做网站
  • 网站备案 教程网站设计大全推荐
  • 临沂建设局网站官网文明网站建设工作进度表
  • 网站编辑seo旅游网站建设代码
  • 为什么自己做的网站打开是乱码wordpress live-2d
  • 素材下载网站电商自建站
  • 浙江省的网站建设公司有哪些代理注册公司一般多少钱
  • 如何在建设银行网站预约纪念币东莞网站建设服务有什
  • 有哪些可以做h5的网站代理网址上境外网
  • 做网站所需要的代码6红杏直播
  • 南通制作网站wordpress移动版设置
  • 哪个网站有免费ppt下载建筑类网站的推荐理由
  • 视觉差的网站公司外包
  • 基础做网站内蒙住房和城乡建设部网站
  • 发帖效果好的网站展馆展示设计公司排名
  • 童装网站建设文案什么网站做的号
  • 能打开的a站莆田网站建设建站系统