Compare commits
2 Commits
gitea
...
a4f092dbe1
| Author | SHA1 | Date | |
|---|---|---|---|
|
a4f092dbe1
|
|||
|
29b979a04b
|
32
.gitea/workflows/build.yaml
Normal file
32
.gitea/workflows/build.yaml
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
name: Build and Push Docker Image
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- dev
|
||||||
|
- gitea
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-and-push:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
|
- name: Login to Docker Registry
|
||||||
|
uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
registry: docker.gardel.top
|
||||||
|
username: ${{ secrets.DOCKER_USERNAME }}
|
||||||
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||||
|
- name: Build and Push Docker Image
|
||||||
|
uses: docker/build-push-action@v5
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
file: ./Dockerfile
|
||||||
|
push: true
|
||||||
|
tags: docker.gardel.top/gardel/mofox:dev
|
||||||
|
build-args: |
|
||||||
|
BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ')
|
||||||
|
VCS_REF=${{ github.sha }}
|
||||||
149
.github/workflows/docker-image.yml
vendored
149
.github/workflows/docker-image.yml
vendored
@@ -1,149 +0,0 @@
|
|||||||
name: Docker Build and Push
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- master
|
|
||||||
- dev
|
|
||||||
tags:
|
|
||||||
- "v*.*.*"
|
|
||||||
- "v*"
|
|
||||||
- "*.*.*"
|
|
||||||
- "*.*.*-*"
|
|
||||||
workflow_dispatch: # 允许手动触发工作流
|
|
||||||
|
|
||||||
# Workflow's jobs
|
|
||||||
jobs:
|
|
||||||
build-amd64:
|
|
||||||
name: Build AMD64 Image
|
|
||||||
runs-on: ubuntu-24.04
|
|
||||||
outputs:
|
|
||||||
digest: ${{ steps.build.outputs.digest }}
|
|
||||||
steps:
|
|
||||||
- name: Check out git repository
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
with:
|
|
||||||
fetch-depth: 0
|
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
|
||||||
uses: docker/setup-buildx-action@v3
|
|
||||||
with:
|
|
||||||
buildkitd-flags: --debug
|
|
||||||
|
|
||||||
# Log in docker hub
|
|
||||||
- name: Log in to Docker Hub
|
|
||||||
uses: docker/login-action@v3
|
|
||||||
with:
|
|
||||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
||||||
|
|
||||||
# Generate metadata for Docker images
|
|
||||||
- name: Docker meta
|
|
||||||
id: meta
|
|
||||||
uses: docker/metadata-action@v5
|
|
||||||
with:
|
|
||||||
images: ${{ secrets.DOCKERHUB_USERNAME }}/mofox
|
|
||||||
|
|
||||||
# Build and push AMD64 image by digest
|
|
||||||
- name: Build and push AMD64
|
|
||||||
id: build
|
|
||||||
uses: docker/build-push-action@v5
|
|
||||||
with:
|
|
||||||
context: .
|
|
||||||
platforms: linux/amd64
|
|
||||||
labels: ${{ steps.meta.outputs.labels }}
|
|
||||||
file: ./Dockerfile
|
|
||||||
cache-from: type=registry,ref=${{ secrets.DOCKERHUB_USERNAME }}/mofox:amd64-buildcache
|
|
||||||
cache-to: type=registry,ref=${{ secrets.DOCKERHUB_USERNAME }}/mofox:amd64-buildcache,mode=max
|
|
||||||
outputs: type=image,name=${{ secrets.DOCKERHUB_USERNAME }}/mofox,push-by-digest=true,name-canonical=true,push=true
|
|
||||||
build-args: |
|
|
||||||
BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ')
|
|
||||||
VCS_REF=${{ github.sha }}
|
|
||||||
|
|
||||||
build-arm64:
|
|
||||||
name: Build ARM64 Image
|
|
||||||
runs-on: ubuntu-24.04-arm
|
|
||||||
outputs:
|
|
||||||
digest: ${{ steps.build.outputs.digest }}
|
|
||||||
steps:
|
|
||||||
- name: Check out git repository
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
with:
|
|
||||||
fetch-depth: 0
|
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
|
||||||
uses: docker/setup-buildx-action@v3
|
|
||||||
with:
|
|
||||||
buildkitd-flags: --debug
|
|
||||||
|
|
||||||
# Log in docker hub
|
|
||||||
- name: Log in to Docker Hub
|
|
||||||
uses: docker/login-action@v3
|
|
||||||
with:
|
|
||||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
||||||
|
|
||||||
# Generate metadata for Docker images
|
|
||||||
- name: Docker meta
|
|
||||||
id: meta
|
|
||||||
uses: docker/metadata-action@v5
|
|
||||||
with:
|
|
||||||
images: ${{ secrets.DOCKERHUB_USERNAME }}/mofox
|
|
||||||
|
|
||||||
# Build and push ARM64 image by digest
|
|
||||||
- name: Build and push ARM64
|
|
||||||
id: build
|
|
||||||
uses: docker/build-push-action@v5
|
|
||||||
with:
|
|
||||||
context: .
|
|
||||||
platforms: linux/arm64/v8
|
|
||||||
labels: ${{ steps.meta.outputs.labels }}
|
|
||||||
file: ./Dockerfile
|
|
||||||
cache-from: type=registry,ref=${{ secrets.DOCKERHUB_USERNAME }}/mofox:arm64-buildcache
|
|
||||||
cache-to: type=registry,ref=${{ secrets.DOCKERHUB_USERNAME }}/mofox:arm64-buildcache,mode=max
|
|
||||||
outputs: type=image,name=${{ secrets.DOCKERHUB_USERNAME }}/mofox,push-by-digest=true,name-canonical=true,push=true
|
|
||||||
build-args: |
|
|
||||||
BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ')
|
|
||||||
VCS_REF=${{ github.sha }}
|
|
||||||
|
|
||||||
create-manifest:
|
|
||||||
name: Create Multi-Arch Manifest
|
|
||||||
runs-on: ubuntu-24.04
|
|
||||||
needs:
|
|
||||||
- build-amd64
|
|
||||||
- build-arm64
|
|
||||||
steps:
|
|
||||||
- name: Set up Docker Buildx
|
|
||||||
uses: docker/setup-buildx-action@v3
|
|
||||||
|
|
||||||
# Log in docker hub
|
|
||||||
- name: Log in to Docker Hub
|
|
||||||
uses: docker/login-action@v3
|
|
||||||
with:
|
|
||||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
||||||
|
|
||||||
# Generate metadata for Docker images
|
|
||||||
- name: Docker meta
|
|
||||||
id: meta
|
|
||||||
uses: docker/metadata-action@v5
|
|
||||||
with:
|
|
||||||
images: ${{ secrets.DOCKERHUB_USERNAME }}/mofox
|
|
||||||
tags: |
|
|
||||||
type=ref,event=branch
|
|
||||||
type=ref,event=tag
|
|
||||||
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }}
|
|
||||||
type=semver,pattern={{version}}
|
|
||||||
type=semver,pattern={{major}}.{{minor}}
|
|
||||||
type=semver,pattern={{major}}
|
|
||||||
type=sha,prefix=${{ github.ref_name }}-,enable=${{ github.ref_type == 'branch' }}
|
|
||||||
|
|
||||||
- name: Create and Push Manifest
|
|
||||||
run: |
|
|
||||||
# 为每个标签创建多架构镜像
|
|
||||||
for tag in $(echo "${{ steps.meta.outputs.tags }}" | tr '\n' ' '); do
|
|
||||||
echo "Creating manifest for $tag"
|
|
||||||
docker buildx imagetools create -t $tag \
|
|
||||||
${{ secrets.DOCKERHUB_USERNAME }}/mofox@${{ needs.build-amd64.outputs.digest }} \
|
|
||||||
${{ secrets.DOCKERHUB_USERNAME }}/mofox@${{ needs.build-arm64.outputs.digest }}
|
|
||||||
done
|
|
||||||
@@ -187,8 +187,8 @@ class ShortTermMemoryManager:
|
|||||||
"importance": 0.7,
|
"importance": 0.7,
|
||||||
"attributes": {{
|
"attributes": {{
|
||||||
"time": "时间信息",
|
"time": "时间信息",
|
||||||
"attribute1": "其他属性1"
|
"attribute1": "其他属性1",
|
||||||
"attribute2": "其他属性2"
|
"attribute2": "其他属性2",
|
||||||
...
|
...
|
||||||
}}
|
}}
|
||||||
}}
|
}}
|
||||||
@@ -327,7 +327,7 @@ class ShortTermMemoryManager:
|
|||||||
# 创建决策对象
|
# 创建决策对象
|
||||||
# 将 LLM 返回的大写操作名转换为小写(适配枚举定义)
|
# 将 LLM 返回的大写操作名转换为小写(适配枚举定义)
|
||||||
operation_str = data.get("operation", "CREATE_NEW").lower()
|
operation_str = data.get("operation", "CREATE_NEW").lower()
|
||||||
|
|
||||||
decision = ShortTermDecision(
|
decision = ShortTermDecision(
|
||||||
operation=ShortTermOperation(operation_str),
|
operation=ShortTermOperation(operation_str),
|
||||||
target_memory_id=data.get("target_memory_id"),
|
target_memory_id=data.get("target_memory_id"),
|
||||||
@@ -597,35 +597,35 @@ class ShortTermMemoryManager:
|
|||||||
# 1. 正常筛选:重要性达标的记忆
|
# 1. 正常筛选:重要性达标的记忆
|
||||||
candidates = [mem for mem in self.memories if mem.importance >= self.transfer_importance_threshold]
|
candidates = [mem for mem in self.memories if mem.importance >= self.transfer_importance_threshold]
|
||||||
candidate_ids = {mem.id for mem in candidates}
|
candidate_ids = {mem.id for mem in candidates}
|
||||||
|
|
||||||
# 2. 检查低重要性记忆是否积压
|
# 2. 检查低重要性记忆是否积压
|
||||||
# 剩余的都是低重要性记忆
|
# 剩余的都是低重要性记忆
|
||||||
low_importance_memories = [mem for mem in self.memories if mem.id not in candidate_ids]
|
low_importance_memories = [mem for mem in self.memories if mem.id not in candidate_ids]
|
||||||
|
|
||||||
# 如果低重要性记忆数量超过了上限(说明积压严重)
|
# 如果低重要性记忆数量超过了上限(说明积压严重)
|
||||||
# 我们需要清理掉一部分,而不是转移它们
|
# 我们需要清理掉一部分,而不是转移它们
|
||||||
if len(low_importance_memories) > self.max_memories:
|
if len(low_importance_memories) > self.max_memories:
|
||||||
# 目标保留数量(降至上限的 90%)
|
# 目标保留数量(降至上限的 90%)
|
||||||
target_keep_count = int(self.max_memories * 0.9)
|
target_keep_count = int(self.max_memories * 0.9)
|
||||||
num_to_remove = len(low_importance_memories) - target_keep_count
|
num_to_remove = len(low_importance_memories) - target_keep_count
|
||||||
|
|
||||||
if num_to_remove > 0:
|
if num_to_remove > 0:
|
||||||
# 按创建时间排序,删除最早的
|
# 按创建时间排序,删除最早的
|
||||||
low_importance_memories.sort(key=lambda x: x.created_at)
|
low_importance_memories.sort(key=lambda x: x.created_at)
|
||||||
to_remove = low_importance_memories[:num_to_remove]
|
to_remove = low_importance_memories[:num_to_remove]
|
||||||
|
|
||||||
for mem in to_remove:
|
for mem in to_remove:
|
||||||
if mem in self.memories:
|
if mem in self.memories:
|
||||||
self.memories.remove(mem)
|
self.memories.remove(mem)
|
||||||
|
|
||||||
logger.info(
|
logger.info(
|
||||||
f"短期记忆清理: 移除了 {len(to_remove)} 条低重要性记忆 "
|
f"短期记忆清理: 移除了 {len(to_remove)} 条低重要性记忆 "
|
||||||
f"(保留 {len(self.memories)} 条)"
|
f"(保留 {len(self.memories)} 条)"
|
||||||
)
|
)
|
||||||
|
|
||||||
# 触发保存
|
# 触发保存
|
||||||
asyncio.create_task(self._save_to_disk())
|
asyncio.create_task(self._save_to_disk())
|
||||||
|
|
||||||
return candidates
|
return candidates
|
||||||
|
|
||||||
async def clear_transferred_memories(self, memory_ids: list[str]) -> None:
|
async def clear_transferred_memories(self, memory_ids: list[str]) -> None:
|
||||||
|
|||||||
Reference in New Issue
Block a user