gptscript-ai / gptscript

Build AI assistants that interact with your systems
https://gptscript.ai
Apache License 2.0
2.92k stars 258 forks source link

TUI - Prompted for entering openAI API keys when executing gptscript that is chat enabled using a local provider. #510

Closed sangee2004 closed 2 months ago

sangee2004 commented 2 months ago

gptscript version v0.8.2+1b5e068f

Steps to reproduce the problem:

  1. Execute the following script that is chat enabled using a local provider
    
    cat examples/bobchat.gpt  
    tools: bob
    chat: true
    Ask Bob how he is doing and let me know exactly what he said.

name: bob description: I'm Bob, a friendly guy. args: question: The question to ask Bob. chat: true

When asked how I am doing, respond with "Thanks for asking "${question}", I'm doing great fellow friendly AI tool!"


2. User is prompted to enter OpenAI API key.

gptscript --disable-cache --default-model 'Llama-3-8b-function-calling-alpha-v1.gguf from http://localhost:1234/v1' examples/bobchat.gpt 12:32:27 WARNING: Changing the default model can have unknown behavior for existing tools. Use the model field per tool instead.

Please provide your OpenAI API key:

On entering an invalid(or empty) openAI API key , the script fails to execute.

 gptscript --disable-cache --default-model 'Llama-3-8b-function-calling-alpha-v1.gguf from http://localhost:1234/v1' examples/bobchat.gpt
12:31:32 WARNING: Changing the default model can have unknown behavior for existing tools. Use the model field per tool instead.
2024/06/18 12:31:42 error, status code: 401, message: Incorrect API key provided: 234. You can find your API key at https://platform.openai.com/account/api-keys.

Expected Behavior: User should not be prompted to enter openAI API keys when executing chat scripts with local providers.

Note - When TUI is disabled - gptscript --disable-cache --default-model 'Llama-3-8b-function-calling-alpha-v1.gguf from http://localhost:1234/v1' --disable-tui examples/bobchat.gpt , there is no prompting for openai API key and chat completion requests get directed to local models and succeeds.

sangee2004 commented 2 months ago

Similar issue is also seen when testing with "--ui" option with local provider. User is prompted to enter openai api keys and chat completion requests are sent to openai instead of being sent to local provider.

sangee2004 commented 2 months ago

This issue is seen when testing with any provider other than the default gpt provider.

gptscript --default-model 'claude-3-opus-20240229  from github.com/gptscript-ai/anthropic-provider' examples/bobchat.gpt                
10:58:49 WARNING: Changing the default model can have unknown behavior for existing tools. Use the model field per tool instead.

Please provide your OpenAI API key:
njhale commented 2 months ago

@sangee2004 just merged a fix (#541) to main. Please verify the issue is resolved when you get the chance.

sangee2004 commented 2 months ago

@njhale When i try to TUI with other providers , I am not prompted to enter openai api keys anymore. But tool calls do not succeed. In case of local model , i just see a message about starttoolcall and in the case of anthropic provider , it just hangs. Seems like confirmation prompt for repo is broken in this flow which might be causing this problem.

%gptscript --default-model 'Llama-3-8b-function-calling-alpha-v1.gguf from http://localhost:1234/v1' --disable-cache github.com/gptscript-ai/cli-demo
09:55:02 WARNING: Changing the default model can have unknown behavior for existing tools. Use the model field per tool instead.

  Hello! How can I assist you today?                                                                                                                                          

> get me all my github repos

  starttoolcall{"name": "github", "arguments": "{\"task\":\"list all repos\"}"}endtoolcall                                                                                    
% gptscript --default-model 'claude-3-5-sonnet-20240620 from github.com/gptscript-ai/claude3-anthropic-provider' --disable-cache github.com/gptscript-ai/cli-demo
09:55:48 WARNING: Changing the default model can have unknown behavior for existing tools. Use the model field per tool instead.
njhale commented 2 months ago

The latter issue w/ the anthropic provider should be fixed by #551

sangee2004 commented 2 months ago

Tested with gptscript version v0.0.0-dev-3033b05a-dirty

Able to chat with local provider and Anthropic provider using TUI ( and --disable-tui) option.

sangee2004 commented 2 months ago

Closing this issue with findings from https://github.com/gptscript-ai/gptscript/issues/510#issuecomment-2189995940.

We are still not able to launch ui with other providers which is tracked in https://github.com/gptscript-ai/gptscript/issues/556, https://github.com/gptscript-ai/gptscript/issues/559