UNPKG

rawi

Version:

Rawi (راوي) is the developer-friendly AI CLI that brings the power of 12 major AI providers directly to your terminal. With seamless shell integration, persistent conversations, and 200+ specialized prompt templates, Rawi transforms your command line into

1 lines 4.26 kB
{"version":3,"sources":["/home/mkabumattar/withrawi/rawi/dist/chunk-5CRCR6CM.cjs","../src/core/providers/google.provider.ts"],"names":["googleModelIds","googleModels","name","googleProvider","streamWithGoogle","credentials","prompt","settings","apiKey","baseURL","createGoogleGenerativeAI","result","streamText","error"],"mappings":"AAAA;ACCA,wCAAuC,wBACd,IAYnBA,CAAAA,CAAiB,CACrB,kBAAA,CACA,yBAAA,CACA,sBAAA,CACA,sBAAA,CACA,qBAAA,CACA,4BAAA,CACA,yBAAA,CACA,gBAAA,CACA,uBAAA,CACA,oBAAA,CACA,oBAAA,CACA,kBAAA,CACA,sBAAA,CACA,2BAAA,CACA,uBAAA,CACA,0BAAA,CACA,qCAAA,CACA,sBAAA,CACA,0BAAA,CACA,8BAAA,CACA,gCAAA,CACA,iBAAA,CACA,gBAAA,CACA,8BACF,CAAA,CAEaC,CAAAA,aAA4BD,CAAAA,CAAe,GAAA,CAAKE,CAAAA,EAAAA,CAAU,CACrE,IAAA,CAAAA,CAAAA,CACA,WAAA,CAAaA,CACf,CAAA,CAAE,CAAA,CAEWC,CAAAA,aAAiB,CAC5B,IAAA,CAAM,QAAA,CACN,WAAA,CAAa,2BAAA,CACb,MAAA,CAAQF,CACV,CAAA,CAEaG,CAAAA,aAAmB,KAAA,CAC9BC,CAAAA,CACAC,CAAAA,CAAAA,EAC+B,CAC/B,GAAI,CACF,IAAMC,CAAAA,CAAWF,CAAAA,CAAY,gBAAA,CAEvBG,CAAAA,iBAASD,CAAAA,2BAAU,QAAA,EAAUF,CAAAA,CAAY,MAAA,CAE/C,EAAA,CAAI,CAACG,CAAAA,CACH,MAAM,IAAI,KAAA,CAAM,gCAAgC,CAAA,CAGlD,IAAMC,CAAAA,iBACJF,CAAAA,6BAAU,SAAA,EAAW,kDAAA,CAEjBJ,CAAAA,CAA6CO,8CAAAA,CAE/C,MAAA,CAAQF,CAAAA,CACR,OAAA,CAASC,CACX,CACF,CAAA,CAEME,CAAAA,CAASC,4BAAAA,CACb,KAAA,CAAOT,CAAAA,CAAeE,CAAAA,CAAY,KAAK,CAAA,CACvC,MAAA,CAAAC,CAAAA,CACA,WAAA,CAAaD,CAAAA,CAAY,WAAA,EAAe,EAAA,CACxC,SAAA,CAAWA,CAAAA,CAAY,SAAA,EAAa,IACtC,CAAC,CAAA,CAED,MAAO,CACL,UAAA,CAAYM,CAAAA,CAAO,UAAA,CACnB,YAAA,CAAcA,CAAAA,CAAO,IACvB,CACF,CAAA,KAAA,CAASE,CAAAA,CAAO,CACd,MAAM,IAAI,KAAA,CACR,CAAA,uCAAA,EACEA,EAAAA,WAAiB,KAAA,CAAQA,CAAAA,CAAM,OAAA,CAAU,MAAA,CAAOA,CAAK,CACvD,CAAA,CAAA;ADxFouC","file":"/home/mkabumattar/withrawi/rawi/dist/chunk-5CRCR6CM.cjs","sourcesContent":[null,"import type {GoogleGenerativeAIProvider, google} from '@ai-sdk/google';\nimport {createGoogleGenerativeAI} from '@ai-sdk/google';\nimport {streamText} from 'ai';\nimport type {\n GoogleSettings,\n LooseToStrict,\n ModelInfo,\n RawiCredentials,\n StreamingResponse,\n} from '../shared/index.js';\n\ntype LooseGoogleModelId = Parameters<typeof google>[0];\nexport type GoogleModelId = LooseToStrict<LooseGoogleModelId>;\n\nconst googleModelIds = [\n 'gemini-1.5-flash',\n 'gemini-1.5-flash-latest',\n 'gemini-1.5-flash-001',\n 'gemini-1.5-flash-002',\n 'gemini-1.5-flash-8b',\n 'gemini-1.5-flash-8b-latest',\n 'gemini-1.5-flash-8b-001',\n 'gemini-1.5-pro',\n 'gemini-1.5-pro-latest',\n 'gemini-1.5-pro-001',\n 'gemini-1.5-pro-002',\n 'gemini-2.0-flash',\n 'gemini-2.0-flash-001',\n 'gemini-2.0-flash-live-001',\n 'gemini-2.0-flash-lite',\n 'gemini-2.0-pro-exp-02-05',\n 'gemini-2.0-flash-thinking-exp-01-21',\n 'gemini-2.0-flash-exp',\n 'gemini-2.5-pro-exp-03-25',\n 'gemini-2.5-pro-preview-05-06',\n 'gemini-2.5-flash-preview-04-17',\n 'gemini-exp-1206',\n 'gemma-3-27b-it',\n 'learnlm-1.5-pro-experimental',\n] as const;\n\nexport const googleModels: ModelInfo[] = googleModelIds.map((name) => ({\n name,\n displayName: name,\n}));\n\nexport const googleProvider = {\n name: 'google' as const,\n displayName: '🔴 Google (Gemini)',\n models: googleModels,\n};\n\nexport const streamWithGoogle = async (\n credentials: RawiCredentials,\n prompt: string,\n): Promise<StreamingResponse> => {\n try {\n const settings = credentials.providerSettings as GoogleSettings | undefined;\n\n const apiKey = settings?.apiKey || credentials.apiKey;\n\n if (!apiKey) {\n throw new Error('API key is required for Google');\n }\n\n const baseURL =\n settings?.baseURL || 'https://generativelanguage.googleapis.com/v1beta';\n\n const googleProvider: GoogleGenerativeAIProvider = createGoogleGenerativeAI(\n {\n apiKey: apiKey,\n baseURL: baseURL,\n },\n );\n\n const result = streamText({\n model: googleProvider(credentials.model),\n prompt,\n temperature: credentials.temperature || 0.7,\n maxTokens: credentials.maxTokens || 2048,\n });\n\n return {\n textStream: result.textStream,\n fullResponse: result.text,\n };\n } catch (error) {\n throw new Error(\n `Error calling Google AI streaming API: ${\n error instanceof Error ? error.message : String(error)\n }`,\n );\n }\n};\n"]}