Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

记忆没有正常产生 #13

Open
busiyg opened this issue May 11, 2024 · 3 comments
Open

记忆没有正常产生 #13

busiyg opened this issue May 11, 2024 · 3 comments

Comments

@busiyg
Copy link

busiyg commented May 11, 2024

以下是代码
public class RobotController : MonoBehaviour
{
public TMP_InputField inputField;
public TMP_Text TMP_Text;
public string prompt = @"How many planets are there?";
public AudioSource speechAudioSource;

private ChatHistory history;
private ChatMemory memory;
private readonly string template = "{history}\n{prompt}";
public ILargeLanguageModel ollamaChat;
// Start is called before the first frame update
void Start()
{
    ollamaChat = new OllamaChat() { Model = "BobBot" };
    history = new ChatHistory();
    memory = new ChatBufferMemory() { ChatHistory = history};
    inputField.onValueChanged.AddListener((str) => {
        prompt = str;
    });
}

public void OnClick() {
    RunChainlocal();
}

public async UniTask RunChainlocal()
{
    var chain = Chain.Set(prompt, "prompt")
        | Chain.LoadMemory(memory,"history")
        | Chain.Template(template)
        | Chain.LLM(ollamaChat)
        | Chain.UpdateHistory(history,requestKey:"prompt");

    string result = await chain.Run<string>("text");
    TMP_Text.text = result.Replace("\n", string.Empty).Trim();
    //    //AzureTTSStream.Instance.StartTTS(result, speechAudioSource);
    //    //AzureTTSNormal.Instance.StartTTS(result, speechAudioSource);
}

}
以下是log
[chain/start] [1:chain:StackChain > 9:chain:UpdateHistoryChain] Entering chain run with input:
{"prompt":"我叫什么名字","history":"User: 你好,我叫姚大哥,请你记住我\r\nBot: 好的,很高兴认识你!请告诉我你的名字是什么?\r\nUser: 我的名字是姚大哥\r\nBot: 好的,小姚大哥。很高兴与你交谈!有事可以随时找我聊天哦。\r\n","text":"很抱歉,我不知道你的名字。如果你告诉我,你就能听到我的回答了!"}

[chain/end] [1:chain:StackChain > 9:chain:UpdateHistoryChain] [1.0067ms] Exiting chain run with output:
{"prompt":"我叫什么名字","history":"User: 你好,我叫姚大哥,请你记住我\r\nBot: 好的,很高兴认识你!请告诉我你的名字是什么?\r\nUser: 我的名字是姚大哥\r\nBot: 好的,小姚大哥。很高兴与你交谈!有事可以随时找我聊天哦。\r\n","text":"很抱歉,我不知道你的名字。如果你告诉我,你就能听到我的回答了!"}

[chain/end] [1:chain:StackChain] [786.7143ms] Exiting chain run with output:
{"prompt":"我叫什么名字","history":"User: 你好,我叫姚大哥,请你记住我\r\nBot: 好的,很高兴认识你!请告诉我你的名字是什么?\r\nUser: 我的名字是姚大哥\r\nBot: 好的,小姚大哥。很高兴与你交谈!有事可以随时找我聊天哦。\r\n","text":"很抱歉,我不知道你的名字。如果你告诉我,你就能听到我的回答了!"}

@AkiKurisu
Copy link
Owner

你的ollama版本是多少?看起来是上下文模型侧没有接受/处理到。

@busiyg
Copy link
Author

busiyg commented May 17, 2024

0.1.36,请问记忆功能目前只有这一种实现方式吗,token看不起不小

@AkiKurisu
Copy link
Owner

刚看出问题,你没有await task😂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants