manibatra / obsidian-text2anki-openai

MIT License
8 stars 0 forks source link

Plugin not parsing flash cards response correctly #2

Open JavaJimFl opened 1 year ago

JavaJimFl commented 1 year ago

I received an 'model not found' error response when trying to use the 'gpt-4' GPT model name:

{
    "error": {
        "message": "The model: `gpt-4` does not exist",
        "type": "invalid_request_error",
        "param": null,
        "code": "model_not_found"
    }
}

I changed to to 'gpt-3.5-turbo-0301' and tried again:

{
  "id": "AAAAA",
  "object": "chat.completion",
  "created": 123,
  "model": "gpt-3.5-turbo-0301",
  "usage": {
    "prompt_tokens": 123,
    "completion_tokens": 123,
    "total_tokens": 123
  },
  "choices": [
    {
      "message": {
        "role": "assistant",
        "content": "Front: What is an EBS snapshot? || \nBack: An EBS snapshot is a backup of an Amazon Elastic Block Storage (EBS) Volume at a point in time.\n\nFront: What does AWS recommend when creating an EBS snapshot? || \nBack: AWS recommends detaching the volume to create the snapshot, but it's not necessary.\n\nFront: How does Amazon bill for EBS snapshots? || \nBack: Amazon bills only for the storage of the changed volume blocks.\n\nFront: Can an EBS snapshot be copied across an AWS Availability Zone or AWS Region? || \nBack: Yes, an EBS snapshot can be copied across an AWS Availability Zone or even an AWS Region.\n\nFront: What is the EBS snapshot archive? || \nBack: The EBS snapshot archive holds full EBS volume copies and Amazon bills for all volume blocks.\n\nFront: How much less do EBS snapshots moved to an \"archive tier\" cost? || \nBack: EBS snapshots moved to an \"archive tier\" cost 75% less.\n\nFront: How long does it take to restore a snapshot from the archive? || \nBack: It takes 24-72 hours to restore a snapshot from the archive.\n\nFront: What is the minimum retention period for an EBS snapshot archive? || \nBack: The minimum retention period for an EBS snapshot archive is 90 days.\n\nFront: Do snapshot archive retrievals incur additional charges? || \nBack: Yes, snapshot archive retrievals incur additional charges.\n\nFront: What is Fast Snapshot Restore (FSR)? || \nBack: Fast Snapshot Restore (FSR) forces an immediate snapshot restore for an additional charge.\n\nFront: Is Fast Snapshot Restore (FSR) expensive? || \nBack: Yes, Fast Snapshot Restore (FSR) is very expensive.\n\nFront: Can the Recycle Bin be used for EBS snapshots? || \nBack: Yes, the Recycle Bin can be used for EBS snapshots.\n\n======="
      },
      "finish_reason": "stop",
      "index": 0
    }
  ]
}

While I got a response with multiple cards, only one was imported into Anki. The front of the card was fine, and its answer was correct, but the 'front' keyword appeared after the answer. I don't think the content is being parsed correctly. Could it be related to the GPT model name?

manibatra commented 1 year ago

I am pretty sure this is related to using the gpt-3.5-turbo-0301 model. I have found it to be a hit-and-miss when it comes to generating the responses in the correct structure. It looks like you do not have access to the gpt-4 model. Once you have access, the responses will be more structured. I am a little short on time at the moment, but I will try and push an update out in the next few weeks to change the prompt to try and coax more structured replies from GPT-3.5.