File tree 2 files changed +4
-3
lines changed
app/(backend)/webapi/chat/vertexai
2 files changed +4
-3
lines changed Original file line number Diff line number Diff line change 1
1
import { checkAuth } from '@/app/(backend)/middleware/auth' ;
2
2
import { AgentRuntime , ModelProvider } from '@/libs/agent-runtime' ;
3
3
import { LobeVertexAI } from '@/libs/agent-runtime/vertexai' ;
4
+ import { safeParseJSON } from '@/utils/safeParseJSON' ;
4
5
5
6
import { POST as UniverseRoute } from '../[provider]/route' ;
6
7
@@ -16,10 +17,10 @@ import { POST as UniverseRoute } from '../[provider]/route';
16
17
export const POST = checkAuth ( async ( req : Request , { jwtPayload } ) =>
17
18
UniverseRoute ( req , {
18
19
createRuntime : ( ) => {
19
- const googleAuthOptions = jwtPayload . apiKey ?? process . env . VERTEXAI_CREDENTIALS ?? undefined ;
20
+ const googleAuthStr = jwtPayload . apiKey ?? process . env . VERTEXAI_CREDENTIALS ?? undefined ;
20
21
21
22
const instance = LobeVertexAI . initFromVertexAI ( {
22
- googleAuthOptions : googleAuthOptions as any ,
23
+ googleAuthOptions : safeParseJSON ( googleAuthStr ) ,
23
24
location : process . env . VERTEXAI_LOCATION ,
24
25
project : process . env . VERTEXAI_PROJECT ,
25
26
} ) ;
Original file line number Diff line number Diff line change 1
- export const safeParseJSON = < T = Record < string , any > > ( text : string ) => {
1
+ export const safeParseJSON = < T = Record < string , any > > ( text ? : string ) => {
2
2
if ( typeof text !== 'string' ) return undefined ;
3
3
4
4
let json : T ;
You can’t perform that action at this time.
0 commit comments