Code Monkey home page Code Monkey logo

ailice's People

Contributors

eltociear avatar stevenlu137 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ailice's Issues

Not actually lightweight ;)

The tagline of AIlice is 'lightweight AI agent', and while the code itself is brilliantly minimal, the ailice virtual environment took up 5.8GB of space on my hard drive.

The biggest contributors to the size are the nvidia package at 2.8GB and torch at 1.6GB.

Would it be possible to not depend on these packages, or to make the dependencies optional?

Problems with ailice calling the model after installing it through lm studio

(AIlice) PS G:\AIlice> ailice_main --modelID=lm-studio:Nexesenex/MIstral-QUantized-70b_Miqu-1-70b-iMat.GGUF --prompt="main" --contextWindowRatio=0.5
Encountered an exception, AIlice is exiting: 'lm-studio'
  File "G:\AIlice\ailice\AIliceMain.py", line 123, in main
    mainLoop(**kwargs)
  File "G:\AIlice\ailice\AIliceMain.py", line 38, in mainLoop
    config.Initialize(modelID = modelID)
  File "G:\AIlice\ailice\common\AConfig.py", line 125, in Initialize
    needAPIKey = ("apikey" in self.models[modelType] and (self.models[modelType]["apikey"] is None))

Recommended Python Version?

First off, thank you for creating this! I've been playing with other agent systems, and found AIlice to be quite interesting.

Is there a recommended python version I should be running AIlice in?

Currently running AIlice on a NUC running ubuntu 23.10 (CPU only, 32GB RAM) on python 3.11.7. Previously rubbing on the same machine but with python 3.10.6

Installation path

I would like to know where the default installation path for the weight model is downloaded to

The code AIlice wrote always have invalid syntax.

ASSISTANT_api_requestor:  Apologies for the error in my previous response. Here's the corrected version of Python code:

```!PYTHON<!|
import requests

post_data = '{"token": "thisisatoken"}'
url = "http://****/get_cur_tasks"

response = requests.post(url, json=post_data)

if response.status_code == 200:
    result_json = response.json()
else:
    error_message = f"POST request failed with status code: {response.status_code}"
    result_json = {"error": error_message}

# Ensure result_json is stringified before assigning to a variable
result_json_str = str(result_json)

# Properly store the result as a string
!VAR<!|"post_response", result_json_str|!>;
```
SYSTEM_api_requestor:  PYTHON_RESULT=[  File "/tmp/tmpk8yktbgk", line 19
    !VAR<!|"post_response", result_json_str
    ^
SyntaxError: invalid syntax

Execution completed.

]

ASSISTANT_api_requestor:  I apologize for the mistake in my previous code. Here's the corrected Python snippet:

```!PYTHON<!|
import requests

post_data = '{"token": "thisisatoken"}'
url = "http://****/get_cur_tasks"

response = requests.post(url, json=post_data)

if response.status_code == 200:
    result_json = response.json()
else:
    error_message = f"POST request failed with status code: {response.status_code}"
    result_json = {"error": error_message}

# Stringify the JSON object and store it in a variable
result_json_str = str(result_json)

# Properly save the stringified JSON to a variable using the correct syntax
!VAR <!| "post_response", result_json_str |!>;
```
SYSTEM_api_requestor:  PYTHON_RESULT=[  File "/tmp/tmpzl7x9snh", line 19
    !VAR <!| "post_response", result_json_str 
    ^
SyntaxError: invalid syntax

Execution completed.

]

I think the !VAR <!| "post_response", result_json_str is a command to start a agent, but looks like execute as a python code.

Speech.PrepareModel not downloading voice model

When starting AIlice (both main and web) with the --speechOn flag, I'm getting this error:

Command used:

$ ailice_main --modelID=lm-server:llava --prompt="main" --contextWindowRatio=0.5 --speechOn

Result (truncated):

