aandrew-me / tgpt

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

Order of providers #254

Closed johnd0e closed 5 months ago

johnd0e commented 7 months ago

Currently order of providers is sort of random:

https://github.com/aandrew-me/tgpt/blob/9477ce1b3f6d36c69d2b6b838fc3a54cf3199253/main.go#L485

In providers.go the order is different. At first enumeration it is alphabetical, but then in two places the order gets random again. https://github.com/aandrew-me/tgpt/blob/9477ce1b3f6d36c69d2b6b838fc3a54cf3199253/providers/providers.go#L7-L40

Perhaps it would be better to sync the order of the providers through all the occurrences.

The question is: which order should be preferred?

aandrew-me commented 7 months ago

Does it matter?

johnd0e commented 7 months ago

You decide. For me it would be easier to maintain a project with consistent items order, as when I need to make a change, it requires simultaneous edits in several places.

shmilee commented 6 months ago

It matters. You have made a mistake in v2.7.3, https://github.com/aandrew-me/tgpt/blob/22015a0d036748e02c7bc5fbb480856925a89151/providers/providers.go#L26-L29

shmilee commented 6 months ago

@aandrew-me Here is the bug report, for ollama and openai

[$] tgpt --provider openai --key sk-?? --url https://??  --model "gpt-3.5-turbo" "What is 1+1"

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

goroutine 1 [running]:
github.com/aandrew-me/tgpt/v2/providers/ollama.GetMainText({0xc0001446e0?, 0x142?})
    /home/runner/work/tgpt/tgpt/providers/ollama/ollama.go:91 +0xdb
github.com/aandrew-me/tgpt/v2/providers.GetMainText({0xc0001446e0?, 0xc0000b9000?}, {0x7ffc2018d381?, 0xc000138080?}, {0xc00002c120?, 0x0?})
    /home/runner/work/tgpt/tgpt/providers/providers.go:27 +0x6d
main.handleEachPart(0xc000172380?, {0xc00002c120, 0x30})
    /home/runner/work/tgpt/tgpt/helper.go:543 +0x1e8
main.getDataResponseTxt({0xc00002c120, 0x30}, 0x0, {{0x0, 0x0}, {0x0, 0x0}, {0x0, 0x0}})
    /home/runner/work/tgpt/tgpt/helper.go:84 +0x44c
main.getData({0xc00002c120, 0x30}, 0x25?, {{0x0, 0x0}, {0x0, 0x0}, {0x0, 0x0}})
    /home/runner/work/tgpt/tgpt/helper.go:88 +0x6f
main.main()
    /home/runner/work/tgpt/tgpt/main.go:323 +0x1055
aandrew-me commented 5 months ago

I decided to make the order alphabetical