Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 2 additions & 8 deletions packages/cali/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import 'dotenv/config'

import { createOpenAI } from '@ai-sdk/openai'
import { confirm, outro, select, spinner, text } from '@clack/prompts'
import { CoreMessage, generateText } from 'ai'
import * as tools from 'cali-tools'
Expand All @@ -12,7 +11,6 @@ import { retro } from 'gradient-string'
import { z } from 'zod'

import { reactNativePrompt } from './prompt.js'
import { getApiKey } from './utils.js'

const MessageSchema = z.union([
z.object({ type: z.literal('select'), content: z.string(), options: z.array(z.string()) }),
Expand Down Expand Up @@ -49,11 +47,7 @@ console.log(

console.log()

const AI_MODEL = process.env.AI_MODEL || 'gpt-4o'

const openai = createOpenAI({
apiKey: await getApiKey('OpenAI', 'OPENAI_API_K2EY'),
})
import model from './model.js'

async function startSession(): Promise<CoreMessage[]> {
const question = await text({
Expand Down Expand Up @@ -88,7 +82,7 @@ while (true) {
s.start(chalk.gray('Thinking...'))

const response = await generateText({
model: openai(AI_MODEL),
model,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on this!

This will probably clash with @grabbou PR: #57

Let's get the other one merged first and then this one

system: reactNativePrompt,
tools,
maxSteps: 10,
Expand Down
13 changes: 13 additions & 0 deletions packages/cali/src/model.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { createOpenAI } from '@ai-sdk/openai'

import { getApiKey } from './utils.js'

const AI_MODEL = process.env.AI_MODEL || 'gpt-4o'

const openai = createOpenAI({
apiKey: await getApiKey('OpenAI', 'OPENAI_API_K2EY'),
})

const model = openai(AI_MODEL)

export default model