jlewi / foyle

Foyle is a copilot to help developers deploy and operate their applications.
https://foyle.io
Apache License 2.0
110 stars 10 forks source link

Post Processing Bug - Dropped New Line From OpenAI response #327

Open jlewi opened 1 month ago

jlewi commented 1 month ago

I observed the following: Session: 01JB0J90CYPK7XQ6YDWTXZYHDX Trace: 2ec22c57dfdc0bde303772eb4117c8b3 Notes: /Users/jlewi/git_worklog/foyle/2024_10_24_rube_debug_example.md

The generated code cell had a single comment line which had a command as part of it. Here is the contents of the cell "# 1. Get the details of the service account associated with your Kubernetes podkubectl get pod -o=jsonpath='{.spec.serviceAccountName}' -n "

Note how the kubectl command is on the comment line. It looks like a newline was dropped.

It looks like the newline was in the response from OpenAI. Here's the json of the response

"{\"choices\":[{\"finish_reason\":\"stop\",\"index\":0,\"message\":{\"content\":\"To check which Google service account is being used by your Kubernetes pod, you can run the following command:\\n\\n```bash\\n# 1. Get the details of the service account associated with your Kubernetes pod\\nkubectl get pod \\u003cyour-pod-name\\u003e -o=jsonpath='{.spec.serviceAccountName}' -n \\u003cyour-namespace\\u003e\\n```\\n\\nReplace `\\u003cyour-pod-name\\u003e` with the name of your pod and `\\u003cyour-namespace\\u003e` with the namespace in which your pod is deployed.\\n\\nAfter you identify the service account, you can describe it to check the IAM role bindings:\\n\\n```bash\\n# 2. Describe the service account to check its IAM roles\\ngcloud iam service-accounts describe \\u003cservice-account-name\\u003e@\\u003cyour-project-id\\u003e.iam.gserviceaccount.com\\n```\\n\\nReplace `\\u003cservice-account-name\\u003e` and `\\u003cyour-project-id\\u003e` appropriately with the values you retrieved from the previous command.\",\"role\":\"assistant\"}}],\"created\":1729817270,\"id\":\"chatcmpl-AM2mUHOQY8z59cYSd0xfQ6T9cV0bH\",\"model\":\"gpt-4o-mini-2024-07-18\",\"object\":\"chat.completion\",\"system_fingerprint\":\"fp_482c22a7bc\",\"usage\":{\"completion_tokens\":183,\"prompt_tokens\":2120,\"total_tokens\":2303}}"

It looks like there is a newline that got dropped when the resposne was turned into blocks.