aandrew-me / tgpt

AI Chatbots in terminal without needing API keys
GNU General Public License v3.0
2.04k stars 171 forks source link

fix the broken provider openai in v2.7.3 #262

Closed shmilee closed 6 months ago

shmilee commented 6 months ago

Commit-1: fix this, https://github.com/aandrew-me/tgpt/blob/22015a0d036748e02c7bc5fbb480856925a89151/providers/providers.go#L26-L29

Commit-2: fix an index error of openai Response

panic: runtime error: index out of range [0] with length 0

goroutine 1 [running]:
github.com/aandrew-me/tgpt/v2/providers/openai.GetMainText({0xc000126840?, 0x142?})
    /tmp/tgpt/src/tgpt-2.7.3/providers/openai/openai.go:98 +0xdb
github.com/aandrew-me/tgpt/v2/providers.GetMainText({0xc000126840?, 0xc0002a1000?}, {0x7fffda6c3346?, 0xc000132080?}, {0xc00021a03b?, 0x0?})
....

Response:

data: {"choices":[],"created":0,"id":"","model":"","object":"","prompt_filter_results":[{"prompt_index":0,"content_filter_results":{"hate":{"filtered":false,"severity":"safe"},"self_harm":{"filtered":false,"severity":"safe"},"sexual":{"filtered":false,"severity":"safe"},"violence":{"filtered":false,"severity":"safe"}}}]}