new game stuff, analytics

This commit is contained in:
sky
2026-02-07 14:45:30 -05:00
parent 49e542b3e9
commit 71f377ac18
20 changed files with 144 additions and 562 deletions

12
ai.js
View File

@ -1,21 +1,23 @@
import { createOpenAICompatible } from '@ai-sdk/openai-compatible';
import { generateText } from 'ai';
import { generateText, streamText } from 'ai';
const model = createOpenAICompatible({
name: 'model',
apiKey: process.env.OPENAI_API_KEY,
baseURL: process.env.OPENAI_BASE_URL,
includeUsage: true, // Include usage information in streaming responses
includeUsage: true,
});
async function callAI(chatHistory) {
console.log("call ai called")
let { text } = await generateText({
// TODO: add proper checking for chat
// realistically, just trust whats given, just make sure that the only roles are user and assistant
let { text } = streamText({
model: model(process.env.OPENAI_MODEL),
system: "You are Zen, a helpful AI assistant built by Selenite. Your response should be accurate without hallucination." +
"Over the course of conversation, adapt to the user's tone and preferences. Try to match the user's vibe, tone, and generally how they are speaking. You want the conversation to feel natural. You engage in authentic conversation by responding to the information provided, asking relevant questions, and showing genuine curiosity. If natural, use information you know about the user to personalize your responses and ask a follow up question.",
messages: chatHistory
});
console.log(text);
return text.toTextStreamResponse();
}
export { callAI };