gptscript-ai / desktop

MIT License
19 stars 13 forks source link

UI - `Model` set within the script is not getting used properly when scripts are executed using UI. #160

Closed sangee2004 closed 1 month ago

sangee2004 commented 1 month ago

gptscript version - v0.0.0-dev-a5a0538d-dirty

Scenario 1: Pre Req

  1. Do not have openai keys set thru environment variable or sys.openai credential.
  2. Have anthropic credentials set.

Steps to reproduce the problem:

  1. Execute the following script using ui - DISABLE_CACHE=true gptscript --ui internet_chat_claude.gpt
Tools: github.com/gptscript-ai/search/brave
Model: claude-3-5-sonnet-20240620 from github.com/gptscript-ai/claude3-anthropic-provider
Chat: true

You are a good assistant . Wait for the user to ask a question and always return source for the search results.

Following error in seen:

 ⨯ unhandledRejection: TypeError: Cannot create property 'digest' on string 'prompt occurred when prompt was not allowed: Message: Please provide your OpenAI API key:
Fields: key
Sensitive: true'
    at /Users/sangeethahariharan/Library/Caches/gptscript/repos/de7395ca8d353df9ea3e521a513bfc853feab73e/tool.gpt/node21/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:36:17727
    at AsyncLocalStorage.run (node:async_hooks:346:14)
    at eL (/Users/sangeethahariharan/Library/Caches/gptscript/repos/de7395ca8d353df9ea3e521a513bfc853feab73e/tool.gpt/node21/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:35:273726)
    at /Users/sangeethahariharan/Library/Caches/gptscript/repos/de7395ca8d353df9ea3e521a513bfc853feab73e/tool.gpt/node21/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:35:269554
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
 ⨯ unhandledRejection: TypeError: Cannot create property 'digest' on string 'prompt occurred when prompt was not allowed: Message: Please provide your OpenAI API key:
Fields: key
Sensitive: true'
    at /Users/sangeethahariharan/Library/Caches/gptscript/repos/de7395ca8d353df9ea3e521a513bfc853feab73e/tool.gpt/node21/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:36:17727
    at AsyncLocalStorage.run (node:async_hooks:346:14)
    at eL (/Users/sangeethahariharan/Library/Caches/gptscript/repos/de7395ca8d353df9ea3e521a513bfc853feab73e/tool.gpt/node21/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:35:273726)
    at /Users/sangeethahariharan/Library/Caches/gptscript/repos/de7395ca8d353df9ea3e521a513bfc853feab73e/tool.gpt/node21/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:35:269554
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

Note : Running the script using TUI works as expected - gptscript --disable-cache internet_chat_claude.gpt

Scenario 2:

Pre Req In my case I dont have gcloud authentication setup , so using github.com/gptscript-ai/gemini-vertexai-provider would fail. Have a valid openai key set in sys.openai creds.

Steps to reproduce the problem:

  1. Launch UI using gemini vertexai provider for the following script - gptscript --disable-cache --default-model 'gemini-1.0-pro from github.com/gptscript-ai/gemini-vertexai-provider' --ui internet_chat.gpt
Tools: github.com/gptscript-ai/search/brave
Model: gpt-4o
Chat: true

You are a good assistant . Wait for the user to ask a question and always return source for the search results.
  1. Ask any question

There is no response and following error in seen in ui console

 ⨯ unhandledRejection: TypeError: Cannot create property 'digest' on string 'error, status code: 401, message: {"detail":"Authentication error. Please ensure you are properly authenticated with GCP and have the correct project configured."}'
    at /Users/sangeethahariharan/Library/Caches/gptscript/repos/de7395ca8d353df9ea3e521a513bfc853feab73e/tool.gpt/node21/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:36:17727
    at AsyncLocalStorage.run (node:async_hooks:346:14)
    at eL (/Users/sangeethahariharan/Library/Caches/gptscript/repos/de7395ca8d353df9ea3e521a513bfc853feab73e/tool.gpt/node21/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:35:273726)
    at /Users/sangeethahariharan/Library/Caches/gptscript/repos/de7395ca8d353df9ea3e521a513bfc853feab73e/tool.gpt/node21/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:35:269554
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
 ⨯ unhandledRejection: TypeError: Cannot create property 'digest' on string 'error, status code: 401, message: {"detail":"Authentication error. Please ensure you are properly authenticated with GCP and have the correct project configured."}'
    at /Users/sangeethahariharan/Library/Caches/gptscript/repos/de7395ca8d353df9ea3e521a513bfc853feab73e/tool.gpt/node21/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:36:17727
    at AsyncLocalStorage.run (node:async_hooks:346:14)
    at eL (/Users/sangeethahariharan/Library/Caches/gptscript/repos/de7395ca8d353df9ea3e521a513bfc853feab73e/tool.gpt/node21/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:35:273726)
    at /Users/sangeethahariharan/Library/Caches/gptscript/repos/de7395ca8d353df9ea3e521a513bfc853feab73e/tool.gpt/node21/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:35:269554
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

