radicalxdev / kai-ai-backend

This is the Kai Teaching Assistant ai repo.
MIT License
12 stars 46 forks source link

Solve issue 30 #31

Closed AaronSosaRamos closed 2 weeks ago

AaronSosaRamos commented 1 month ago

This Pull Request is done for solving #30. As @mikhailocampo mentioned, I had to monitor the LLM responses in order to evaluate the problem. What I have discovered was that the actual problem was not the ```json string, but indeed it was this specific response format that was not appropriately managed by the validate_response function: image As you can see, the format changes for the choices, organizing them differently as how it is normally accepted: image For that reason, I have implemented a function to pre-process the provided dict from the chain. As a result, we can decrease the latency for performing less requests, decreasing the token costs and achieving the requested amount of questions. This was the result of requesting 3 questions (With multiple attempts as a result of the unaccepted format) before of the implementation of the function: image And this is the result of requesting 3 questions after implementing the function: image

mikhailocampo commented 1 month ago

@bkb-Git Quick question, so what is the expected incoming format for the choices data structure? I know it is a list type but are you expecting the keys to be explicitly key or the actual letter like

{ 
"key": "A",
"value": "<answer>"
}

OR

{
"<letter_key>": "<choice>"
}

Let us know so we can validate

mikhailocampo commented 2 weeks ago

This is resolved into Staging, will close this PR and subsequent issue