Spaces:
Runtime error
Runtime error
fix: added proper types when interacting with toOpenAi
Browse filesFiles changed (3)
278 unmodified lines27928028128228328428528628728828986 unmodified lines376377378379380381278 unmodified linestry {setLoading(true);const client = createClient(formObject.openAIAPIKey as string);const answer = await toOpenAI({...formObject,client,});86 unmodified linesRun</Typography></Button></Stack></Stack>278 unmodified lines27928028128228328428528628728828929029129229329429529629729829930030130230386 unmodified lines390391392393394395396278 unmodified linestry {setLoading(true);const {command,prompt,temperature,template,model,maxTokens,} = formObject;const client = createClient(formObject.openAIAPIKey as string);const answer = await toOpenAI({command: command as string,prompt: prompt as string,temperature: temperature as string,template: template as string,model: model as string,maxTokens: maxTokens as string,client,});86 unmodified linesRun</Typography></Button><Box sx={{ flex: 1 }} /></Stack></Stack>
123456782 unmodified lines11121314151617import { ChatCompletionRequestMessage } from "openai";import { nanoid } from "nanoid";import { extractCode, miniPrompt } from "@/utils/prompt";import { systemMessage } from "@/constants";export async function toOpenAI({command = "CREATE_GAME",prompt = "extend the code",2 unmodified linesmodel = "gpt-3.5-turbo",maxTokens = "2048",client = null,}) {if (client === null) {throw new Error("OpenAI client is not defined");}1234567891011121314151617182 unmodified lines21222324252627import { ChatCompletionRequestMessage, OpenAIApi } from "openai";import { nanoid } from "nanoid";import { extractCode, miniPrompt } from "@/utils/prompt";import { systemMessage } from "@/constants";interface ToOpenAIProps {command: string;prompt: string;temperature: string;template: string;model: string;maxTokens: string;client: OpenAIApi | null;}export async function toOpenAI({command = "CREATE_GAME",prompt = "extend the code",2 unmodified linesmodel = "gpt-3.5-turbo",maxTokens = "2048",client = null,}: ToOpenAIProps) {if (client === null) {throw new Error("OpenAI client is not defined");}
12345import { Configuration, OpenAIApi } from "openai";export const createClient = (apiKey: string) => {return new OpenAIApi(new Configuration({ apiKey }));};12345import { Configuration, OpenAIApi } from "openai";export const createClient = (apiKey: string): OpenAIApi => {return new OpenAIApi(new Configuration({ apiKey }));};
src/components/GameCreator.tsx+16-1
src/services/api/index.ts+12-2
src/services/api/openai.ts+1-1