openv0 icon indicating copy to clipboard operation
openv0 copied to clipboard

After passing in the baseURL for the OPENAI object, Api will report an error when generating the component

Open OrzMiku opened this issue 1 year ago • 3 comments

I have modified the code in these areas of the program


const openai = new OpenAI({
  apiKey: process.env.OPENAI_API_KEY,
  baseURL: 'my api url',
});


/openv0/server/modules/multipass/passes/build-component-generation-context/rag_icons.js
  7,16: const openai = new OpenAI({
/openv0/server/modules/multipass/passes/design-component-iteration-from-description/index.js
  10,16: const openai = new OpenAI({
/openv0/server/modules/multipass/passes/design-component-iteration-from-json/index.js
  10,16: const openai = new OpenAI({
/openv0/server/modules/multipass/passes/design-component-new-from-description/index.js
  10,16: const openai = new OpenAI({
/server/modules/multipass/passes/design-component-new-from-json/index.js
  10,16: const openai = new OpenAI({
/server/modules/multipass/passes/generate-component-iteration/index.js
  6,16: const openai = new OpenAI({
/server/modules/multipass/passes/generate-component-new/index.js
  6,16: const openai = new OpenAI({
/server/modules/multipass/passes/validate-fix-generated-component/index.js
  9,16: const openai = new OpenAI({

I am confident that my interface address can be accessed and used normally. It supports the GPT4 model, and I have tested it using the OpenAI package in my own program. But in this program, I encountered an error while generating the component using my own Api address. The error is as follows:

gpt-4 model

Server is running on http://localhost:3000
Connected to the database
{
  module: 'multipass/preset',
  preset: {
    name: 'componentNew_description',
    description: 'generate a new component from a text description'
  }
}
{
  module: 'multipass/run',
  status: 'starting',
  query: {
    description: 'google search ui',
    framework: 'react',
    components: 'nextui',
    icons: 'lucide'
  },
  preset: {
    name: 'componentNew_description',
    description: 'generate a new component from a text description'
  },
  passes: [
    'design-component-new-from-description',
    'build-component-generation-context',
    'generate-component-new',
    'validate-check-generated-component',
    'validate-fix-generated-component',
    'postprocess-generated-component',
    'store-component',
    'export-component'
  ]
}
> pass 0/7
> init : passes/design-component-new-from-description
undefined:1
()
 ^

SyntaxError: Unexpected token ')'
    at Object.run (/home/orzmiku/DevDrive/aicode/openv0/server/modules/multipass/passes/design-component-new-from-description/index.js:154:17)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async run (/home/orzmiku/DevDrive/aicode/openv0/server/modules/multipass/index.js:31:22)
    at async Object.preset (/home/orzmiku/DevDrive/aicode/openv0/server/modules/multipass/index.js:80:10)
    at async /home/orzmiku/DevDrive/aicode/openv0/server/api.js:138:21

Node.js v18.18.0

gpt-3.5-turbo model

(base) orzmiku@DevMiku:~/DevDrive/aicode/openv0/server$ node api.js 
Server is running on http://localhost:3000
Connected to the database
{
  module: 'multipass/preset',
  preset: {
    name: 'componentNew_description',
    description: 'generate a new component from a text description'
  }
}
{
  module: 'multipass/run',
  status: 'starting',
  query: {
    description: 'google search ui',
    framework: 'react',
    components: 'nextui',
    icons: 'lucide'
  },
  preset: {
    name: 'componentNew_description',
    description: 'generate a new component from a text description'
  },
  passes: [
    'design-component-new-from-description',
    'build-component-generation-context',
    'generate-component-new',
    'validate-check-generated-component',
    'validate-fix-generated-component',
    'postprocess-generated-component',
    'store-component',
    'export-component'
  ]
}
> pass 0/7
> init : passes/design-component-new-from-description
{
{
  "new_component_name": "GoogleSearchUI",
  "new_component_description": "The GoogleSearchUI component is designed to replicate the user interface of the Google search engine. It allows users to input search queries and displays search results in a visually appealing and user-friendly manner.",
  "use_library_components": [
    {
      "library_component_name": "",
Input",
      "library_component_usage_reason": "To provide a text input field where users can enter their search query."
    },
    {
      "library_component_name": "Button",
      "library_component_usage_reason": "To display a search button that users can click to initiate the search."
    },
    {
      "library_component_name": "Card",
      "library_component_usage_reason": "To display the search results in a card-like format, with relevant information and a title."
    },
    {
      "library_component_name": "Avatar",
      "library_component_usage_reason": "To display the profile picture or logo of the source of the search result."
    },
    {
      "library_component_name": "Link",
      "library_component_usage_reason": "To create clickable links that direct users to the source of the search result."
    }
  ]
}undefined:2
{
^

SyntaxError: Unexpected token '{'
    at Object.run (/home/orzmiku/DevDrive/aicode/openv0/server/modules/multipass/passes/design-component-new-from-description/index.js:154:17)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async run (/home/orzmiku/DevDrive/aicode/openv0/server/modules/multipass/index.js:31:22)
    at async Object.preset (/home/orzmiku/DevDrive/aicode/openv0/server/modules/multipass/index.js:80:10)
    at async /home/orzmiku/DevDrive/aicode/openv0/server/api.js:138:21

Node.js v18.18.0

OrzMiku avatar Oct 05 '23 04:10 OrzMiku

mark. my env also has to use baseURL.

just-a-stone avatar Oct 05 '23 08:10 just-a-stone

I encountered this problem too

mooerccx avatar Oct 05 '23 13:10 mooerccx

  • the chat completion functions in multipass plugins are independent from everything else, and can be (re)implemented in any way you want
  • seems like the error here happens in parsing the JSON string returned from completion (in my implementation, i used eval() because gpt function_call does not return a strictly parseable JSON)
  • i suggest you log the returned object right before this line and use it to troubleshoot
  • maybe we need an interface to integrate multiple LLMs straight from .env config, but honestly it's not top priority now

raidendotai avatar Oct 09 '23 13:10 raidendotai