Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: analyze`s --backend arg error #902

Closed
3 of 4 tasks
JuHyung-Son opened this issue Jan 31, 2024 · 4 comments · Fixed by #966
Closed
3 of 4 tasks

[Bug]: analyze`s --backend arg error #902

JuHyung-Son opened this issue Jan 31, 2024 · 4 comments · Fixed by #966

Comments

@JuHyung-Son
Copy link
Contributor

Checklist

  • I've searched for similar issues and couldn't find anything matching
  • I've included steps to reproduce the behavior

Affected Components

  • K8sGPT (CLI)
  • K8sGPT Operator

K8sGPT Version

No response

Kubernetes Version

No response

Host OS and its Version

No response

Steps to reproduce

2 problems.

  1. set default backend as none openai and give -b openai -> use default backend not openai
> ./bin/k8sgpt analyze -f Service -n default -c -e -b openai
   0% |                                                                                                                                                                                                                                                                                | (0/8, 0 it/hr) [0s:0s]
Error: failed while calling AI provider localai: error, status code: 404, message: %!s(<nil>)
  1. set any default backend and run analyze with -b arg -> only use default backend not provided arg. (i think this is bug)
> ./bin/k8sgpt auth default -p noopai
Default provider set to noopai
> ./bin/k8sgpt analyze -f Service -n default -e -c localai
 100% |███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| (7/7, 2693 it/s)
AI Provider: noopai

Expected behaviour

ai provider should be provided --backend even openai is given.

Actual behaviour

No response

Additional Information

No response

@VaibhavMalik4187
Copy link
Contributor

Hi, can I work on this?

@JuHyung-Son
Copy link
Contributor Author

@VaibhavMalik4187 sure

@VaibhavMalik4187
Copy link
Contributor

It looks like this behaviour is intentional and was introduced by @AlexsJones in the commit cbe2fb4.

@AlexsJones, in #427 (comment), I don't think that the code matches the reasoning. Like, in this case, the backend has been specified as openai and the default backend is also set. But the default backend is being used because it satisfies the following condition and sets the backend to use the default backend:

	if configAI.DefaultProvider != "" && backend == "openai" {
		backend = configAI.DefaultProvider
	}

@VaibhavMalik4187
Copy link
Contributor

VaibhavMalik4187 commented Feb 17, 2024

Changing the default value of the backend flag to "" and updating the if condition to:

	if configAI.DefaultProvider == "" && backend == "" {
		backend = "openai"
        } else if configAI.DefaultProvider != "" && backend == "" {
		backend = configAI.DefaultProvider
        }

Fixes the issue, would like to know your thoughts on this @AlexsJones, @JuHyung-Son. Thanks!

VaibhavMalik4187 added a commit to VaibhavMalik4187/k8sgpt that referenced this issue Feb 18, 2024
Now, the default value of the `backend` flag for the analyze command
will be an empty string. And the `NewAnalysis` function has been
modified to use the default backend set by the user if the backend flag
is not provided and the `defaultprovider` is set in the config file.
Otherwise, backend will be set to "openai".

Fixes: k8sgpt-ai#902

Signed-off-by: VaibhavMalik4187 <vaibhavmalik2018@gmail.com>
VaibhavMalik4187 added a commit to VaibhavMalik4187/k8sgpt that referenced this issue Feb 18, 2024
Now, the default value of the `backend` flag for the analyze command
will be an empty string. And the `NewAnalysis` function has been
modified to use the default backend set by the user if the backend flag
is not provided and the `defaultprovider` is set in the config file.
Otherwise, backend will be set to "openai".

Fixes: k8sgpt-ai#902

Signed-off-by: VaibhavMalik4187 <vaibhavmalik2018@gmail.com>
VaibhavMalik4187 added a commit to VaibhavMalik4187/k8sgpt that referenced this issue Feb 18, 2024
Now, the default value of the `backend` flag for the analyze command
will be an empty string. And the `NewAnalysis` function has been
modified to use the default backend set by the user if the backend flag
is not provided and the `defaultprovider` is set in the config file.
Otherwise, backend will be set to "openai".

Fixes: k8sgpt-ai#902

Signed-off-by: VaibhavMalik4187 <vaibhavmalik2018@gmail.com>
VaibhavMalik4187 added a commit to VaibhavMalik4187/k8sgpt that referenced this issue Feb 21, 2024
Now, the default value of the `backend` flag for the analyze command
will be an empty string. And the `NewAnalysis` function has been
modified to use the default backend set by the user if the backend flag
is not provided and the `defaultprovider` is set in the config file.
Otherwise, backend will be set to "openai".

Fixes: k8sgpt-ai#902

Signed-off-by: VaibhavMalik4187 <vaibhavmalik2018@gmail.com>
AlexsJones pushed a commit that referenced this issue Feb 28, 2024
Now, the default value of the `backend` flag for the analyze command
will be an empty string. And the `NewAnalysis` function has been
modified to use the default backend set by the user if the backend flag
is not provided and the `defaultprovider` is set in the config file.
Otherwise, backend will be set to "openai".

Fixes: #902

Signed-off-by: VaibhavMalik4187 <vaibhavmalik2018@gmail.com>
Co-authored-by: JuHyung Son <sonju0427@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants