https://github.com/lucasliet/phind-ai-provider
phind ai provider compatible with vercel ai sdk
https://github.com/lucasliet/phind-ai-provider
ai phind provider sdk vercel
Last synced: 8 months ago
JSON representation
phind ai provider compatible with vercel ai sdk
- Host: GitHub
- URL: https://github.com/lucasliet/phind-ai-provider
- Owner: lucasliet
- License: mit
- Created: 2025-04-30T19:30:29.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-08-29T20:16:42.000Z (10 months ago)
- Last Synced: 2025-10-01T09:23:15.110Z (8 months ago)
- Topics: ai, phind, provider, sdk, vercel
- Language: TypeScript
- Homepage: https://jsr.io/@lucasliet/phind-ai-provider
- Size: 106 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Phind AI Provider
Um provedor para o [Vercel AI SDK](https://sdk.vercel.ai/) que permite integrar facilmente o modelo de IA do Phind em suas aplicações JavaScript/TypeScript.
[](LICENSE)
[](https://jsr.io/@lucasliet)
[](https://github.com/lucasliet/phind-ai-provider/actions/workflows/tests.yml)
[](https://github.com/lucasliet/phind-ai-provider/actions/workflows/publish.yml)
[](https://jsr.io/@lucasliet/phind-ai-provider)
[](https://www.npmjs.com/package/phind-ai-provider)
## Características
- Compatível com o Vercel AI SDK (implementa `LanguageModelV1`)
- Suporta chat e geração de texto via Phind
- Suporte para ESM, CommonJS, UMD e Deno
- Streaming de respostas em tempo real
- Mínima dependência externa
## Instalação
### npm/Node.js
```bash
npm install phind-ai-provider
```
### Deno (via JSR)
```typescript
import { PhindAIService } from "jsr:@lucasliet/phind-ai-provider";
```
## Uso Básico
```typescript
import { PhindAIService } from "phind-ai-provider";
import { generateText } from "ai";
export async function POST(req: Request) {
const { messages } = await req.json();
const { text } = await generateText({
model: new PhindAIService(),
messages,
});
return text;
}
```
### Uso Direto (sem Vercel AI SDK)
```typescript
import { PhindAIService } from "phind-ai-provider";
// Uso síncrono
async function askQuestion() {
const phind = new PhindAIService();
const response = await phind.chat([
{ role: "user", content: "Qual é a capital da Suécia?" }
]);
console.log(response); // "A capital da Suécia é Estocolmo."
}
// Uso com streaming
async function askQuestionWithReader() {
const phind = new PhindAIService();
const reader = await phind.chatReader([
{ role: "user", content: "Explique brevemente o que é inteligência artificial." }
]);
// Ler resposta em partes
const decoder = new TextDecoder();
while (true) {
const { done, value } = await reader.read();
if (done) break;
console.log(decoder.decode(value));
}
}
// Uso com streaming
async function askQuestionWithStreaming() {
const phind = new PhindAIService();
const stream = await phind.chatStream([
{ role: "user", content: "Explique brevemente o que é inteligência artificial." }
]);
for await (const chunk of stream) {
console.log(chunk);
}
}
```
## Opções Avançadas
### Modelos
O Phind tem diferentes modelos disponíveis. Por padrão, usamos o "Phind-70B", pois é o único modelo gratuito atualmente:
```typescript
// Use o modelo Phind-70B (padrão)
const model = new PhindAIService();
// Ou especifique outro modelo
const model = new PhindAIService("Phind-405B"); // Atualmente Phind-70B é o único modelo gratuito
```
## Compatibilidade
Este pacote funciona em:
- Node.js (ESM e CommonJS)
- Navegadores (ESM e UMD)
- Deno (via JSR)
- Bun
- Ambientes edge (Vercel Edge Runtime, Cloudflare Workers, etc.)