50 lines
1.3 KiB
C#
50 lines
1.3 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Diagnostics;
|
|
using UnityEngine;
|
|
|
|
public class LLM:MonoBehaviour
|
|
{
|
|
/// <summary>
|
|
/// api地址
|
|
/// </summary>
|
|
[SerializeField] protected string url;
|
|
/// <summary>
|
|
/// 提示词,与消息一起发送
|
|
/// </summary>
|
|
[Header("发送的提示词设定")]
|
|
[SerializeField] protected string m_Prompt = string.Empty;
|
|
/// <summary>
|
|
/// 语言
|
|
/// </summary
|
|
[Header("设置回复的语言")]
|
|
[SerializeField] protected string lan="中文";
|
|
/// <summary>
|
|
/// 上下文保留条数
|
|
/// </summary>
|
|
[Header("上下文保留条数")]
|
|
[SerializeField] protected int m_HistoryKeepCount = 15;
|
|
Coroutine m_Coroutine;
|
|
/// <summary>
|
|
/// 计算方法调用的时间
|
|
/// </summary>
|
|
[SerializeField] protected Stopwatch stopwatch=new Stopwatch();
|
|
/// <summary>
|
|
/// 发送消息
|
|
/// </summary>
|
|
public virtual void PostMsg(string _msg,Action<string> _callback) {
|
|
m_Coroutine = StartCoroutine(Request(_msg, _callback));
|
|
}
|
|
public virtual void StopMsg()
|
|
{
|
|
if(m_Coroutine != null)
|
|
{
|
|
StopCoroutine(m_Coroutine);
|
|
}
|
|
}
|
|
public virtual IEnumerator Request(string _postWord, System.Action<string> _callback)
|
|
{
|
|
yield return new WaitForEndOfFrame();
|
|
}
|
|
}
|