A provider for Vercel's AI SDK that enables seamless integration with Orama's search and chat capabilities.
- 🔍 Full-text, vector, and hybrid search
- 💬 Streaming chat/QA functionality
- 🚀 Framework agnostic
- 🔄 Real-time streaming responses
- 🖼️ Rich media search results
npm install ai-sdk-orama-provider
or
pnpm install ai-sdk-orama-provider
or
yarn add ai-sdk-orama-provider
import { generateText } from 'ai';
import { oramaProvider } from 'ai-sdk-orama-provider';
// Create an Orama provider instance
const orama = oramaProvider({
endpoint: process.env.ORAMA_API_URL!,
apiKey: process.env.ORAMA_API_KEY!,
userContext: "The user is looking for documentation help",
inferenceType: "documentation"
});
// Use it in your component
export default function Chat() {
const [messages, setMessages] = useState([]);
const [input, setInput] = useState('');
const handleSubmit = async (e) => {
e.preventDefault();
const { text } = await generateText({
model: orama.ask(),
prompt: input
});
setMessages(prev => [...prev, { role: 'assistant', content: text }]);
};
return (
// Your chat UI
);
}
interface OramaProviderConfig {
endpoint: string; // Your Orama endpoint URL
apiKey: string; // Your Orama API key
userContext?: string | Record<string, any>; // Context for the chat session
inferenceType?: "documentation" | "chat"; // Type of inference
searchMode?: "fulltext" | "vector" | "hybrid"; // Search mode
searchOptions?: OramaSearchOptions; // Default search options
}
interface OramaSearchOptions {
mode?: "fulltext" | "vector" | "hybrid";
where?: Record<string, any>;
sortBy?: Array<{ property: string; order?: "asc" | "desc" }>;
facets?: Record<string, any>;
limit?: number;
boost?: Record<string, number>;
order?: "asc" | "desc";
}
const orama = oramaProvider({
endpoint: process.env.ORAMA_API_URL!,
apiKey: process.env.ORAMA_API_KEY!,
inferenceType: "documentation"
});
const { text } = await generateText({
model: orama.ask(),
prompt: "What is Orama?"
});
const orama = oramaProvider({
endpoint: process.env.ORAMA_API_URL!,
apiKey: process.env.ORAMA_API_KEY!,
searchMode: "hybrid",
searchOptions: {
sortBy: [{ property: "rating", order: "desc" }],
where: {
category: "documentation"
}
}
});
const { text } = await generateText({
model: orama.ask(),
prompt: "Search query"
});
Contributions are welcome! Please feel free to submit a Pull Request.
Apache 2.0. Read the full license here