Coder Social home page Coder Social logo

Comments (18)

0ut0flin3 avatar 0ut0flin3 commented on July 20, 2024

It's not an error by the app, but you just need to have your API KEY inside environment variable! it's the error you get!

from talk2gpt.

0ut0flin3 avatar 0ut0flin3 commented on July 20, 2024

You need to put your api key inside an environment variable named OPENAI_API_KEY
You can do it from terminal, or with Python too:
>>>import os
>>>os.environ['OPENAI_API_KEY']=<your_api_key_here>

from talk2gpt.

khanfar avatar khanfar commented on July 20, 2024

You need to put your api key inside an environment variable named OPENAI_API_KEY , were do that ??? were this located ???

from talk2gpt.

0ut0flin3 avatar 0ut0flin3 commented on July 20, 2024

You need to put your api key inside an environment variable named OPENAI_API_KEY , were do that ??? were this located ???

you can set an environment variable both using Python or from the terminal itself.

From Python: >>> import os;os.environ['OPENAI_API_KEY']='sk-************'

From command prompt (Windows): set OPENAI_API_KEY=sk-***************

From Linux/MAC Terminal: export OPENAI_API_KEY = 'sk-************'

Note that it will be available just for the terminal session in use then it will disappear and you have to re set it.
if you want to have it always available just write it in your python code, but it is reccomended to use environment variable for security reasons.

Using Python, you can do something like this:

import os
os.environ["OPENAI_API_KEY"]='sk-*******'


#your code here#

so, every time it will auto create the environment variable so you donpt have to set it every time

from talk2gpt.

khanfar avatar khanfar commented on July 20, 2024

import os
os.environ["OPENAI_API_KEY"]='sk-*******'

you mean put these in file and name it .env ???? if correct were to put that ??? i do cmd then python then type import os then type os.environ['OPENAI_API_KEY']= then try again python app.py but get same error !

from talk2gpt.

0ut0flin3 avatar 0ut0flin3 commented on July 20, 2024

import os os.environ["OPENAI_API_KEY"]='sk-*******'

you mean put these in file and name it .env ???? if correct were to put that ??? i do cmd then python then type import os then type os.environ['OPENAI_API_KEY']= then try again python app.py but get same error !

the app.py script is no longer available, the project has been updated, now it is in the form of a pypi package that can be installed with pip. pip install gptalk and the you have to import in your Python code with import gptalk.gptalk as gpt3
Check the README file here on GitHub. There is an example. Or Join Discord.
in any case it is correct how you set the environment variable. only that it must be used in the same session. or, you can also declare it without environment variable like so:

import openai
openai.api_key='sk-*****'

If people has troubles with environment variables so In the next version/update I will make it possible to insert the apikey directly into a variable inside the app, so it will be easier

from talk2gpt.

0ut0flin3 avatar 0ut0flin3 commented on July 20, 2024

import os os.environ["OPENAI_API_KEY"]='sk-*******'

you mean put these in file and name it .env ???? if correct were to put that ??? i do cmd then python then type import os then type os.environ['OPENAI_API_KEY']= then try again python app.py but get same error !

only now i saw that you forked the old project. Well, the apikey should still work, I propose a change to your code so that you can figure out where to put it, but don't make it public, please!!!!

from talk2gpt.

0ut0flin3 avatar 0ut0flin3 commented on July 20, 2024

import os os.environ["OPENAI_API_KEY"]='sk-*******'

you mean put these in file and name it .env ???? if correct were to put that ??? i do cmd then python then type import os then type os.environ['OPENAI_API_KEY']= then try again python app.py but get same error !

I've fixed the code in your fork , now youjust need to have your apikey inside a file named apikey.txt, in the same folder where you are running the script. WARNING, DO NOT SHARE YOUR KEY ON GITHUB

from talk2gpt.

khanfar avatar khanfar commented on July 20, 2024

so now download my fork zip file , then i will see in it new .txt called apikey.txt ???? i download it not see .txt

from talk2gpt.

khanfar avatar khanfar commented on July 20, 2024

or i need to create just txt file and name it apikey.txt and put in same app.py directory ???

from talk2gpt.

khanfar avatar khanfar commented on July 20, 2024

if yes what type inside .txt ???? this correct :
import os
os.environ["OPENAI_API_KEY"]='sk-*******'

from talk2gpt.

khanfar avatar khanfar commented on July 20, 2024

and keep it txt ??? or rename it to .env ???

from talk2gpt.

khanfar avatar khanfar commented on July 20, 2024

brother send to me link to download zip file that i just put my key inside it

from talk2gpt.

0ut0flin3 avatar 0ut0flin3 commented on July 20, 2024

or i need to create just txt file and name it apikey.txt and put in same app.py directory ???

exactly

from talk2gpt.

0ut0flin3 avatar 0ut0flin3 commented on July 20, 2024

or i need to create just txt file and name it apikey.txt and put in same app.py directory ???

exactly

sorry, go to line 131 of your app.py . you will find openai.api_key=os.getenv(....
after openai.api_key= insert your apikey inside double quotes like this : openai.api_key="sk-*****"

Save it, And you're ok

from talk2gpt.

khanfar avatar khanfar commented on July 20, 2024

i do this : i create new txt file and mane it apikey.txt and put this inside it :
os.environ['OPENAI_API_KEY']="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"
then i put it in same directory of app.py
then i open app.py in visual studio code and edit line 131 and i see this :
openai.api_key = os.getenv("sk-xxxxxxxxxxX")

change it to this :
openai.api_key="sk-*****" ????

from talk2gpt.

khanfar avatar khanfar commented on July 20, 2024

i do what i say to you up then i got this :

Human: what is Raspberry Pi

Traceback (most recent call last):
File "C:\Users\Lenovo\Downloads\Compressed\GPT-Talk-main-fork\GPT-Talk-main\app.py", line 237, in
main()
File "C:\Users\Lenovo\Downloads\Compressed\GPT-Talk-main-fork\GPT-Talk-main\app.py", line 184, in main
response = openai.Completion.create(
^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Python311\Lib\site-packages\openai\api_resources\completion.py", line 25, in create
return super().create(args, kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Python311\Lib\site-packages\openai\api_resources\abstract\engine_api_resource.py", line 115, in create
response, _, api_key = requestor.request(
^^^^^^^^^^^^^^^^^^
File "C:\Python311\Lib\site-packages\openai\api_requestor.py", line 181, in request
resp, got_stream = self._interpret_response(result, stream)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Python311\Lib\site-packages\openai\api_requestor.py", line 396, in _interpret_response
self._interpret_response_line(
File "C:\Python311\Lib\site-packages\openai\api_requestor.py", line 429, in _interpret_response_line
raise self.handle_error_response(
openai.error.AuthenticationError: Incorrect API key provided: sk-QVNoH
************************************KD2X. You can find your API key at https://beta.openai.com.

C:\Users\Lenovo\Downloads\Compressed\GPT-Talk-main-fork\GPT-Talk-main>

from talk2gpt.

khanfar avatar khanfar commented on July 20, 2024

can you brother upload ready to use zip file to me and im just put my api in it ? please upload it somewhere and send to me link to download it

from talk2gpt.

Related Issues (6)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.