mirror of
https://github.com/simstudioai/sim.git
synced 2026-09-24 15:45:35 +08:00
Added code to trim gemini response of any markdown/whitespace
This commit is contained in:
@@ -182,8 +182,15 @@ export const googleProvider: ProviderConfig = {
|
||||
},
|
||||
|
||||
transformResponse: (response: any) => {
|
||||
let content = response.candidates?.[0]?.content?.parts?.[0]?.text || ''
|
||||
|
||||
if (content) {
|
||||
content = content.replace(/```json\n?|\n?```/g, '')
|
||||
content = content.trim()
|
||||
}
|
||||
|
||||
return {
|
||||
content: response.candidates?.[0]?.content?.parts?.[0]?.text || '',
|
||||
content,
|
||||
tokens: response.usageMetadata && {
|
||||
prompt: response.usageMetadata.promptTokenCount,
|
||||
completion: response.usageMetadata.candidatesTokenCount,
|
||||
|
||||
Reference in New Issue
Block a user