UNPKG

rawi

Version:

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

4 lines 2.94 kB
/* Rawi (راوي) is the developer-friendly AI CLI that brings the power of 11 major AI providers directly to your terminal. With seamless shell integration, persistent conversations, and 200+ specialized prompt templates, Rawi transforms your command line into an intelligent development workspace. */ import{a as u}from"./chunk-DZIEWBQ3.js";import{createAzure as m}from"@ai-sdk/azure";import{generateText as d,streamText as p}from"ai";var y=[],z={name:"azure",displayName:"\u{1F537} Azure OpenAI",models:y},w=async(e,n)=>{try{if(!e.apiKey)throw new Error("API key is required for Azure OpenAI");if(!e.providerSettings||!("resourceName"in e.providerSettings))throw new Error("Azure resource name is required");let r=e.providerSettings.resourceName,o="apiVersion"in e.providerSettings?e.providerSettings.apiVersion:"2024-10-01-preview",t=m({apiKey:e.apiKey,resourceName:r,apiVersion:o}),s=p({model:t(e.model),prompt:n,temperature:e.temperature||.7,maxOutputTokens:e.maxTokens||2048});return{textStream:s.textStream,fullResponse:s.text}}catch(r){throw r instanceof Error&&(r.message.includes("not found")||r.message.includes("does not exist")||r.message.includes("deployment"))?new Error(`Error calling Azure OpenAI streaming API: Deployment "${e.model}" not found. Make sure you've correctly entered your deployment name (not the model name like "gpt-4"). Original error: ${r.message}`):new Error(`Error calling Azure OpenAI streaming API: ${r instanceof Error?r.message:String(r)}`)}},f={name:"azure",displayName:"\u{1F537} Azure OpenAI",async streamChat(e,n,r={}){let o=e.providerSettings||{},t=o.apiKey||e.apiKey;if(!t)throw new Error("API key is required for Azure OpenAI");if(!o.resourceName)throw new Error("Azure resource name is required");let s=o.resourceName,a=o.apiVersion||"2024-10-01-preview",i=m({apiKey:t,resourceName:s,apiVersion:a});return p({model:i(e.model),messages:n,temperature:e.temperature||r.temperature||.7,maxOutputTokens:e.maxTokens||r.maxTokens||2048}).textStream}},x=async e=>{let n=Date.now();try{if(!e.credentials.apiKey)throw new Error("API key is required for Azure OpenAI");let r=e.credentials.providerSettings;if(!r?.resourceName)throw new Error("Azure resource name is required");let o=r.resourceName,t=r.apiVersion||"2024-10-01-preview",s=m({apiKey:e.credentials.apiKey,resourceName:o,apiVersion:t}),a=await d({model:s(e.credentials.model),system:e.systemPrompt,prompt:e.userPrompt}),i=Date.now()-n;return{command:u(a.text),generationTime:i}}catch(r){throw new Error(`Azure exec generation failed: ${r}`)}};export{y as a,z as b,w as c,f as d,x as e}; /* Rawi (راوي) is the developer-friendly AI CLI that brings the power of 11 major AI providers directly to your terminal. With seamless shell integration, persistent conversations, and 200+ specialized prompt templates, Rawi transforms your command line into an intelligent development workspace. */ //# sourceMappingURL=chunk-UVCGEIMD.js.map