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

How to run it #100

Closed
AndreiClouds opened this issue Apr 25, 2023 · 6 comments
Closed

How to run it #100

AndreiClouds opened this issue Apr 25, 2023 · 6 comments

Comments

@AndreiClouds
Copy link

I cant run the script , mentioning that i'm a newbie and please help
iloading@DESKTOP-CPIUK2P:/mnt/c/Users/user/Desktop/camel-master/camel-master/examples/ai_society$ python3 role_playing.py
Traceback (most recent call last):
File "/mnt/c/Users/user/Desktop/camel-master/camel-master/examples/ai_society/role_playing.py", line 3, in
from camel.agents import RolePlaying
ModuleNotFoundError: No module named 'camel'

@lightaime
Copy link
Member

Hi @AndreiClouds, it seems you haven't install the camel package. Did you run pip install -e .?

@AndreiClouds
Copy link
Author

Yes everything is setup acordingly and now I'm getting this
(camel) C:\Users\user\Desktop\camel-master\camel-master\examples\ai_society>python role_playing.py
Traceback (most recent call last):
File "C:\Users\user.conda\envs\camel\lib\site-packages\tenacity_init_.py", line 382, in call
result = fn(*args, **kwargs)
File "C:\Users\user\Desktop\camel-master\camel-master\camel\agents\chat_agent.py", line 130, in step
response = openai.ChatCompletion.create(
File "C:\Users\user.conda\envs\camel\lib\site-packages\openai\api_resources\chat_completion.py", line 25, in create
return super().create(*args, **kwargs)
File "C:\Users\user.conda\envs\camel\lib\site-packages\openai\api_resources\abstract\engine_api_resource.py", line 149, in create
) = cls.__prepare_create_request(
File "C:\Users\user.conda\envs\camel\lib\site-packages\openai\api_resources\abstract\engine_api_resource.py", line 106, in __prepare_create_request
requestor = api_requestor.APIRequestor(
File "C:\Users\user.conda\envs\camel\lib\site-packages\openai\api_requestor.py", line 130, in init
self.api_key = key or util.default_api_key()
File "C:\Users\user.conda\envs\camel\lib\site-packages\openai\util.py", line 186, in default_api_key
raise openai.error.AuthenticationError(
openai.error.AuthenticationError: No API key provided. You can set your API key in code using 'openai.api_key = ', or you can set the environment variable OPENAI_API_KEY=). If your API key is stored in a file, you can point the openai module at it with 'openai.api_key_path = '. You can generate API keys in the OpenAI web interface. See https://onboard.openai.com for details, or email support@openai.com if you have any questions.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "C:\Users\user\Desktop\camel-master\camel-master\examples\ai_society\role_playing.py", line 56, in
main()
File "C:\Users\user\Desktop\camel-master\camel-master\examples\ai_society\role_playing.py", line 9, in main
role_play_session = RolePlaying(
File "C:\Users\user\Desktop\camel-master\camel-master\camel\agents\role_playing.py", line 71, in init
self.specified_task_prompt = task_specify_agent.step(
File "C:\Users\user\Desktop\camel-master\camel-master\camel\agents\task_agent.py", line 85, in step
specified_task_msgs, terminated, _ = super().step(task_msg)
File "C:\Users\user.conda\envs\camel\lib\site-packages\tenacity_init_.py", line 289, in wrapped_f
return self(f, *args, **kw)
File "C:\Users\user.conda\envs\camel\lib\site-packages\tenacity_init_.py", line 379, in call
do = self.iter(retry_state=retry_state)
File "C:\Users\user.conda\envs\camel\lib\site-packages\tenacity_init_.py", line 326, in iter
raise retry_exc from fut.exception()
tenacity.RetryError: RetryError[<Future at 0x160e9d3ffd0 state=finished raised AuthenticationError>]

@lightaime
Copy link
Member

lightaime commented Apr 25, 2023

As the error message shown, you need to set up the OpenAI api key:

No API key provided. You can set your API key in code using 'openai.api_key = ', or you can set the environment variable OPENAI_API_KEY=). If your API key is stored in a file, you can point the openai module at it with 'openai.api_key_path = '. You can generate API keys in the OpenAI web interface. See https://onboard.openai.com for details, or email support@openai.com if you have any questions.

@TheCodeInjection
Copy link

so how od i add the api key?

@hammoudhasan
Copy link
Collaborator

There are multiple ways to do that:

  1. Export as variable using your terminal (on Linux that would be)
    export OPENAI_API_KEY=<insert your OpenAI API key>
  2. Add to the Python code,
    openai.api_key = os.environ["OPENAI_API_KEY"]

There are multiple other ways, check this for reference.

@lightaime
Copy link
Member

I closed this issue. Please feel free to reopen if it is not fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants