OS-Copilot / OS-Copilot

An self-improving embodied conversational agent seamlessly integrated into the operating system to automate our daily tasks.
MIT License
1.45k stars 157 forks source link

[General]: I dont know how to fix bug #54

Closed sensen02 closed 3 weeks ago

sensen02 commented 1 month ago

the first three step are successful, but in "Running the script":


(base) sensen@sensen-Zenbook-UX425QA-UM425QA:~/OS-Copilot$ python quick_start.py Task: Your task is: Copy any text file located in the working_dir/document directory that contains the word 'agent' to a new folder named 'agents' Traceback (most recent call last): File "/home/sensen/OS-Copilot/quick_start.py", line 10, in agent = FridayAgent(FridayPlanner, FridayRetriever, FridayExecutor, ToolManager, config=args) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/sensen/OS-Copilot/oscopilot/agents/friday_agent.py", line 33, in init tool_manager = Tool_Manager(config.generated_tool_repo_path) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/sensen/OS-Copilot/oscopilot/tool_repository/manager/tool_manager.py", line 77, in init embedding_function=embedding_function, ^^^^^^^^^^^^^^^^^^ UnboundLocalError: cannot access local variable 'embedding_function' where it is not associated with a value


how to fix this bug? i am using ubuntu 24.04, this is my first time build something from github

sensen02 commented 1 month ago

I did not change anything except api key, org id and replace langchain with langchain_community

heroding77 commented 1 month ago

You can modify

EMBED_MODEL_TYPE = os.getenv('MODEL_TYPE')
EMBED_MODEL_NAME = os.getenv('MODEL_NAME')

in tool_manager.py and try again, if there is still error, feel free to contact me.

sensen02 commented 1 month ago

thanks, I have already fix this bug by changing

OPENAI_API_KEY = os.getenv('OPENAI_API_KEY')

OPENAI_ORGANIZATION = os.getenv('OPENAI_ORGANIZATION')

OPENAI_API_KEY = "sk-proj-KpbrVjSmWOC3PhtKbdY6T3BlbkFJWU9wuHE4BDNPn8bh5H9q" OPENAI_ORGANIZATION = "org-8KurHM3kAoXGlGxsCA3Qi30i"

EMBED_MODEL_TYPE = os.getenv('EMBED_MODEL_TYPE')

EMBED_MODEL_NAME = os.getenv('EMBED_MODEL_NAME')

EMBED_MODEL_TYPE = "OpenAI" EMBED_MODEL_NAME = "gpt-3.5-turbo"


But I encounter a new one:


(base) sensen@sensen-Zenbook-UX425QA-UM425QA:~/OS-Copilot$ python quick_start.py Task: Your task is: Copy any text file located in the working_dir/document directory that contains the word 'agent' to a new folder named 'agents' Operating System Version: Ubuntu 24.04 LTS api call failed: 'FridayPlanner' object has no attribute 'llm' The task list obtained after planning is: None

sensen02 commented 1 month ago

谢谢你的提示,我做了三处改动: 1)(base_modeule.py) class BaseModule: def init(self): """ Initializes a new instance of BaseModule with default values for its attributes. """ self.llm=OpenAI() ''' if MODEL_TYPE == "OpenAI": self.llm = OpenAI() '''
2)(toolmanager.py)    embedding_function = OpenAIEmbeddings( openai_api_key="_", openai_organization="__", )

    '''
    if EMBED_MODEL_TYPE == "OpenAI":
        embedding_function = OpenAIEmbeddings(
            openai_api_key=OPENAI_API_KEY,
            openai_organization=OPENAI_ORGANIZATION,
        )
    elif EMBED_MODEL_TYPE == "OLLAMA":
        embedding_function = OllamaEmbeddings(model=EMBED_MODEL_NAME)
    '''

(由于我只用openai,所以我删除了这处判断) 3)上次不小心把api key复制到github里了,又注册了个账号继续白漂chatgpt :) ———————————————————————————————————————————————— 上一次提示的 “llm” bug 没了,但是OpenAI返回了错误提示: (base) sensen@sensen-Zenbook-UX425QA-UM425QA:~/OS-Copilot$ python quick_start.py Task: Your task is: Copy any text file located in the working_dir/document directory that contains the word 'agent' to a new folder named 'agents' Operating System Version: Ubuntu 24.04 LTS api call failed: The api_key client option must be set either by passing api_key to the client or by setting the OPENAI_API_KEY environment variable The task list obtained after planning is: None

heroding77 commented 1 month ago

You only need to follow my instructions to make the modifications. Making changes to other files could lead to more unknown errors.

sensen02 commented 1 month ago

I undo the changes I made last time, and make the following change in .env.template :

MODEL_NAME="gpt-3.5-turbo-0125" EMBED_MODEL_TYPE="OpenAI" # if use the gpt series (OpenAI), lamma series (LLAMA)

but this will lead to the same result:


Your task is: Copy any text file located in the working_dir/document directory that contains the word 'agent' to a new folder named 'agents' Operating System Version: Ubuntu 24.04 LTS api call failed: 'FridayPlanner' object has no attribute 'llm' The task list obtained after planning is: None


I think the problem is in base_module.py

    if MODEL_TYPE == "OpenAI":
        self.llm = OpenAI()
sensen02 commented 1 month ago

wait,what I changed is .env.template instead of .env_template

heroding77 commented 1 month ago

Your change is wrong, you should change .env_template to .env.

sensen02 commented 1 month ago

I changed the .env to: _____-- MODEL_NAME="gpt-3.5-turbo-0125" EMBED_MODEL_TYPE="OpenAI" # if use the gpt series (OpenAI), lamma series (LLAMA) OPENAI_APIKEY="____" OPENAI_ORGANIZATION="org-8KurHM3kAoXGlGxsCA3Qi30i" API_BASE_URL="http://127.0.0.1:8079" OPENAI_BASE_URL="" BING_SUBSCRIPTION_KEY="" BING_SEARCH_URL="https://api.bing.microsoft.com/v7.0/search" WOLFRAMALPHA_APP_ID="" ___- and the output is:

Your task is: Copy any text file located in the working_dir/document directory that contains the word 'agent' to a new folder named 'agents' Operating System Version: Ubuntu 24.04 LTS api call failed: 'str' object has no attribute 'chat' The task list obtained after planning is: None

heroding77 commented 1 month ago

We have updated the code and tested it without any issues. Please pull the new code and try again. (We recommend pulling the new code rather than overwriting your current code.)

If you are accessing OpenAI using a VPN, you might try uncommenting the relevant sections in the .env file before running it.

Best regards!