Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,6 @@ config.yml
gpt4_config.yml
XAgentWeb/pnpm-lock.yaml
XAgentWeb/pnpm-lock.yaml

.venv/
venv/
2 changes: 2 additions & 0 deletions XAgent/ai_functions/request/openai.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ def chatcompletion_request(**kwargs):
)
try:
completions = client.chat.completions.create(**chatcompletion_kwargs)
# response = json.loads(completions.model_dump_json())
response = completions.model_dump()
if response["choices"][0]["finish_reason"] == "length":
raise BadRequestError(
Expand Down Expand Up @@ -204,6 +205,7 @@ def chatcompletion_request(**kwargs):
chatcompletion_kwargs.update(kwargs)
chatcompletion_kwargs.pop("schema_error_retry", None)
completions = client.chat.completions.create(**chatcompletion_kwargs)
# response = json.loads(completions.model_dump_json())
response = completions.model_dump()
else:
raise e
Expand Down
19 changes: 11 additions & 8 deletions XAgent/function_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,14 +164,17 @@ def long_result_summary(self, command: dict, result):
'parse_web_text', webpage=result[:8096], prompt=command['arguments']['goals_to_browse'])
result['useful_hyperlinks'] = result['useful_hyperlinks'][:3]
if command['name'] == 'WebEnv_search_and_browse':
with ThreadPoolExecutor(max_workers=len(result)) as pool:
f = []
for ret in result:
f.append(pool.submit(function_manager, 'parse_web_text',
webpage=ret['page'][:8096], prompt=command['arguments']['goals_to_browse']))
for ret, thd in zip(result, f):
ret['page'] = thd.result()
ret['page']['useful_hyperlinks'] = ret['page']['useful_hyperlinks'][:3]
# --- START MODIFICATION ---
# Add a check to handle cases where the search returns no results.
if len(result) > 0:
with ThreadPoolExecutor(max_workers=len(result)) as pool:
f = []
for ret in result:
f.append(pool.submit(function_manager, 'parse_web_text',
webpage=ret['page'][:8096], prompt=command['arguments']['goals_to_browse']))
for ret, thd in zip(result, f):
ret['page'] = thd.result()
ret['page']['useful_hyperlinks'] = ret['page']['useful_hyperlinks'][:3]

if isinstance(result, str) and len(result) > 2000:
# need to summarize
Expand Down
2 changes: 1 addition & 1 deletion XAgent/workflow/plan_exec.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ def initial_plan_generation(self, agent_dispatcher):
functions=[split_functions],
)

subtasks = json5.loads(new_message["function_call"]["arguments"])
subtasks = new_message["function_call"]["arguments"]

for subtask_item in subtasks["subtasks"]:
subplan = plan_function_output_parser(subtask_item)
Expand Down
2 changes: 1 addition & 1 deletion XAgent/workflow/reflection.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,6 @@ def get_posterior_knowledge(all_plan: Plan,
arguments=function_manager.get_function_schema('generate_posterior_knowledge')['parameters']
)

data = json5.loads(new_message["arguments"])
data = new_message["arguments"]

return data
46 changes: 18 additions & 28 deletions assets/config.yml
Original file line number Diff line number Diff line change
@@ -1,36 +1,26 @@
# ====================================================================
# THIS IS THE CORRECTED AND SIMPLIFIED CONFIG FILE
# ====================================================================

api_keys:
gpt-3.5-turbo-16k:
- api_key: sk-xxxxx
api_base: https://example.com
api_type: azure
api_version: 2023-07-01-preview
engine: GPT-35-Turbo-16k
# you can use any kwargs supported by openai.ChatCompletion here
- api_key: sk-xxxxx
organization: org-xxxxxx
model: gpt-3.5-turbo-16k
gpt-4:
- api_key: sk-xxxxx
organization: org-xxxxx
model: gpt-4
- api_key: sk-xxxxx
organization: org-xxxxxx
model: gpt-4
gpt-4-32k:
- api_key: sk-xxxxx
organization: org-xxxxx
model: gpt-4-32k
- api_key: sk-xxxxx
organization: org-xxxxxx
model: gpt-4-32k


default_request_type: openai # or xagent
# We will only define the gpt-4 model, which your key should have access to.
gpt-4:
# PASTE YOUR FULL, VALID OPENAI API KEY IN THE LINE BELOW
- api_key: "sk-proj-8Hs"
model: "gpt-4"

# Set the default request type to openai
default_request_type: openai

# Set the default model to gpt-4, which we know you have access to.
# THIS IS THE MOST IMPORTANT FIX.
default_completion_kwargs:
model: gpt-4-32k
model: "gpt-4"
temperature: 0.2
request_timeout: 60

# --- The rest of the settings are correct and can be left as is ---

enable_summary: true
summary:
single_action_max_length: 2048
Expand Down
21 changes: 11 additions & 10 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,24 +63,25 @@ services:
xagent-redis:
condition: service_healthy

# --- ADD THIS NEW, IMPROVED BLOCK ---
xagent-mysql:
image: mysql
command:
- --default-authentication-plugin=caching_sha2_password
- --character-set-server=utf8mb4
- --collation-server=utf8mb4_unicode_ci
image: mysql/mysql-server:latest
container_name: xagent-mysql
platform: linux/amd64
environment:
MYSQL_ROOT_PASSWORD: xagent
MYSQL_DATABASE: xagent
MYSQL_ROOT_HOST: '%'
ports:
- "3306:3306"
volumes:
- ./XAgentServer/database/sql:/docker-entrypoint-initdb.d
healthcheck:
# test: [ "CMD", "mysqladmin","ping", "-h", "localhost" ]
test: ["CMD-SHELL", "mysql -h localhost -u root -pxagent -e 'SELECT 1'"]
#interval: 10s
timeout: 20s
retries: 20
test: ["CMD", "mysqladmin" ,"ping", "-h", "localhost", "-u", "root", "-pxagent"]
interval: 10s
timeout: 10s
retries: 10


xagent-redis:
image: redis
Expand Down
6 changes: 3 additions & 3 deletions dockerfiles/ToolServerNode/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ WORKDIR /app

RUN apt-get update

RUN apt update && apt install -y build-essential make openjdk-17-jdk-headless curl docker.io docker-compose psmisc sudo
RUN apt update && apt install -y build-essential make openjdk-21-jre-headless curl docker.io docker-compose psmisc sudo

RUN pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
# RUN pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple

RUN pip install playwright && playwright install chromium && playwright install-deps
RUN pip install playwright && playwright install chromium && playwright install-deps || true

COPY ToolServer/ToolServerNode/requirements.txt .

Expand Down
6 changes: 4 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ tiktoken
tqdm
uvicorn
json5
openai
python-dotenv
sqlalchemy
tenacity
Expand All @@ -28,4 +27,7 @@ pinecone-client
websockets
cryptography
inputimeout
pytest
pytest
pinecone
openai
httpx