Note - The same script when executed from TUI succeeds as expected - gptscript --disable-cache --default-model 'gemini-1.0-pro from github.com/gptscript-ai/gemini-vertexai-provider' internet_chat.gpt

internet_chat.gpt 
14:55:43 WARNING: Changing the default model can have unknown behavior for existing tools. Use the model field per tool instead.

  How can I assist you today?                                                                                                                                                                                     

> Who won 2024 superbowl?

    ┌──────────────────────────────────────┐
    │ Call Arguments:                      │
    │                                      │
    │ brave {"q":"2024 Super Bowl winner"} │
    └──────────────────────────────────────┘

  Running  from github.com/gptscript-ai/search/brave                                                                                                                                                              

    ┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
    │ Title: Super Bowl LVIII - Wikipedia                                                                                                                                                                                 
    │ URL: https://en.wikipedia.org/wiki/Super_Bowl_LVIII                                                                                                                                                                 
    │ Description: <strong>The Chiefs</strong> became the first team to win back-to-back Super Bowls since the 2004 New England Patriots. The game was played on February 11, 2024, at Allegiant Stadium in Paradise, Neva
    │                                                                                                                                                                                                                     
    │ Title: 2024 Super Bowl LVIII - Chiefs vs 49ers News, Highlights and More | FOX Sports                                                                                                                               
    │ URL: https://www.foxsports.com/nfl/super-bowl                                                                                                                                                                       
    │ Description: Super Bowl LVIII will be televised nationally on CBS. ... The <strong>Kansas City Chiefs</strong> will take on the San Francisco 49ers in the 2024 Super Bowl.                                         
    │                                                                                                                                                                                                                     
    │ Title: Super Bowl Winners List - Full NFL winners list from 1967 to 2024 - MARCA in English                                                                                                                         
    │ URL: https://www.marca.com/en/nfl/winners.html                                                                                                                                                                      
    │ Description: Check the updated ranking of all the <strong>winners</strong>, runners-up, MVP and scores of the <strong>Super</strong> <strong>Bowl</strong> <strong>winners</strong> year by year since the beginning
    │                                                                                                                                                                                                                     
    │ Title: 2024 super bowl winner on X                                                                                                                                                                                  
    │ URL: https://twitter.com/search?q=2024+super+bowl+winner                                                                                                                                                            
    │ Description: Explore Twitter&#x27;s latest discussions on <strong>2024</strong> <strong>super</strong> <strong>bowl</strong> <strong>winner</strong>                                                                
    │                                                                                                                                                                                                                     
    │ Title: Super Bowl winners throughout history: Full list from 2024 all the way back to the first in 1967 - CBS News                                                                                                  
    │ URL: https://www.cbsnews.com/news/super-bowl-winners-list-history/                                                                                                                                                  
    │ Description: Mecole Hardman Jr. describes game-winning Super Bowl catch 04:48 · The 2024 Super Bowl ended in dramatic fashion with the <strong>Kansas City Chiefs</strong> defeating the San Francisco 49ers 25-22 i
    │                                                                                                                                                                                                                     
    │ Title: Super Bowl 2024: Chiefs beat 49ers in overtime to win second straight title | AP News                                                                                                                        
    │ URL: https://apnews.com/article/super-bowl-2024-score-chiefs-49ers-49b5dca51c05ab0f259cef0d7da76c2d                                                                                                                 
    │ Description: Patrick Mahomes, Travis Kelce and Andy Reid have made the <strong>Kansas City Chiefs</strong> a dynasty. They’re already thinking three-peat. First, they had to become the NFL’s first back-to-back Su
    │                                                                                                                                                                                                                     
    │ Title: Super Bowl 2024 Winner                                                                                                                                                                                       
    │ URL: https://www.hollywoodreporter.com/news/general-news/super-bowl-2024-winner-1235822266/                                                                                                                         
    │ Description: The <strong>Kansas City Chiefs</strong> are still the Super Bowl champs. Michael Reaves/Getty Images ... The <strong>Kansas City Chiefs</strong> are still the Super Bowl champs.                      
    │                                                                                                                                                                                                                     
    │ Title: Super Bowl 2024 updates: The commercials, cameos, halftime show and more                                                                                                                                     
    │ URL: https://www.npr.org/2024/02/10/1230621176/super-bowl-58                                                                                                                                                        
    │ Description: The <strong>Kansas City Chiefs</strong> win the Super Bowl 58. Here&#x27;s are the highlights from the big game                                                                                        
    │                                                                                                                                                                                                                     
    │ Title: Super Bowl 2024 winners and losers: Patrick Mahomes was legendary                                                                                                                                            
    │ URL: https://www.usatoday.com/story/sports/nfl/super-bowl/2024/02/12/super-bowl-2024-winners-and-losers-patrick-mahomes-was-legendary/72563446007/                                                                  
    │ Description: <strong>The Chiefs</strong> toppled the San Francisco 49ers in Super Bowl 58 on Sunday night in Las Vegas, 25-22, to become the first team in 19 seasons to repeat as Super Bowl champions. They have w
    │                                                                                                                                                                                                                     
    │ Title: Super Bowl 2024 Recap: The Kansas City Chiefs' Big Win, Taylor Swift's Celebrations and All the Highlights                                                                                                   
    │ URL: https://people.com/super-bowl-2024-full-recap-8572245                                                                                                                                                          
    │ Description: Golden Globe winner <strong>Andra Day</strong> kicked off a series of big pre-kickoff performances with a rousing rendition of &quot;Lift Every Voice and Sing.&quot; Following the announcement that s
    │                                                                                                                                                                                                                     
    │ Title: Super Bowl 2024 - Highlights from Chiefs' win vs. 49ers - ESPN                                                                                                                                               
    │ URL: https://www.espn.com/nfl/story/_/id/39480722/49ers-chiefs-live-super-bowl-lviii-updates-moments-highlights                                                                                                     
    │ Description: With a relentless defense and opportune plays by their star quarterback -- including a pair of gutsy overtime scrambles -- <strong>the Chiefs</strong> won their third Super Bowl in five years in a 25
    │                                                                                                                                                                                                                     
    │ Title: Super Bowl Winners and Results - Super Bowl History - National Football League - ESPN                                                                                                                        
    │ URL: https://www.espn.com/nfl/superbowl/history/winners                                                                                                                                                             
    │ Description: Find out each <strong>Super</strong> <strong>Bowl</strong> winning team throughout NFL pro football history.                                                                                           
    │                                                                                                                                                                                                                     
    │ Title: Super Bowl 2024: Kansas City Chiefs defend NFL title after beating San Francisco 49ers in overtime - BBC Sport                                                                                               
    │ URL: https://www.bbc.com/sport/american-football/68145318                                                                                                                                                           
    │ Description: The Kansas City Chiefs fight back to beat the San Francisco 49ers 25-22 in overtime and win their third <strong>Super</strong> <strong>Bowl</strong> in five years.                                    
    │                                                                                                                                                                                                                     
    │ Title: Kansas City Chiefs win 2024 Super Bowl, beating San Francisco 49ers in overtime                                                                                                                              
    │ URL: https://ktla.com/sports/the-big-game/super-bowl-58-only-second-in-nfl-history-to-go-to-overtime/                                                                                                               
    │ Description: Kansas City Chiefs, San Francisco 49ers are in second overtime game in <strong>Super</strong> <strong>Bowl</strong> history. New England Patriots, Atlanta Falcons played in first                     
    │                                                                                                                                                                                                                     
    │ Title: Super Bowl 2024: Chiefs stun 49ers in overtime for second straight NFL title | Super Bowl | The Guardian                                                                                                     
    │ URL: https://www.theguardian.com/sport/2024/feb/11/who-won-superbowl-49ers-chiefs                                                                                                                                   
    │ Description: The Chiefs have become the first team to repeat as <strong>Super</strong> <strong>Bowl</strong> champions in nearly two decades after coming from behind to defeat the 49ers 25-22 in overtime         
    │                                                                                                                                                                                                                     
    │ Title: super bowl winner 2024 on X                                                                                                                                                                                  
    │ URL: https://twitter.com/search?q=super+bowl+winner+2024                                                                                                                                                            
    │ Description: Explore Twitter&#x27;s latest discussions on <strong>super</strong> <strong>bowl</strong> <strong>winner</strong> <strong>2024</strong>                                                                
    │                                                                                                                                                                                                                     
    │ Title: Super bowl 2024 winner on X                                                                                                                                                                                  
    │ URL: https://twitter.com/search?q=super+bowl+2024+winner                                                                                                                                                            
    │ Description: Explore Twitter&#x27;s latest discussions on <strong>super</strong> <strong>bowl</strong> <strong>2024</strong> <strong>winner</strong>                                                                
    │                                                                                                                                                                                                                     
    │ Title: Chiefs defeat 49ers 25-22 in OT thriller in Super Bowl 2024. Here are highlights from the big game.                                                                                                          
    │ URL: https://www.cbsnews.com/live-updates/super-bowl-2024-chiefs-49ers-game-coverage/                                                                                                                               
    │ Description: 11, <strong>2024</strong> in Las Vegas, Nevada. Kevin Mazur/Getty Images for Roc Nation ... When Usher performs in the halftime show of the <strong>Super</strong> <strong>Bowl</strong>, arguably one 
    │                                                                                                                                                                                                                     
    │ Title: Who won Super Bowl 2024? | The Independent                                                                                                                                                                   
    │ URL: https://www.independent.co.uk/sport/nfl/super-bowl-who-won-chiefs-49ers-score-b2494560.html                                                                                                                    
    │ Description: Kansas City 25-22 San Francisco: Patrick Mahomes and Brock Purdy battled it out at Allegiant Stadium in Las Vegas for the Vince Lombardi trophy                                                        
    │                                                                                                                                                                                                                     
    │ Title: Super Bowl 2024: Chiefs beat 49ers in OT thriller on walk-off TD pass by                                                                                                                                     
    │ Patrick Mahomes                                                                                                                                                                                                     
    │ URL: https://sports.yahoo.com/super-bowl-2024-chiefs-vs-49ers-score-highlights-and-live-updates-210034840.html                                                                                                      
    │ Description: The Chiefs have won a third <strong>Super</strong> <strong>Bowl</strong> with Patrick Mahomes and Andy Reid.                                                                                           
    └─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

  The Kansas City Chiefs won the 2024 Super Bowl, defeating the San Francisco 49ers 25-22 in overtime. This victory marked their second consecutive Super Bowl win and their third title in five years.           

  For more details, you can check the following sources:                                                                                                                                                          

  • Wikipedia https://en.wikipedia.org/wiki/Super_Bowl_LVIII                                                                                                                                                      
  • CBS News https://www.cbsnews.com/news/super-bowl-winners-list-history/                                                                                                                                        
  • BBC Sport https://www.bbc.com/sport/american-football/68145318       
tylerslaton commented 1 month ago

@sangee2004 Since this is no longer possible given you can't run scripts not created by the UI do you still see issues here?

g-linville commented 1 month ago

I don't think this is an issue anymore. In the desktop app, I created a new assistant and gave it access to this test tool I made: https://github.com/g-linville/anthropic-test

When it calls the test tool, it runs the Anthropic provider without any issues.

sangee2004 commented 1 month ago

Tested with electron app - Version 0.10.0-rc3

I am able to chat with claude provider following these steps.

  1. Create an assistant with model (in Advanced) as claude-3-5-sonnet-20240620 from github.com/gptscript-ai/claude3-anthropic-provider
  2. Start a chat using this assistant.
  3. I am prompted to enter anthropic key and I am able to get response successfully.

I am seeing this issue with other threads getting to a bad state which is tracked in https://github.com/gptscript-ai/desktop/issues/161