Comments (4)
我也遇到同样问题了,通过跟踪发现:
调用myKernel.InvokePromptAsync(input)时,SK库用提示词去生成一个了ChatHistory,但这个ChatHistory中的Message集合中只有一个消息,类型被标记为AuthorRole.System。我不清楚SK官方这么做是什么意思,明明是用户输入的消息,为什么标记为System。难道是因为给大模型一个初始角色设定?
但不管怎么样,到了ERNIE-Bot中,执行到了
private List ChatHistoryToMessages(ChatHistory chatHistory, out string? system)
{
if (chatHistory.First().Role == AuthorRole.System)
{
system = chatHistory.First().Content;
}
else
{
system = null;
}
return chatHistory
.Where(_ => _.Role != AuthorRole.System)
.Select(m => new Message()
{
Role = AuthorRoleToMessageRole(m.Role),
Content = m.Content!
}).ToList();
}
最后导致消息集合中数量为0,触发了异常。
因此,我将ERNIEBotChatCompletion.cs文件中的GetChatMessageContentsAsync进行了修改,It Works!
public async Task<IReadOnlyList> GetChatMessageContentsAsync(ChatHistory chat, PromptExecutionSettings? executionSettings = null, Kernel? kernel = null, CancellationToken cancellationToken = default)
{
var messages = ChatHistoryToMessages(chat, out var system);
if(messages.Count == 0 && chat.Count > 0) //新添加逻辑。
{
var m = chat[0];
messages.Add(new Message
{
Role = AuthorRoleToMessageRole(m.Role),
Content = m.Content!
});
}
executionSettings ??= new PromptExecutionSettings();
var settings = ERNIEBotAIRequestSettings.FromRequestSettings(executionSettings);
ChatResponse result = await InternalCompletionsAsync(messages,
settings.Temperature,
settings.TopP,
settings.PenaltyScore,
system,
cancellationToken
);
return new List<ChatMessageContent>() { new ERNIEBotChatMessage(result) };
}
但是不知道这个是不是仓主的意思。不改乱提pull request。坐等仓主解答。
from semantic-kernel-ernie-bot.
有解决方案了没
from semantic-kernel-ernie-bot.
抱歉这么久才回复。
文心的接口提供所的提供system参数并不在history的队列中,而是单独参数。
诚如 @shangdf88 所提供的信息,SK在某次改版之后某次改版之后,单条的message role从User 改为了System,因而造成了一些异常情况。
这个问题近期会尽快修复一下。
from semantic-kernel-ernie-bot.
0.13.1 版本已经修复了该问题,请安装最新版本的nuget包重试一下。
from semantic-kernel-ernie-bot.
Related Issues (14)
- document required
- ERNIE-Bot SDK release as NuGet package.
- Connector release as Nuget package.
- 适配 Semantic Kernel Planner
- 支持 Llama-2 系列模型接口 HOT 1
- 适配 SemanticMemory
- ERNIE-Bot Enhancement
- support function call
- Add GitHub Actions
- Add CI, automatically build updates.
- Support for system parameters
- 接入Token计算接口
- 接入 StableDiffusion XL 接口
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from semantic-kernel-ernie-bot.