xiangsx/gpt4free-ts

Test file

Nicat-dcw opened this issue · 2 comments

const axios = require("axios");

async function ask() {
  const objj = {
    messages: { prompt: "Hello" }, //[{" role":"user","content":"hello\n"},{"role":"assistant","content":"Hi there! How can I assist you today?"},{"role":"user","prompt":"who are you"}],
    model: "gpt-4"
  };

  try {
    const response = await axios.post(
      "http://127.0.0.1:3000/v1/chat/completions?site=better",{
      data: {
		prompt: "Hello",
  	    messages: { content: "Hello" }, //[{" role":"user","content":"hello\n"},{"role":"assistant","content":"Hi there! How can I assist you today?"},{"role":"user","prompt":"who are you"}],
        model: "gpt-4"  
	  }},
      {
		body: {
		 messages: { prompt: "Hello" }, //[{" role":"user","content":"hello\n"},{"role":"assistant","content":"Hi there! How can I assist you today?"},{"role":"user","prompt":"who are you"}],
         model: "gpt-4"	
		},
        headers: {
          "Content-Type": "application/json"
        }
      }
    );

    console.log(response.data.choices[0]);
  } catch (error) {
	console.error(error)
    console.error("Error making the request:", error.message);
  }
}

ask();

I trying this but server says need prompt in query

I solved with some changes in index.ts