mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-05-17 12:56:55 +08:00
22 lines
500 B
TypeScript
22 lines
500 B
TypeScript
import { type BodyPayload, BodyPayloadValueType } from './types'
|
|
|
|
export const transformToBodyPayload = (old: string, hasKey: boolean): BodyPayload => {
|
|
if (!hasKey) {
|
|
return [
|
|
{
|
|
type: BodyPayloadValueType.text,
|
|
value: old,
|
|
},
|
|
]
|
|
}
|
|
const bodyPayload = old.split('\n').map((item) => {
|
|
const [key, value] = item.split(':')
|
|
return {
|
|
key: key || '',
|
|
type: BodyPayloadValueType.text,
|
|
value: value || '',
|
|
}
|
|
})
|
|
return bodyPayload
|
|
}
|