#Wonder which model would be the best to extract mentions of books or movies from an rss feed?

17 messages · Page 1 of 1 (latest)

regal bay
#

Right now I'm using createCompletion, but I'm wondering if something else might be more efficient/accurate. Doing something like this:

const analyzeText = async text => {
  console.log('Analyzing text...')
  const openai = new OpenAIApi(configuration)
  const result = await openai.createCompletion({
    model: 'text-davinci-edit-001',
    prompt: `Analyze the text and extract mentions of movies, films, books, short stories, or articles. Then, categorize them into separate lists and return the lists.

  Text: ${text}`,
    max_tokens: 100,
    n: 1,
    stop: null,
    temperature: 0.7
  })
  console.log('Text analyzed successfully!')
  return result.data.choices[0].text.trim()
}
versed raven
#

gpt-3.5-turbo is best in fast response, for the quality of response, gpt-4 is best.

regal bay
hot raptor
regal bay
#

@versed raven @hot raptor Sorry, I'm not seeing the documentation for how to call each model differently. Shouldn't something like this work with the 3.5-turbo model?

const analyzeText = async text => {
  console.log('Analyzing text...')
  const openai = new OpenAIApi(configuration)
  const result = await openai.createCompletion({
    model: 'gpt-3.5-turbo',
    prompt: `You should respond with nothing other than JSON. Analyze the text and extract mentions of movies, films, books, short stories, or articles. Categorize them into separate lists for each episode, format your response strictly as JSON and return the following keys with data:

    Episode: "Title"
    Movies: ['movie1', 'movie2']
    Books: ['book1', 'book2']
    Short Stories: [shortStory1', 'shortStory2']
    Articles: ['article1', 'article2']
    
    Text: ${text}`,

    max_tokens: 1000,
    n: 1,
    stop: null,
    temperature: 0.7
  })
  console.log('Text analyzed successfully!')
  return result.data.choices[0].text.trim()
}```

Getting a 404 on the call, but not when I use text-davinci-002
hot raptor
versed raven
regal bay
#

Ok ill look over that again, thank you! Does that seem like the right method (or whatever its called) for that type of prompt?

versed raven
regal bay
#

Ahh ok. I'll try it with that setup. Thank you!

versed raven
#

Do you see {"role"}?

regal bay
#

Yep, I was thinking that was optional

versed raven
#

and make sure that you are using latest version of openai.

#

you can update version using this command.
pip install --upgrade openai

regal bay
#

Working now! Looks like the method call is slightly different in node. This is what's working:

const analyzeText = async text => {
  console.log('Analyzing text...')
  const openai = new OpenAIApi(configuration)
  
  const conversation = [
    { "role": "system", "content": "You are a helpful assistant that parses text and identifies references to movies, films, books, short stories, and articles. You should respond with nothing other than JSON. Organize the identified references into separate lists, each keyed by category in the response." },
    { "role": "user", "content": `Text: ${text}` },
  ];

  const result = await openai.ChatCompletion.create({
    model: 'gpt-3.5-turbo',
    messages: conversation,
    max_tokens: 1000,
    temperature: 0.7
  })

  console.log('Text analyzed successfully!')
  return result.data['choices'][0]['message']['content']
}
#

Thanks for the help!