...
The speech module is preparing speech recognition and TTS models, which may include the work of downloading weight data, so it may take a long time.
Encountered an exception, AIlice is exiting: An error happened while trying to locate the files on the Hub and we cannot find the appropriate snapshot folder for the specified revision on the local disk. Please check your internet connection and try again.
  File "/home/user/ailice/AIliceMain.py", line 104, in main
    mainLoop(**kwargs)
  File "/home/user/ailice/AIliceMain.py", line 56, in mainLoop
    speech.PrepareModel()
  File "/home/user/ailice/common/lightRPC.py", line 102, in methodTemplate
    return self.RemoteCall(methodName,args,kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/ailice/common/lightRPC.py", line 129, in RemoteCall
    raise ret["exception"]```

I am running using LM Studio to run my model (trinity v1.2 7B for testing), and it works fine without speech.

Cannot build Docker container using provided Dockerfile

Hey there,
when I run the Dockerfile using
docker build -t env4scripter .
as explained in the documentation I get the following error.

 > [10/10] RUN pip3 install pyzmq:
0.580 error: externally-managed-environment
0.580
0.580 × This environment is externally managed
0.580 ╰─> To install Python packages system-wide, try apt install
0.580     python3-xyz, where xyz is the package you are trying to
0.580     install.
0.580
0.580     If you wish to install a non-Debian-packaged Python package,
0.580     create a virtual environment using python3 -m venv path/to/venv.
0.580     Then use path/to/venv/bin/python and path/to/venv/bin/pip. Make
0.580     sure you have python3-full installed.
0.580
0.580     If you wish to install a non-Debian packaged Python application,
0.580     it may be easiest to use pipx install xyz, which will manage a
0.580     virtual environment for you. Make sure you have pipx installed.
0.580
0.580     See /usr/share/doc/python3.12/README.venv for more information.
0.580
0.580 note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages.
0.580 hint: See PEP 668 for the detailed specification.
------
Dockerfile:14
--------------------
  12 |     COPY ailice/modules/AScrollablePage.py /scripter/ailice/modules/AScrollablePage.py
  13 |
  14 | >>> RUN pip3 install pyzmq
  15 |
  16 |     EXPOSE 59000-59200
--------------------
ERROR: failed to solve: process "/bin/sh -c pip3 install pyzmq" did not complete successfully: exit code: 1

I managed to bypass this issue by creating a virtual environment.

However, I encountered several issues even after creating a working Docker container.

First of all, several Python packages are missing now, like numpy.
Furthermore, after installing those missing libraries, access to the AIlice modules is not working either and needs to be fixed.
So far, I have not found a solution to this issue.

Thus, I'm not able to use the dockerized method right now.

Cannot install on Windows

I create new clean Python environment.
Then the following commands all work

git clone https://github.com/myshell-ai/AIlice.git
cd AIlice
pip install -e .

But when I try the next pip install -e .[speech] it fails with these errors...
fail.txt

Any ideas? Thanks.

502 Network Error

(base) PS G:\AIlice> conda activate AIlice
(AIlice) PS G:\AIlice> ailice_web --modelID=lm-studio:TheBloke/Mistral-7B-OpenOrca-GGUF/mistral-7b-openorca.Q5_K_M.gguf --prompt="main" --contextWindowRatio=0.5
config.json is located at C:\Users\29099\AppData\Local\Steven Lu\ailice
In order to simplify installation and usage, we have set local execution as the default behavior, which means AI has complete control over the local environment. To prevent irreversible losses due to potential AI errors, you may consider one of the following two methods: the first one, run AIlice in a virtual machine; the second one, install Docker, use the provided Dockerfile to build an image and container, and modify the relevant configurations in config.json. For detailed instructions, please refer to the documentation.
storage  started.
browser  started.
arxiv  started.
google  started.
duckduckgo  started.
scripter  started.
files  started.
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
We now start the vector database. Note that this may include downloading the model weights, so it may take some time.
Vector database has been started. returned msg: vector database has been switched to a non-persistent version. tokenizer: bert-base-uncased, model: nomic-ai/nomic-embed-text-v1
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Running on local URL:  http://127.0.0.1:7860

To create a public link, set `share=True` in `launch()`.
ASSISTANT_AIlice:  Exception in thread Thread-6:
Traceback (most recent call last):
  File "C:\Program Files\Python310\lib\threading.py", line 1016, in _bootstrap_inner
    self.run()
  File "C:\Program Files\Python310\lib\threading.py", line 953, in run
    self._target(*self._args, **self._kwargs)
  File "G:\AIlice\ailice\core\AProcessor.py", line 83, in __call__
    ret = self.llm.Generate(prompt, proc=partial(self.outputCB, "ASSISTANT_" + self.name), endchecker=self.interpreter.EndChecker, temperature = config.temperature)
  File "G:\AIlice\ailice\core\llm\AModelChatGPT.py", line 26, in Generate
    for chunk in self.client.chat.completions.create(model=self.modelName,
  File "C:\Users\29099\AppData\Roaming\Python\Python310\site-packages\openai\_utils\_utils.py", line 275, in wrapper
    return func(*args, **kwargs)
  File "C:\Users\29099\AppData\Roaming\Python\Python310\site-packages\openai\resources\chat\completions.py", line 663, in create
    return self._post(
  File "C:\Users\29099\AppData\Roaming\Python\Python310\site-packages\openai\_base_client.py", line 1200, in post
    return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls))
  File "C:\Users\29099\AppData\Roaming\Python\Python310\site-packages\openai\_base_client.py", line 889, in request
    return self._request(
  File "C:\Users\29099\AppData\Roaming\Python\Python310\site-packages\openai\_base_client.py", line 965, in _request
    return self._retry_request(
  File "C:\Users\29099\AppData\Roaming\Python\Python310\site-packages\openai\_base_client.py", line 1013, in _retry_request
    return self._request(
  File "C:\Users\29099\AppData\Roaming\Python\Python310\site-packages\openai\_base_client.py", line 965, in _request
    return self._retry_request(
  File "C:\Users\29099\AppData\Roaming\Python\Python310\site-packages\openai\_base_client.py", line 1013, in _retry_request
    return self._request(
  File "C:\Users\29099\AppData\Roaming\Python\Python310\site-packages\openai\_base_client.py", line 980, in _request
    raise self._make_status_error_from_response(err.response) from None
openai.InternalServerError: Error code: 502

offline huggingface

Because the region is restricted, I would like to ask how to load the model on hugging face offline?

image

Errors running on mac

On Mac M1 Max OSX 14.2.1 with python 3.11.

when running with parameters:
ailice_main --modelID=hf:Open-Orca/Mistral-7B-OpenOrca --prompt="main" --quantization=8bit --contextWindowRatio=0.6
getting error because of quantization parameter
Error:
Encountered an exception, AIlice is exiting: No GPU found. A GPU is needed for quantization.

if not torch.cuda.is_available():
    raise RuntimeError("No GPU found. A GPU is needed for quantization.")

which expected because M1 do not have cuda

without quantization parameter getting other error:
Encountered an exception, AIlice is exiting: The current `device_map` had weights offloaded to the disk. Please provide an `offload_folder` for them. Alternatively, make sure you have `safetensors` installed if the model you are using offers the weights in this format.

@stevenlu137 what are you thought of using external local running LLM with LM Studio or ollama and implement AModelLocal.py ?
it can run all the same hugging face models

Adding ollama support fails

I tried to include ollama model into /home/user/.config/ailice/config.json as explained in the readme:

(env) user@debian-ai:~/AIlice$ ailice_main --modelID=ollama:llama2:latest --prompt="main"
config.json is located at /home/user/.config/ailice

In order to simplify installation and usage, we have set local execution as the default behavior, which means AI has complete control over the local environment. To prevent irreversible losses due to potential AI errors, you may consider one of the following two methods: the first one, run AIlice in a virtual machine; the second one, install Docker, use the provided Dockerfile to build an image and container, and modify the relevant configurations in config.json. For detailed instructions, please refer to the documentation.
killing proc with PID 27298
killing proc with PID 27299
killing proc with PID 27302
killing proc with PID 27303
killing proc with PID 27305
killing proc with PID 27308
killing proc with PID 27309
storage  started.
browser  started.
arxiv  started.
google  started.
duckduckgo  started.
scripter  started.
computer  started.
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
We now start the vector database. Note that this may include downloading the model weights, so it may take some time.
Vector database has been started. returned msg: vector database has been switched to a non-persistent version. tokenizer: bert-base-uncased, model: nomic-ai/nomic-embed-text-v1
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Encountered an exception, AIlice is exiting: 'llama2:latest'
  File "/home/user/AIlice/ailice/AIliceMain.py", line 126, in main
    mainLoop(**kwargs)
  File "/home/user/AIlice/ailice/AIliceMain.py", line 91, in mainLoop
    llmPool.Init([modelID])
  File "/home/user/AIlice/ailice/core/llm/ALLMPool.py", line 21, in Init
    self.pool[id] = MODEL_WRAPPER_MAP[config.models[modelType]["modelWrapper"]](modelType=modelType, modelName=modelName)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/AIlice/ailice/core/llm/AModelChatGPT.py", line 16, in __init__
    modelCfg = config.models[modelType]["modelList"][modelName]
               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^

the config.json looks like this:

 {
  "maxMemory": {},
  "quantization": null,
  "models": {
    "hf": {...},
    "peft": {...},
    "oai": {...},
    "groq": {...},
    "mistral": {...},
    "ollama": {
      "modelWrapper": "AModelChatGPT",
      "apikey": "fakekey",
      "baseURL": "http://localhost:4000",
      "modelList": {
        "ollama/llama2:latest": {
          "contextWindow": 8192,
          "systemAsUser": false
        }
      }
    },
    "anthropic": {...}
  },
  "temperature": 0.0,
  "flashAttention2": false,
  "speechOn": false,
  "contextWindowRatio": 0.6,
  "services": {...}
}

Agents looping at task execution

I have an issue with agents looping infinitely at the lower level task execution. They can execute the task successfully but instead of passing the result up, the LLM get's basically the same request again.
I'm using local model via OpenAI compatible API using text-generation-webui (oobabooga), so I suspect it might be related to the issue. I tried different models and tasks and the problem is always the same.

I've added logs (LLM + AIlice output) from very simple task (listing files in the current directory) using nous-hermes-2-mixtral-8x7b-dpo model.
Any hints how to resolve that would be appreciated.

AIlice log

storage started.
browser started.
arxiv started.
google started.
duckduckgo started.
scripter started.
USER: List all files in the current dir
ASSISTANT_AIlice: This is a task that requires file system access and should be handled by a coder-proxy agent. I will forward it to a coder-proxy agent: !CALL<!|"coder-proxy", "file_system_agent", "List all files in the current dir."|!>
ASSISTANT_file_system_agent: !BASH<!|ls|!>
SYSTEM_file_system_agent: BASH_RESULT=[ailice
ailice.egg-info
AIlice.png
Dockerfile
IACT.jpg
LICENSE
log
README.md
setup.py
venv

Execution completed.

]

ASSISTANT_file_system_agent: !BASH<!|ls|!>
SYSTEM_file_system_agent: BASH_RESULT=[ailice
ailice.egg-info
AIlice.png
Dockerfile
IACT.jpg
LICENSE
log
README.md
setup.py
venv

Execution completed.

]

ASSISTANT_file_system_agent: !BASH<!|ls|!>
SYSTEM_file_system_agent: BASH_RESULT=[ailice
ailice.egg-info
AIlice.png
Dockerfile
IACT.jpg
LICENSE
log
README.md
setup.py
venv

Execution completed.

]

LLM log 23:24:02-028478 INFO PROMPT= <|im_start|>system

Your responsibility is to communicate with users, understand their needs, and select an appropriate agent to forward the questions or tasks presented by the user. Afterward, you need to organize the results returned by the agent and reply to the user. The agent may ask the user some questions, and you will need to facilitate the communication between them.
When calling an agent, it is important to note that the working language of the agent is English. If the user is communicating in a language other than English, you will need to provide translation between the agent and the user.
If you're not sure an agent type is suitable for a task, create one and ask it first.
You can create and communicate with AI agents using textual function calls. These agents have the ability to solve different types of problems and have different abilities to interact with the external environment.
Always forward tasks to agents with appropriate capabilities. Especially don't do coding tasks yourself.
In order to reduce symbol conflicts, we use special symbols "<!|","|!>" as replacements for commonly used parentheses in function call syntax. Please pay special attention to the syntax when generating function call statements.
The agent can only see the information you send to it through "CALL" function, they can't see anything else you output. So, please provide agents with thorough task descriptions or additional information; don't cut corners.
"ext-modules" is a type of module that implements specific interfaces, defining a set of new function calls. Once loaded, you will be able to use the functions defined within it. For user requests to build or load ext-modules, please forward them to coder-proxy.

#Use the following function to create or communicate with an AI agent:
CALL<!|agentType: str, agentName: str, msg: str|!>

  • agentType: A string used to specify the type of AI agent. It can be of the following types:
    1. "researcher", Conduct an internet investigation on a particular topic or gather data. It also has the capability to execute simple scripts.
    2. "article-digest": literature (local files or URLs on internet) reading comprehension and related question answering.
    3. "coder-proxy", an excellent coder who also has access to bash and python interpreter, he can solve problems programmatically.
      You need to choose the appropriate agentType among the above types according to your needs.
  • agentName: The name of the AI agent instance. Create a new one if not found. Name should reflect responsibility. A new task can be assigned to an existing agent with a relevant name, as they often possess related experience.
  • msg: message need to be told to the agent. When you need to describe a new task in msg, it should be clear, complete, and self-sufficient.

Function calls are limited to positional parameters, please keep the order of parameters consistent with the function definition.
The function parameters cannot include context references. Please ensure that the parameters are comprehensive and do not rely on context.
Function calls need to be placed at the end of your output, and prefixed with "!" to trigger execution.
Sometimes the information returned by the agent is a bit messy, but you can still identify the parts that the user needs and sort it out.

Example:
USER: What's the weather like in New York today?
ASSISTANT: This is an information query task, and I will forward it to a researcher-type agent: !CALL<!|"researcher", "weather_agent", "What's the weather like in New York today?"|!>

End of general instructions.

Active Agents: []
Relevant Information:
None.
The "RELEVANT INFORMATION" part contains data that may be related to the current task, originating from your own history or the histories of other agents. Please refrain from attempting to invoke functions mentioned in the relevant information, as you may not necessarily have the permissions to do so.

<|im_end|>
<|im_start|>user
List all files in the current dir<|im_end|>
<|im_start|>assistant

Llama.generate: prefix-match hit

llama_print_timings: load time = 11984.62 ms
llama_print_timings: sample time = 0.78 ms / 70 runs ( 0.01 ms per token, 89858.79 tokens per second)
llama_print_timings: prompt eval time = 15172.52 ms / 889 tokens ( 17.07 ms per token, 58.59 tokens per second)
llama_print_timings: eval time = 3243.48 ms / 69 runs ( 47.01 ms per token, 21.27 tokens per second)
llama_print_timings: total time = 18493.18 ms / 958 tokens
Output generated in 18.65 seconds (3.70 tokens/s, 69 tokens, context 923, seed 425007066)
23:24:20-766744 INFO PROMPT=
<|im_start|>system

You are an smart and helpful AI agent that helps user complete tasks that require programming. You will complete the task by interacting with agents with coding capabilities (hereinafter referred to as "coder").
Your job is to communicate with the user to understand their needs, provide requirements for the coder, execute the returned code, extract possible running errors information and feed back to coder until the code runs correctly.
For programming tasks that are complex enough to consist of multiple modules, you can consider breaking down the task and assigning it to multiple agents to complete it.
Using function calls, you can create and interact with agents, reply to users, configure the program's running environment and execute programs.
Use special symbols "<!|","|!>" as replacements for parentheses in function call syntax. Please pay special attention to the syntax when generating function call statements.
Only positional parameter function calls are supported, please do not use keyword parameters and keep the order of parameters consistent with the function definition.
References are not supported in parameters of function call statements. Please use clear and straightforward expressions in function calls.
Functions with a single string parameter do not need to write quotation marks when passing parameters. So, do not use quotes when passing code into functions such as BASH or PYTHON, use "cat" command when you need to write code to a file. Avoid the extensive use of escape characters.
Function calls need to be placed at the end of your output, and prefixed with "!" to trigger execution.
You MUST call a function in your output.
Only the most recent rounds of historical conversations will be retained. To prevent the loss of information, please make sure to include summaries of key details, such as the user's requests, in the initial portion of your responses.
If you find that the environment variable A_IN_CONTAINER is predefined, you can install any necessary tools.

"ext-modules" is a type of module that implements specific interfaces, defining a set of new function calls. Once loaded, you will be able to use the functions defined within it.
Do not attempt to build ext-modules unless explicitly requested by the user. It adds complexity to the debugging process.
Please note that for ext-modules, you need to store the code in the current directory before running it, otherwise there will be an error that the python package cannot be found. You also need to run them as separate processes, or you will be stuck.

Your workflow follows these steps (The details of functions such as CALL/PYTHON/BASH/RESPOND will be given below, and for the sake of simplicity in this context, the term 'coder' is used to encompass both 'coder' and 'module-coder'):

  1. Receive user requirements, understand and engage with the user as needed to enhance understanding(use RESPOND).
  2. Choose or create a suitable coder agent, provide a clear and comprehensive description of the requirements to it(use CALL).
  3. Once coder returns the code, your responsibilities include:
    Initial verification of whether the solution provided by the coder meets the requirements. If not, make modification requests to the coder.
    Install the necessary dependencies following coder's instructions and execute the code (use BASH and PYTHON).
    In case of error, send detailed error information to coder for code improvement (use CALL), the message include error and problematic lines of code (for the python case, the code is saved into a temp file like "/tmp/tmp*.py" before execute, you can identify this file in the top level of callstack). Go back to the beginning of step 3 and iterate until success.
    During the iteration, if coder requires knowledge about specific libraries, query relevant knowledge through the "researcher" type agent (use CALL).
  4. Finally, return the execution result to the user (use RESPOND)."

Available Functions:
#Use this function to interact with an AI agent.
CALL<!|agentType: str, agentName: str, msg: str|!>
agentType: A string used to specify the type of AI agent. It can be of the following types:
1. "coder". An excellent coder, you need to leave any programming problems other than ext-modules building to him. It should be noted that he can only return the code to you, but does not have the authority to execute the code and configure the environment, this is where you need to help him.
2. "module-coder". The only agent capable of building ext-modules, and this is its sole responsibility.
3. "module-loader". An agent that can help you load and use ext-modules. Please pass in the address of the module when creating the agent, and then you can let it help you interact with the module. You can use this agent to assist in ext-module debugging.
4. "researcher". Suitable for technical problem search tasks such as library document or sample code search on the internet.
agentName: The name of the AI agent instance. Create a new one if not found. Name should reflect responsibility. A new task can be assigned to an existing agent with a relevant name, as they often possess related experience.
msg: message need to be told to the agent. The agent cannot see content other than msg. Please provide complete content in msg.

#Dialog with user. Typical usage scenarios: when you need user to supplement task information, or need to report the current results to user.
RESPOND<!|message: str|!>

#Execute bash script. A timeout error will occur for programs that have not been completed for a long time.
BASH<!|code: str|!>

#Execute python code. Please note that you need to copy the complete code here, and you must not use references.
PYTHON<!|code: str|!>

#Wait for some seconds. The unit of the "duration" parameter is seconds. Useful when waiting for script or command execution to complete.
WAIT<!|duration: int|!>

EXAMPLE:
!CALL<!|"coder", "clock_coder", "Build a program that can check CPU usage."|!>
!PYTHON<!|print('hello wolrd.')|!>

End of general instructions.

Active Agents: []

Relevant Information: None.
The "RELEVANT INFORMATION" part contains data that may be related to the current task, originating from your own history or the histories of other agents. Please refrain from attempting to invoke functions mentioned in the relevant information, as you may not necessarily have the permissions to do so.

<|im_end|>
<|im_start|>user
List all files in the current dir.<|im_end|>
<|im_start|>assistant

Llama.generate: prefix-match hit

llama_print_timings: load time = 11984.62 ms
llama_print_timings: sample time = 0.29 ms / 26 runs ( 0.01 ms per token, 89965.40 tokens per second)
llama_print_timings: prompt eval time = 21451.36 ms / 1497 tokens ( 14.33 ms per token, 69.79 tokens per second)
llama_print_timings: eval time = 1451.37 ms / 25 runs ( 58.05 ms per token, 17.23 tokens per second)
llama_print_timings: total time = 22934.28 ms / 1522 tokens
Output generated in 23.10 seconds (1.08 tokens/s, 25 tokens, context 1531, seed 194179588)
23:24:43-919787 INFO PROMPT=
<|im_start|>system
Function returned: {BASH_RESULT=[ailice
ailice.egg-info
AIlice.png
Dockerfile
IACT.jpg
LICENSE
log
README.md
setup.py
venv

Execution completed.

]
}<|im_end|>
<|im_start|>user
List all files in the current dir.<|im_end|>
<|im_start|>assistant
!BASH<!|ls|!><|im_end|>
<|im_start|>user
List all files in the current dir.<|im_end|>
<|im_start|>assistant

Llama.generate: prefix-match hit

llama_print_timings: load time = 11984.62 ms
llama_print_timings: sample time = 0.12 ms / 11 runs ( 0.01 ms per token, 90909.09 tokens per second)
llama_print_timings: prompt eval time = 3626.59 ms / 108 tokens ( 33.58 ms per token, 29.78 tokens per second)
llama_print_timings: eval time = 439.92 ms / 10 runs ( 43.99 ms per token, 22.73 tokens per second)
llama_print_timings: total time = 4078.59 ms / 118 tokens
Output generated in 4.25 seconds (2.35 tokens/s, 10 tokens, context 163, seed 1374320967)
23:24:48-588522 INFO PROMPT=
<|im_start|>system
Function returned: {BASH_RESULT=[ailice
ailice.egg-info
AIlice.png
Dockerfile
IACT.jpg
LICENSE
log
README.md
setup.py
venv

Execution completed.

]
}<|im_end|>
<|im_start|>user
List all files in the current dir.<|im_end|>
<|im_start|>assistant
!BASH<!|ls|!><|im_end|>
<|im_start|>assistant
!BASH<!|ls|!><|im_end|>
<|im_start|>user
List all files in the current dir.<|im_end|>
<|im_start|>assistant

Llama.generate: prefix-match hit

llama_print_timings: load time = 11984.62 ms
llama_print_timings: sample time = 0.12 ms / 11 runs ( 0.01 ms per token, 90909.09 tokens per second)
llama_print_timings: prompt eval time = 2768.10 ms / 32 tokens ( 86.50 ms per token, 11.56 tokens per second)
llama_print_timings: eval time = 479.88 ms / 10 runs ( 47.99 ms per token, 20.84 tokens per second)
llama_print_timings: total time = 3259.56 ms / 42 tokens
Output generated in 3.42 seconds (2.92 tokens/s, 10 tokens, context 190, seed 1927657688)

AIlice start error

install through docker.

ailice_web --modelID=hf:openchat/openchat_3.5 --prompt="main" --quantization=8bit --contextWindowRatio=0.6                                   

config.json is located at /home/hakuju/.config/ailice/config.json
In order to simplify installation and usage, we have set local execution as the default behavior, which means AI has complete control over the local environment. To prevent irreversible losses due to potential AI errors, you may consider one of the following two methods: the first one, run AIlice in a virtual machine; the second one, install Docker, use the provided Dockerfile to build an image and container, and modify the relevant configurations in config.json. For detailed instructions, please refer to the documentation.
The port range of the ext-modules has been changed from 2005-2016 to 59000-59200. If you are using an old version, startup failure will occur after updating the code. Please modify the port number in config.json and rebuild the docker image.
kill: (1198047): 不允许的操作 // not allowed operation
kill: (1212154): 没有那个进程 //no such process
scripter  started.
Encountered an exception, AIlice is exiting: 'storage'
  File "/data/AIlice/ailice/AIliceWeb.py", line 96, in main
    mainLoop(**kwargs)
  File "/data/AIlice/ailice/AIliceWeb.py", line 42, in mainLoop
    clientPool.Init()
  File "/data/AIlice/ailice/common/ARemoteAccessors.py", line 10, in Init
    storage = config.services['storage']['addr']

config.json:

"maxMemory": {},
  "quantization": null,
  "openaiGPTKey": null,
  "temperature": 0.0,
  "flashAttention2": false,
  "speechOn": false,
  "contextWindowRatio": 0.6,
  "services": {
    "scripter": {
      "cmd": "docker start scripter",
      "addr": "tcp://127.0.0.1:59000"
    }
  }
}

cpu: arm64,
os: ubuntu 20.04

Prompt is not a vaild dict.

Well, it is hard for me to use the api from OpenAI. And My computer is not powerful enough to run these models locally.
So I wrote a file in core/llm/AModelQW.py to access the Qwen model from Internet. (I have much free tokens to use so I choose it.)

It works good when I use the command like "list the files in this folder".
But when I give a complex command like find the *.ppt files in my PC. And tell me where they are. Point the files which maybe the study materials.
It works fine for the first few steps. But after SYSTEM_system_command_agent return the python script and Instructions, the ASSISTANT_system_command_agent give a tuple as prompt. It makes error cause Qwen only accept a dict.
So, does the tuple is neccessary for AIlice? Should I do something to remove it, or it just a bug?

AModelQW.py

import os, json

from ailice.common.utils.ATextSpliter import sentences_split
from ailice.common.AConfig import config
from ailice.core.llm.AFormatter import AFormatterQW
from dashscope import Generation

class AModelQW():
    def __init__(self, modelName: str):
        
        self.tokenizer = None
        self.modelName = modelName
        # self.client = openai.OpenAI(api_key = config.openaiGPTKey)
        self.api_key = os.environ.get("QWEN_KEY")
        self.formatter = AFormatterQW(systemAsUser=True)
        # self.contextWindow = 6122
        self.contextWindow=6122*0.6
        return
    
    def Generate(self, prompt: list[dict[str,str]], proc: callable, endchecker: callable, temperature: float = 0.2) -&gt; str:
        # print("======&gt;this is a generate: ", prompt)
        proc(txt='', action='open')
        currentPosition = 0
        text = ""
        responses = Generation.call(model=Generation.Models.qwen_max,
                                    result_format='message',
                                    messages=prompt,
                                    incremental_output=True,
                                    stream=True)
        for chunk in responses:
            if chunk.status_code == 200:
                text += (chunk.output.choices[0]['message']['content'] or "")

                if endchecker(text):
                    break
                
                sentences = [x for x in sentences_split(text[currentPosition:])]
                if (2 &lt;= len(sentences)) and ("" != sentences[0].strip()):
                    proc(txt=sentences[0], action='append')
                    currentPosition += len(sentences[0])
            else:
                print(f"=====&gt;response error, chunk id {chunk.request_id}, chunk status_code {chunk.status_code}, chunk code {chunk.code}, chunk message {chunk.message}")
                print(prompt)
        proc(txt=text[currentPosition:], action='close')
        return text

prompt

([{'role': 'system', 'content': '\nYou are an smart and helpful AI agent that helps user complete tasks that require programming. You will complete the task by interacting with agents with coding capabilities (hereinafter referred to as "coder").\nYour job is to communicate with the user to understand their needs, provide requirements for the coder, execute the returned code, extract possible running errors information and feed back to coder until the code runs correctly.\nFor programming tasks that are complex enough to consist of multiple modules, you can consider breaking down the task and assigning it to multiple agents to complete it.\nUsing function calls, you can create and interact with agents, reply to users, configure the program\'s running environment and execute programs.\nUse special symbols "<!|","|!>" as replacements for parentheses in function call syntax. Please pay special attention to the syntax when generating function call statements.\nOnly positional parameter function calls are supported, please do not use keyword parameters and keep the order of parameters consistent with the function definition.\nReferences are not supported in parameters of function call statements. Please use clear and straightforward expressions in function calls.\nFunctions with a single string parameter do not need to write quotation marks when passing parameters. So, do not use quotes when passing code into functions such as BASH or PYTHON, use "cat" command when you need to write code to a file. Avoid the extensive use of escape characters.\nFunction calls need to be placed at the end of your output, and prefixed with "!" to trigger execution.\nYou MUST call a function in your output.\nOnly the most recent rounds of historical conversations will be retained. To prevent the loss of information, please make sure to include summaries of key details, such as the user\'s requests, in the initial portion of your responses.\nIf you find that the environment variable A_IN_CONTAINER is predefined, you can install any necessary tools.\n\n"ext-modules" is a type of module that implements specific interfaces, defining a set of new function calls. Once loaded, you will be able to use the functions defined within it.\nDo not attempt to build ext-modules unless explicitly requested by the user. It adds complexity to the debugging process.\nPlease note that for ext-modules, you need to store the code in the current directory before running it, otherwise there will be an error that the python package cannot be found. You also need to run them as separate processes, or you will be stuck.\n\nYour workflow follows these steps (The details of functions such as CALL/PYTHON/BASH/RESPOND will be given below, and for the sake of simplicity in this context, the term \'coder\' is used to encompass both \'coder\' and \'module-coder\'):\n1. Receive user requirements, understand and engage with the user as needed to enhance understanding(use RESPOND).\n2. Choose or create a suitable coder agent, provide a clear and comprehensive description of the requirements to it(use CALL).\n3. Once coder returns the code, your responsibilities include:\n    Initial verification of whether the solution provided by the coder meets the requirements. If not, make modification requests to the coder.\n    Install the necessary dependencies following coder\'s instructions and execute the code (use BASH and PYTHON).\n    In case of error, send detailed error information to coder for code improvement (use CALL), the message include error and problematic lines of code (for the python case, the code is saved into a temp file like "/tmp/tmp*.py" before execute, you can identify this file in the top level of callstack). Go back to the beginning of step 3 and iterate until success.\n    During the iteration, if coder requires knowledge about specific libraries, query relevant knowledge through the "researcher" type agent (use CALL).\n4. Finally, return the execution result to the user (use RESPOND)."\n\nAvailable Functions:\n#Use this function to interact with an AI agent.\nCALL<!|agentType: str, agentName: str, msg: str|!>\nagentType: A string used to specify the type of AI agent. It can be of the following types:\n    1. "coder". An excellent coder, you need to leave any programming problems other than ext-modules building to him. It should be noted that he can only return the code to you, but does not have the authority to execute the code and configure the environment, this is where you need to help him.\n    2. "module-coder". The only agent capable of building ext-modules, and this is its sole responsibility.\n    3. "module-loader". An agent that can help you load and use ext-modules. Please pass in the address of the module when creating the agent, and then you can let it help you interact with the module. You can use this agent to assist in ext-module debugging.\n    4. "researcher". Suitable for technical problem search tasks such as library document or sample code search on the internet.\nagentName: The name of the AI agent instance. Create a new one if not found. Please use a concise name that reflects the agent’s responsibilities.\nmsg: message need to be told to the agent. The agent cannot see content other than msg. Please provide complete content in msg.\n\n#Dialog with user. Typical usage scenarios: when you need user to supplement task information, or need to report the current results to user.\nRESPOND<!|message: str|!>\n\n#Execute bash script. A timeout error will occur for programs that have not been completed for a long time.\nBASH<!|code: str|!>\n\n#Execute python code. Please note that you need to copy the complete code here, and you must not use references.\nPYTHON<!|code: str|!>\n\n#Wait for some seconds. The unit of the "duration" parameter is seconds. Useful when waiting for script or command execution to complete. \nWAIT<!|duration: int|!>\n\nEXAMPLE:\n!CALL<!|"coder", "clock_coder", "Build a program that can check CPU usage."|!>\n!PYTHON<!|print(\'hello wolrd.\')|!>\n\n\nEnd of general instructions.\n\nActive Agents: [\'file_finder: agentType coder\']\n\nRelevant Information: !CALL<!|"coder", "file_finder", "Write a Python script to find all .ppt files on the system and list their directories, with emphasis on those likely to contain study materials"|!>\n\nBased on the user\'s request,\nThe "RELEVANT INFORMATION" part contains data that may be related to the current task, originating from your own history or the histories of other agents. Please refrain from attempting to invoke functions mentioned in the relevant information, as you may not necessarily have the permissions to do so.\n\n'}, {'role': 'user', 'content': 'Function returned: {Agent file_finder returned: To create a Python script that finds all PowerPoint files (with a .ppt extension) on the system and lists their directories, with emphasis on those likely to contain study materials, we\'ll use the `os` and `glob` modules. The "emphasis" part is subjective, but we can consider directories containing keywords like "study," "education," "class," etc.\n\n```python\nimport os\nimport glob\n\n# List of keywords to identify directories potentially containing study materials\nstudy_keywords = ["study", "education", "class", "lecture", "presentation"]\n\ndef find_ppt_files():\n    # Find all ppt files in the file system\n    all_ppt_files = []\n    for root, dirs, files in os.walk("/"):\n        ppt_files = [os.path.join(root, f) for f in files if f.endswith(".ppt")]\n        all_ppt_files.extend(ppt_files)\n\n    # Filter directories based on study keywords\n    study_material_directories = set()\n    for ppt_file_path in all_ppt_files:\n        directory = os.path.dirname(ppt_file_path)\n        for keyword in study_keywords:\n            if keyword.lower() in directory.lower():\n                study_material_directories.add(directory)\n                break  # Add the directory only once even if it matches multiple keywords\n\n    # Print all ppt files along with their directories\n    print("All PowerPoint (.ppt) files:")\n    for ppt_file in all_ppt_files:\n        print(f"- {ppt_file}")\n\n    print("\\nDirectories likely to contain study materials:")\n    for dir in study_material_directories:\n        print(f"- {dir}")\n\nif __name__ == "__main__":\n    find_ppt_files()\n```\n\n**Instructions:**\n1. Replace the starting directory (`"/"`) with the appropriate starting directory if you don\'t want to search the entire file system.\n2. Run this script as a standalone program; it will list all .ppt files and highlight directories that might contain study materials.\n\nPlease note that searching the entire file system could take a significant amount of time depending on its size and structure. This script does not check the content of the PowerPoint files, only the directory names.\n}'}], 2221)

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.