File tree Expand file tree Collapse file tree 6 files changed +8
-28
lines changed
test-workspace/fixtures/inputEmptyString Expand file tree Collapse file tree 6 files changed +8
-28
lines changed Original file line number Diff line number Diff line change 1- import OpenAI from " openai" ;
1+ import { openai } from '../integrations/ openai/construct' ;
22
33interface OutputType {
44 methodName : string ;
@@ -10,15 +10,11 @@ interface InputType {
1010 * "Call OpenAI to get the function name of the stackwise, given its skeleton"
1111 */
1212export async function callOpenAI ( { prompt } : InputType ) : Promise < OutputType > {
13- const openai = new OpenAI ( {
14- apiKey : process . env . OPENAI_API_KEY ,
15- } ) ;
16-
1713 try {
1814 // Create a chat completion request
1915 const chatCompletion = await openai . chat . completions . create ( {
20- messages : [ { role : " user" , content : prompt } ] ,
21- model : " gpt-3.5-turbo" ,
16+ messages : [ { role : ' user' , content : prompt } ] ,
17+ model : ' gpt-3.5-turbo' ,
2218 } ) ;
2319
2420 // console.log('Response from OpenAI:', {
@@ -29,6 +25,6 @@ export async function callOpenAI({ prompt }: InputType): Promise<OutputType> {
2925 methodName : chatCompletion . choices [ 0 ] . message . content ,
3026 } ;
3127 } catch ( error ) {
32- console . error ( " Error during OpenAI API request:" , error ) ;
28+ console . error ( ' Error during OpenAI API request:' , error ) ;
3329 }
3430}
Original file line number Diff line number Diff line change 11import path from 'path' ;
2- import OpenAI from 'openai' ;
32import { Pinecone } from '@pinecone-database/pinecone' ;
43import { getEmbedding } from '../../../../stacks/openai/getEmbedding' ;
54import { readExplainFiles } from '../lib/utils' ;
65import { BoilerplateMetadata } from '../lib/types' ;
76import { combineSkeleton } from '../../createSkeleton' ;
7+ import { openai } from '../openai/construct' ;
88
99const pinecone = new Pinecone ( {
1010 apiKey : process . env . PINECONE_API_KEY as string ,
1111 environment : process . env . PINECONE_ENVIRONMENT as string ,
1212} ) ;
1313
14- const openai = new OpenAI ( {
15- apiKey : process . env . OPENAI_API_KEY ,
16- } ) ;
17-
1814interface OutputType {
1915 nearestBoilerplate : BoilerplateMetadata | BoilerplateMetadata [ ] | null ;
2016 integration : string ;
Original file line number Diff line number Diff line change 1- import OpenAI from 'openai' ;
2-
3- const openai = new OpenAI ( {
4- apiKey : process . env . OPENAI_API_KEY as string ,
5- } ) ;
1+ import { openai } from './construct' ;
62
73export async function openAIQueryBoilerplate ( prompt : string ) : Promise < string > {
84 // this function generates some text given a prompt and return the exact text
Original file line number Diff line number Diff line change @@ -7,10 +7,6 @@ const pinecone = new Pinecone({
77 environment : process . env . PINECONE_ENVIRONMENT as string ,
88} ) ;
99
10- const openai = new OpenAI ( {
11- apiKey : process . env . OPENAI_API_KEY as string ,
12- } ) ;
13-
1410export default async function constructPinecone (
1511 briefSkeleton : string ,
1612 functionAndOutputSkeleton : string ,
Original file line number Diff line number Diff line change 1- import OpenAI from 'openai' ;
21import { Pinecone } from '@pinecone-database/pinecone' ;
32import { BoilerplateMetadata } from '../../lib/types' ;
43import { boilerplateExpert , furtherEngineering , userAsk } from './prompts' ;
5-
6- const openai = new OpenAI ( {
7- apiKey : process . env . OPENAI_APY_KEY ,
8- } ) ;
4+ import { openai } from '../../openai/construct' ;
95
106const pinecone = new Pinecone ( {
117 apiKey : process . env . PINECONE_API_KEY as string ,
Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ stack('this is an example', {
55
66import generateBooleanResponse from '../../stacks/generateBooleanResponse' ;
77
8- await generateBooleanResponse ( "''" ) ;
8+ await generateBooleanResponse ( '' ) ;
99
1010
1111/**
You can’t perform that action at this time.
0 commit comments