Skip to content

Commit

Permalink
Merge pull request cloudflare#146 from rcccf/rchen/fix-ai
Browse files Browse the repository at this point in the history
Fix OpenAPI endpoint usage
  • Loading branch information
third774 authored Dec 20, 2024
2 parents 778f5f6 + c80dc5e commit c143f77
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
3 changes: 3 additions & 0 deletions app/durableObjects/ChatRoom.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {
} from '~/utils/openai.server'

const alarmInterval = 15_000
const defaultOpenAIModelID = 'gpt-4o-realtime-preview-2024-10-01'

/**
* The ChatRoom Durable Object Class
Expand Down Expand Up @@ -415,6 +416,8 @@ export class ChatRoom extends Server<Env> {
params.set('instructions', instructions)
}

params.set('model', this.env.OPENAI_MODEL_ID || defaultOpenAIModelID)

// The Calls's offer is sent to OpenAI
const openaiAnswer = await requestOpenAIService(
openAiTracksResponse.sessionDescription ||
Expand Down
1 change: 1 addition & 0 deletions app/types/Env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ export type Env = {
DB?: D1Database
OPENAI_API_TOKEN?: string
OPENAI_MODEL_ENDPOINT?: string
OPENAI_MODEL_ID?: string
}

0 comments on commit c143f77

Please sign in to comment.