feat: Improved layout and added file content filtering.
- Added a margin bottom to the Upload component in the MessageAttachments page for improved layout. - Added support for not displaying file contents for specific providers.
This commit is contained in:
parent
0ee72a9ef8
commit
353e497642
@ -18,7 +18,7 @@ const MessageAttachments: FC<Props> = ({ message }) => {
|
||||
}
|
||||
|
||||
return (
|
||||
<Container style={{ marginTop: 2 }}>
|
||||
<Container style={{ marginTop: 2, marginBottom: 8 }}>
|
||||
<Upload
|
||||
listType="picture"
|
||||
disabled
|
||||
|
||||
@ -34,6 +34,11 @@ export default class OpenAIProvider extends BaseProvider {
|
||||
return true
|
||||
}
|
||||
|
||||
private get isNotSupportFiles() {
|
||||
const providers = ['deepseek', 'baichuan', 'minimax', 'yi', 'doubao']
|
||||
return providers.includes(this.provider.id)
|
||||
}
|
||||
|
||||
private async getMessageParam(
|
||||
message: Message,
|
||||
model: Model
|
||||
@ -47,6 +52,35 @@ export default class OpenAIProvider extends BaseProvider {
|
||||
}
|
||||
}
|
||||
|
||||
if (this.isNotSupportFiles) {
|
||||
if (message.files) {
|
||||
const textFiles = message.files.filter((file) => file.type === FileTypes.TEXT)
|
||||
|
||||
if (textFiles.length > 0) {
|
||||
let text = ''
|
||||
const divider = '\n\n---\n\n'
|
||||
|
||||
for (const file of textFiles) {
|
||||
const fileContent = (await window.api.file.read(file.id + file.ext)).trim()
|
||||
const fileNameRow = 'file: ' + file.origin_name + '\n\n'
|
||||
text = text + fileNameRow + fileContent + divider
|
||||
}
|
||||
|
||||
message.content = message.content + divider + text
|
||||
|
||||
return {
|
||||
role: message.role,
|
||||
content: message.content
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
role: message.role,
|
||||
content: message.content
|
||||
}
|
||||
}
|
||||
|
||||
const parts: ChatCompletionContentPart[] = [
|
||||
{
|
||||
type: 'text',
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user