Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
OrzMiku opened this issue Oct 5, 2023 · 3 comments

Comments

@OrzMiku
Copy link

OrzMiku commented Oct 5, 2023

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
@just-a-stone
Copy link

mark.
my env also has to use baseURL.

@mooerccx
Copy link

mooerccx commented Oct 5, 2023

I encountered this problem too

@raidendotai
Copy link
Owner

  • 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants