text stringlengths 14 100k | source stringclasses 1
value | repo stringclasses 810
values | language stringclasses 13
values |
|---|---|---|---|
<|fim_prefix|># -*- coding: utf-8 -*-#
from bridge.context import ContextType
from channel.chat_message import ChatMessage
from common.log import logger
from common.tmp_dir import TmpDir
class WeChatMPMessage(ChatMessage):
def _<|fim_suffix|>a_id)
if response.status_code == 200:
... | fim | zhayujie/CowAgent | python |
<|fim_prefix|>"""
WeCom (企业微信) AI Bot channel via WebSocket long connection.
Supports:
- Single chat and group chat (text / image / file input & output)
- Scheduled task push via aibot_send_msg
- Heartbeat keep-alive and auto-reconnect
"""
import base64
import hashlib
import json
import math
import os
import threadin... | fim | zhayujie/CowAgent | python |
<|fim_prefix|>import os
import re
import base64
import requests
from bridge.context import ContextType
from channel.chat_message import ChatMessage
from common.log import logger
from common.utils import expand_path
from config import conf
from Crypto.Cipher import AES
MAGIC_SIGNATURES = [
(b"%PDF", ".pdf"),
... | fim | zhayujie/CowAgent | python |
<|fim_prefix|>"""
Weixin HTTP JSON API client.
Implements the ilink bot protocol:
- getUpdates (long-poll)
- sendMessage
- getUploadUrl
- getConfig
- sendTyping
- QR login (get_bot_qrcode / get_qrcode_status)
CDN media upload with AES-128-ECB encryption.
"""
import base64
import hashlib
import os
import ... | fim | zhayujie/CowAgent | python |
<|fim_suffix|>eply.content, receiver, context_token)
elif reply.type == ReplyType.FILE:
self._send_file(reply.content, receiver, context_token)
elif reply.type in (ReplyType.VIDEO, ReplyType.VIDEO_URL):
self._send_video(reply.content, receiver, context_token)
elif reply.t... | fim | zhayujie/CowAgent | python |
"""
Weixin ChatMessage implementation.
Parses WeixinMessage from the getUpdates API into the unified ChatMessage format.
"""
import os
import uuid
from bridge.context import ContextType
from channel.chat_message import ChatMessage
from channel.weixin.weixin_api import download_media_from_cdn, CDN_BASE_URL
from commo... | fim | zhayujie/CowAgent | python |
<|fim_prefix|>"""CowAgent C<|fim_suffix|>n_file, "r") as f:
return f.read().strip()
except FileNotFoundError:
return "0.0.0"
__version__ = _read_version()
<|fim_middle|>LI - Manage your CowAgent from the command line."""
import os as _os
def _read_version():
version_file = _os.path.join(_... | fim | zhayujie/CowAgent | python |
<|fim_prefix|>"""Allow running a<|fim_suffix|>main()
<|fim_middle|>s: python -m cli"""
from cli.cli import main
<|endoftext|> | fim | zhayujie/CowAgent | python |
<|fim_suffix|>age your CowAgent instance."""
if ctx.invoked_subcommand is None:
click.echo(HELP_TEXT.strip())
@main.command()
def version():
"""Show the version."""
click.echo(f"cow {__version__}")
@main.command(name='help')
@click.pass_context
def help_cmd(ctx):
"""Show this message."""
... | fim | zhayujie/CowAgent | python |
<|fim_prefix|>"""cow context - Context management commands."""
import click
CHAT_HINT = (
"Context commands operate on the running agent's memory.\n"
"Please send the command in a chat conversation instead:\n\n"
" /context - View current context info\n"
" /context clear - Clear conversation... | fim | zhayujie/CowAgent | python |
<|fim_suffix|>talled or target_version}).",
))
if sys.platform == "linux":
_phase(on_phase, _t(
"🔧 [2/3] 正在安装 Linux 系统依赖与轻量中文字体(文泉驿正黑,部分步骤可能需要 sudo)…",
"🔧 [2/3] Installing Linux system deps and a lightweight CJK font (WenQuanYi Zen Hei; some steps may need sudo)…",
))
... | fim | zhayujie/CowAgent | python |
<|fim_prefix|>"""cow knowledge - Knowledge base management commands."""
import os
import click
from cli.utils import get_project_root
def _get_knowledge_dir():
"""Resolve the knowledge directory path from config or default."""
try:
import sys
sys.path.insert(0, get_project_root())
f... | fim | zhayujie/CowAgent | python |
"""cow start/stop/restart/status/logs - Process management commands."""
import os
import sys
import subprocess
import time
from typing import Optional
import click
from cli.utils import get_project_root, load_config_json
_IS_WIN = sys.platform == "win32"
def _is_terminal_only() -> bool:
"""Whether terminal is... | fim | zhayujie/CowAgent | python |
<|fim_prefix|>"""cow skill - Skill management commands."""
import os
import re
import sys
import json
import hashlib
import shutil
import zipfile
import tempfile
from dataclasses import dataclass, field
from typing import Optional, List
from urllib.parse import urlparse
import click
import requests
from cli.utils i... | fim | zhayujie/CowAgent | python |
<|fim_prefix|>"""Shared utilities for cow CLI."""
import os
import sys
import json
def get_project_r<|fim_suffix|>ot(), "skills")
def load_config_json() -> dict:
"""Load config.json from project root."""
config_path = os.path.join(get_project_root(), "config.json")
if not os.path.exists(config_path):
... | fim | zhayujie/CowAgent | python |
<|fim_prefix|>"""
Cloud management client for connecting to the LinkAI control console.
Handles remote configuration sync, message push, and skill management
via the LinkAI socket protocol.
NOTE: By default, no cloud-related config is enabled. The application runs
entirely locally without connecting to any remote ser... | fim | zhayujie/CowAgent | python |
<|fim_suffix|>nded model
GEMINI_35_FLASH = "gemini-3.5-flash" # Gemini 3.5 Flash - Agent recommended model
# OpenAI
GPT35 = "gpt-3.5-turbo"
GPT35_0125 = "gpt-3.5-turbo-0125"
GPT35_1106 = "gpt-3.5-turbo-1106"
GPT4 = "gpt-4"
GPT4_06_13 = "gpt-4-0613"
GPT4_32k = "gpt-4-32k"
GPT4_32k_06_13 = "gpt-4-32k-0613"
GPT4_TURBO =... | fim | zhayujie/CowAgent | python |
<|fim_prefix|>from queue import Full, Queue
from time import monotonic as time
# add implementation of putleft to Queue
class Dequeue(Queue):
def putleft(self, item, block=True, timeout=None):
with self.not_full:
if self.maxsize > 0:
if not block:
if self._q... | fim | zhayujie/CowAgent | python |
<|fim_prefix|>from datetime import datetime, timedelta
class <|fim_suffix|>self.expires_in_seconds = expires_in_seconds
def __getitem__(self, key):
value, expiry_time = super().__getitem__(key)
if datetime.now() > expiry_time:
del self[key]
raise KeyError("expired {}".form... | fim | zhayujie/CowAgent | python |
<|fim_prefix|># encoding:utf-8
"""Lightweight global language detection and resolution.
This module is the single source of truth for the runtime UI language used
across the CLI, startup logs, error messages, agent prompts and channel
replies. It must NOT import project config (to avoid circular imports) and
must sta... | fim | zhayujie/CowAgent | python |
<|fim_suffix|>r = _get_logger()
<|fim_prefix|>import logging
import sys
import io
def _reset_logger(log):
for handler in log.handlers:
handler.close()
log.removeHandler(handler)
del handler
log.handlers.clear()
log.propagate = False
stdout = sys.stdout
if hasattr(stdout, "b... | fim | zhayujie/CowAgent | python |
<|fim_prefix|>from common.expired_dict<|fim_suffix|>ACHE = ExpiredDict(60 * 3)<|fim_middle|> import ExpiredDict
USER_IMAGE_C<|endoftext|> | fim | zhayujie/CowAgent | python |
<|fim_suffix|> import dulwich
except ImportError:
raise ImportError("Unable to import dulwich")
<|fim_prefix|>import time
import pip
from pip._internal import main as pipmain
from common.log import _reset_logger, logger
def install(package):
pipmain(["install", package])
def install_require... | fim | zhayujie/CowAgent | python |
<|fim_suffix|>rn get_instance
<|fim_prefix|>def singleton(cls):
instances = {}
def get_instance(*args, **kwargs):
if cls not in instances:
instances[cls] = cls(*args, **kwa<|fim_middle|>rgs)
return instances[cls]
retu<|endoftext|> | fim | zhayujie/CowAgent | python |
<|fim_suffix|> del self.heap[i]
heapq.heapify(self.heap)
break
self.sorted_keys = None
def keys(self):
if self.sorted_keys is None:
self.sorted_keys = [k for _, k in sorted(self.heap, reverse=self.reverse)]
return self.sorted_keys
... | fim | zhayujie/CowAgent | python |
<|fim_prefix|>import re
import time
import config
from common.log import logger
def time_checker(f):
def _time_checker(self, *args, **kwargs):
_config = config.conf()
chat_time_module = _config.get("chat_time_module", False)
if chat_time_module:
chat_start_time = _config.get("... | fim | zhayujie/CowAgent | python |
<|fim_suffix|> return str(self.tmpFilePath) + "/"
<|fim_prefix|>import os
import pathlib
from config import conf
cl<|fim_middle|>ass TmpDir(object):
"""A temporary directory that is deleted when the object is destroyed."""
tmpFilePath = pathlib.Path("./tmp/")
def __init__(self):
pathExis... | fim | zhayujie/CowAgent | python |
<|fim_prefix|>import threading
import time
class TokenBucket:
def __init__(self, tpm, timeout=None):
self.capacity = int(tpm) # 令牌桶容量
self.tokens = 0 # 初始令牌数为0
self.rate = int(tpm) / 60 # 令牌每秒生成速率
self.timeout = timeout # 等待令牌超时时间
self.cond = threading.Condition() # 条件... | fim | zhayujie/CowAgent | python |
<|fim_suffix|>port LinkAIClient
client_id = LinkAIClient.fetch_client_id()
if client_id:
headers["X-Client-Id"] = client_id
except Exception:
pass
return headers
<|fim_prefix|>import io
import os
import re
from urllib.parse import urlparse
from common.log import logger
def f... | fim | zhayujie/CowAgent | python |
<|fim_prefix|>import inspect
from typing import Any
def websocket_app_run_forever(ws: Any, **kwargs: Any) -> None:
"""
Call WebSocketApp.run_forever; strip reconnect= if the installed
websocket-client is too old (reconnect was added in a later 1.x release).
"""
if "recon<|fim_suffix|>nect" not in ... | fim | zhayujie/CowAgent | python |
<|fim_suffix|>t keys.
"self_evolution_enabled": False, # switch to enable/disable self-evolution
"self_evolution_idle_minutes": 10, # idle time before a session is reviewed
"self_evolution_min_turns": 6, # min user turns (or context pressure) to trigger
"skill": {}, # Per-skill run... | fim | zhayujie/CowAgent | python |
<|fim_suffix|> print(response.json())
return response.json()["access_token"]
<|fim_prefix|># encoding:utf-8
import requests
from models.bot import Bot
from bridge.reply import Reply, ReplyType
# Baidu Unit对话接口 (可用, 但能力较弱)
class BaiduUnitBot(Bot):
def reply(self, query, context=None):
tok... | fim | zhayujie/CowAgent | python |
<|fim_suffix|>", "client_id": BAIDU_API_KEY, "client_secret": BAIDU_SECRET_KEY}
return str(requests.post(url, params=params).json().get("access_token"))
<|fim_prefix|># encoding:utf-8
import requests
import json
from common import const
from models.bot import Bot
from models.session_manager import SessionManag... | fim | zhayujie/CowAgent | python |
<|fim_prefix|>from models.session_manager import Session
from common.log import logger
"""
e.g. [
{"role": "user", "content": "Who won the world series in 2020?"},
{"role": "assistant", "content": "The Los Angeles Dodgers won the World Series in 2020."},
{"role": "user", "content": "Where ... | fim | zhayujie/CowAgent | python |
<|fim_suffix|>bclasses may also implement:
call_with_tools(messages, tools=None, stream=False, **kwargs)
-> dict | generator (OpenAI-compatible format)
call_vision(image_url, question, model=None, max_tokens=1000)
-> dict with keys: model, content, usage (or error/message)
... | fim | zhayujie/CowAgent | python |
<|fim_prefix|>"""
channel factory
"""
from common import const
def create_bot(bot_type):
"""
create a bot_type instance
:param bot_type: bot type code
:return: bot instance
"""
if bot_type == const.BAIDU:
# 替换Baidu Unit为Baidu文心千帆对话接口
# from models.baidu.baidu_unit_bot import Ba... | fim | zhayujie/CowAgent | python |
<|fim_prefix|># encoding:utf-8
import time
import json
from models.openai.openai_compat import (
error as openai_error,
RateLimitError,
Timeout,
APIError,
APIConnectionError,
wrap_http_error,
)
from models.openai.openai_http_client import OpenAIHTTPClient, OpenAIHTTPError
import requests
from ... | fim | zhayujie/CowAgent | python |
from models.session_manager import Session
from common.log import logger
from common import const
"""
e.g. [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Who won the world series in 2020?"},
{"role": "assistant", "content": "The Los Angeles Do... | fim | zhayujie/CowAgent | python |
<|fim_suffix|>ol_calls": [{
"index": idx,
"id": tool_data["id"],
"type": "function",
"function":... | fim | zhayujie/CowAgent | python |
<|fim_suffix|>1. If ``bot_type`` is ``"custom:<id>"``, look up that id in
``custom_providers``.
2. If ``bot_type`` is exactly ``"custom"`` (legacy), return the flat
``custom_api_key`` / ``custom_api_base``.
:return: tuple ``(api_key, api_base, model)``. ``api_base`` and ``model``
... | fim | zhayujie/CowAgent | python |
<|fim_prefix|># encoding:utf-8
import json
from typing import Optional
from models.bot import Bot
from models.session_manager import SessionManager
from bridge.context import ContextType
from bridge.reply import Reply, ReplyType
from common.log import logger
from config import conf, load_config
from .dashscope_sessio... | fim | zhayujie/CowAgent | python |
<|fim_prefix|>from models.session_manager import Session
from common.log import logger
class DashscopeSession(Session):
def __init__(self, session_id, system_prompt=None, model="qwen-turbo"):
super().__init__(session_id)
self.reset()
def discard_exceeding(self, max_tokens, cur_tokens=None):
... | fim | zhayujie/CowAgent | python |
<|fim_suffix|> """
Convert tools from Claude format to OpenAI format.
Claude: {name, description, input_schema}
OpenAI: {type: "function", function: {name, description, parameters}}
"""
if not tools:
return None
converted = []
for tool in tool... | fim | zhayujie/CowAgent | python |
<|fim_prefix|>from models.session_manager import Session
from common.log import logger
class DeepSeekSession(Session):
def __init__(self, session_id, system_prompt=None, model="deepseek-v4-flash"):
super().__init__(session_id, system_prompt)
self.model = model
self.reset()
def discard... | fim | zhayujie/CowAgent | python |
<|fim_prefix|># encoding:utf-8
import json
import time
from typing import Optional
import requests
from models.bot import Bot
from models.session_manager import SessionManager
from bridge.context import ContextType
from bridge.reply import Reply, ReplyType
from common.log import logger
from config import conf, load_c... | fim | zhayujie/CowAgent | python |
<|fim_suffix|> try:
cur_tokens = self.calc_tokens()
except Exception as e:
precise = False
if cur_tokens is None:
raise e
logger.debug("Exception when counting tokens precisely for query: {}".format(e))
while cur_tokens > max_tokens:
... | fim | zhayujie/CowAgent | python |
<|fim_prefix|>"""
Google gemini bot
@author zhayujie
@Date 2023/12/15
"""
# encoding:utf-8
import base64
import json
import mimetypes
import os
import re
import time
from typing import Optional
import requests
from models.bot import Bot
from models.session_manager import SessionManager
from bridge.context import Con... | fim | zhayujie/CowAgent | python |
<|fim_prefix|># access LinkAI knowledge base platform
# docs: https://link-ai.tech/platform/link-app/wechat
import re
import time
import requests
import json
import config
from models.bot import Bot
from models.openai_compatible_bot import OpenAICompatibleBot
from models.chatgpt.chat_gpt_session import ChatGPTSession
... | fim | zhayujie/CowAgent | python |
<|fim_prefix|># encoding:utf-8
"""
小米 MiMo Bot —— OpenAI 兼容协议,使用独立 API key / base 配置。
支持模型:
- mimo-v2.5-pro (旗舰,长上下文,默认开启思考)
- mimo-v2.5 (多模态:文/图/音/视频,默认开启思考)
- mimo-v2-pro (V2 Pro,默认开启思考)
- mimo-v2-omni (V2 多模态,默认开启思考)
- mimo-v2-flash (V2 极速版,默认关闭思考)
思考模式说明:
- 开关参数:``{"thinking": {"type":... | fim | zhayujie/CowAgent | python |
<|fim_suffix|>lif len(self.messages) == 2 and self.messages[1]["role"] == "assistant":
self.messages.pop(1)
if precise:
cur_tokens = self.calc_tokens()
else:
cur_tokens = cur_tokens - max_tokens
break
eli... | fim | zhayujie/CowAgent | python |
<|fim_prefix|># encoding:utf-8
import time
import json
from typing import Optional
import requests
from models.bot import Bot
from models.minimax.minimax_session import MinimaxSession
from models.session_manager import SessionManager
from bridge.context import Context, ContextType
from bridge.reply import Reply, Rep... | fim | zhayujie/CowAgent | python |
from models.session_manager import Session
from common.log import logger
"""
e.g.
[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Who won the world series in 2020?"},
{"role": "assistant", "content": "The Los Angeles Dodgers won the World Se... | fim | zhayujie/CowAgent | python |
<|fim_prefix|># encoding:utf-8
import json
import time
import requests
from models.bot import Bot
from models.session_manager import SessionManager
from bridge.context import ContextType
from bridge.reply import Reply, ReplyType
from common.log import logger
from config import conf, load_config
from .modelscope_sessi... | fim | zhayujie/CowAgent | python |
from models.session_manager import Session
from common.log import logger
class ModelScopeSession(Session):
def __init__(self, session_id, system_prompt=None, model="Qwen/Qwen2.5-7B-Instruct"):
super().__init__(session_id, system_prompt)
self.model = model
self.reset()
def discard_exce... | fim | zhayujie/CowAgent | python |
<|fim_suffix|> }
# Final chunk with finish_reason
yield {
"choices": [{
"index": 0,
"delta": {},
"finish_reason": finish_reason
}]
}
except requests.exceptions.Timeout:... | fim | zhayujie/CowAgent | python |
<|fim_suffix|>ges:
tokens += len(msg["content"])
return tokens
<|fim_prefix|>from models.session_manager import Session
from common.log import logger
class MoonshotSession(Session):
def __init__(self, session_id, system_prompt=None, model="moonshot-v1-128k"):
super().__init__(session_id, syste... | fim | zhayujie/CowAgent | python |
<|fim_suffix|>lf, session: OpenAISession, retry_count=0):
try:
call_args = dict(self.args)
timeout = call_args.pop("request_timeout", None) or call_args.pop("timeout", None)
response = self._http_client.completions(
timeout=timeout,
prompt=str(... | fim | zhayujie/CowAgent | python |
<|fim_suffix|>(mapped)
return False, "画图出现问题,请休息一下再问我吧"
except RateLimitError as e:
logger.warn(e)
if retry_count < 1:
time.sleep(5)
logger.warn("[OPEN_AI] ImgCreate RateLimit exceed, 第{}次重试".format(retry_count + 1))
return self... | fim | zhayujie/CowAgent | python |
<|fim_prefix|>from models.session_manager import Session
from common.log import logger
class OpenAISession(Session):
def __init__(self, session_id, system_prompt=None, model="text-davinci-003"):
super().__init__(session_id, system_prompt<|fim_suffix|> raise e
logger.debug("Exception when c... | fim | zhayujie/CowAgent | python |
<|fim_suffix|> HTTP-based bot wrappers so that downstream ``except RateLimitError``
blocks behave identically to when the openai SDK was raising them.
"""
sc = status_code or 0
msg = message or ""
msg_lower = msg.lower()
# Connection-level (no status / non-HTTP failure)
if sc == 0:
... | fim | zhayujie/CowAgent | python |
# encoding:utf-8
"""
Lightweight HTTP client for OpenAI-compatible APIs.
This client is a drop-in replacement for the parts of the `openai` SDK that this
project actually uses (chat completions, completions, image generation), so we
can drop the hard dependency on `openai==0.27.x`.
Design goals:
- Pure `requests` ba... | fim | zhayujie/CowAgent | python |
<|fim_prefix|># encoding:utf-8
"""
OpenAI-Compatible Bot Base Class
Provides a common implementation for bots that are compatible with OpenAI's API format.
This includes: OpenAI, LinkAI, Azure OpenAI, and many third-party providers.
"""
import json
import requests
from typing import Optional
from common.log import l... | fim | zhayujie/CowAgent | python |
<|fim_prefix|># e<|fim_suffix|>g:utf-8
<|fim_middle|>ncodin<|endoftext|> | fim | zhayujie/CowAgent | python |
<|fim_suffix|> message = str(body.get("raw"))
else:
message = str(body)
logger.error(
"[QIANFAN] chat failed, status_code={}, msg={}".format(
response.status_code, message
)
)
if response.status_code >= 500 and retry_count < 2:
... | fim | zhayujie/CowAgent | python |
<|fim_suffix|> num_tokens_from_messages(self.messages, self.model)
def num_tokens_from_messages(messages, model):
tokens = 0
for msg in messages:
content = msg.get("content", "")
if isinstance(content, str):
tokens += len(content)
elif isinstance(content, list):
... | fim | zhayujie/CowAgent | python |
from common.expired_dict import ExpiredDict
from common.log import logger
from config import conf
class Session(object):
def __init__(self, session_id, system_prompt=None):
self.session_id = session_id
self.messages = []
if system_prompt is None:
self.system_prompt = conf().get... | fim | zhayujie/CowAgent | python |
<|fim_prefix|># encoding:utf-8
import requests, json
from models.bot import Bot
from models.session_manager import SessionManager
from models.chatgpt.chat_gpt_session import ChatGPTSession
from bridge.context import ContextType, Context
from bridge.reply import Reply, ReplyType
from common.log import logger
from confi... | fim | zhayujie/CowAgent | python |
<|fim_prefix|>from common.log import logger
from config import conf
# ZhipuAI提供的画图接口
class ZhipuAIImage(object):
def __init__(self):
from zai import ZhipuAiClient
# 初始化客户端,支持自定义 API base URL(例如智谱国际版 z.ai)
api_key = conf().get("zhipu_ai_api_key")
api_base = conf().get("zhipu_ai_api... | fim | zhayujie/CowAgent | python |
<|fim_suffix|> logger.warn("user message exceed max_tokens. total_tokens={}".format(cur_tokens))
break
else:
logger.debug("max_tokens={}, total_tokens={}, len(messages)={}".format(max_tokens, cur_tokens,
... | fim | zhayujie/CowAgent | python |
<|fim_suffix|>
getattr(response.choices[0].message, 'tool_calls', None)
)
},
"finish_reason": response.choices[0].finish_reason
}],
"usage": {
"prompt_tokens": response.usage.p... | fim | zhayujie/CowAgent | python |
<|fim_prefix|>from .eve<|fim_suffix|>rom .plugin import *
from .plugin_manager import PluginManager
instance = PluginManager()
register = instance.register
# load_plugins = instance.load_plugins
# emit_event = instance.emit_event
<|fim_middle|>nt import *
f<|endoftext|> | fim | zhayujie/CowAgent | python |
<|fim_prefix|>fr<|fim_suffix|>.banwords import *
<|fim_middle|>om <|endoftext|> | fim | zhayujie/CowAgent | python |
<|fim_prefix|># encoding:utf-8
import json
import os
import plugins
from bridge.context import ContextType
from bridge.reply import Reply, ReplyType
from common.log import logger
from plugins import *
from .lib.WordsSearch import WordsSearch
@plugins.register(
name="Banwords",
desire_priority=100,
hidd... | fim | zhayujie/CowAgent | python |
<|fim_suffix|> oldNode=oldNode.Failure
while oldNode != root:
for key in oldNode.m_values :
if (newNode.HasKey(key) == False):
index = oldNode.m_values[key].Index
newNode.Add(key, allNode2[index])
for ... | fim | zhayujie/CowAgent | python |
<|fim_prefix|>from<|fim_suffix|>import CowCliPlugin
<|fim_middle|> .cow_cli <|endoftext|> | fim | zhayujie/CowAgent | python |
<|fim_suffix|>bled", True)
source = entry.get("source", "")
icon = "✅" if enabled else "⏸️"
display = entry.get("display_name", "") or name
desc = entry.get("description", "")
if len(desc) > 50:
desc = desc[:47] + "…"
line = f"{icon... | fim | zhayujie/CowAgent | python |
<|fim_suffix|>ort *
<|fim_prefix|>from .dungeon <|fim_middle|>imp<|endoftext|> | fim | zhayujie/CowAgent | python |
<|fim_prefix|># encoding:utf-8
import plugins
from bridge.bridge import Bridge
from bridge.context import ContextType
from bridge.reply import Reply, ReplyType
from common import const
from common.expired_dict import ExpiredDict
from common.log import logger
from config import conf
from plugins import *
# https://gi... | fim | zhayujie/CowAgent | python |
# encoding:utf-8
from enum import Enum
class Event(Enum):
ON_RECEIVE_MESSAGE = 1 # 收到消息
"""
e_context = { "channel": 消息channel, "context" : 本次消息的context}
"""
ON_HANDLE_CONTEXT = 2 # 处理消息前
"""
e_context = { "channel": 消息channel, "context" : 本次消息的context, "reply" : 目前的回复,初始为空 }
""... | fim | zhayujie/CowAgent | python |
from .finish import *
<|endoftext|> | fim | zhayujie/CowAgent | python |
<|fim_prefix|># encoding:utf-8
import plugins
from bridge.context import ContextType
from bridge.reply import Reply, ReplyType
from common.log import logger
from config import conf
from plugins import *
@plugins.register(
name="Finish",
desire_priority=-999,
hidden=True,
desc="A plugin that check unk... | fim | zhayujie/CowAgent | python |
<|fim_suffix|>port *
<|fim_prefix|>f<|fim_middle|>rom .godcmd im<|endoftext|> | fim | zhayujie/CowAgent | python |
<|fim_prefix|># encoding:utf-8
import json
import os
import random
import string
import logging
from typing import Tuple
import bridge.bridge
import plugins
from bridge.bridge import Bridge
from bridge.context import ContextType
from bridge.reply import Reply, ReplyType
from common import const
from config import con... | fim | zhayujie/CowAgent | python |
<|fim_prefix|>f<|fim_suffix|>hello import *
<|fim_middle|>rom .<|endoftext|> | fim | zhayujie/CowAgent | python |
<|fim_prefix|># encoding:utf-8
import plugins
from bridge.context import ContextType
from bridge.reply import Reply, ReplyType
from channel.chat_message import ChatMessage
from common.log import logger
from plugins import *
from config import conf
@plugins.register(
name="Hello",
desire_priority=-1,
hidd... | fim | zhayujie/CowAgent | python |
<|fim_prefix|>from .<|fim_suffix|>ord import *
<|fim_middle|>keyw<|endoftext|> | fim | zhayujie/CowAgent | python |
<|fim_suffix|>doc", ".docx", ".xls", "xlsx",".zip", ".rar"结尾,则下载文件到tmp目录并发送给用户
file_path = "tmp"
if not os.path.exists(file_path):
os.makedirs(file_path)
file_name = reply_text.split("/")[-1] # 获取文件名
file_path = os.path.join(file_path,... | fim | zhayujie/CowAgent | python |
<|fim_suffix|>port *
<|fim_prefix|>from .link<|fim_middle|>ai im<|endoftext|> | fim | zhayujie/CowAgent | python |
<|fim_suffix|> return
if context.type == ContextType.TEXT and _find_file_id(context):
bot = bridge.Bridge().find_chat_bot(const.LINKAI)
context.kwargs["file_id"] = _find_file_id(context)
reply = bot.reply(context.content, context)
e_context["reply"] = reply
... | fim | zhayujie/CowAgent | python |
<|fim_suffix|>200:
task_id = res.get("data").get("task_id")
logger.info(f"[MJ] image operate processing, task_id={task_id}")
icon_map = {TaskType.UPSCALE: "🔎", TaskType.VARIATION: "🪄", TaskType.RESET: "🔄"}
content = f"{icon_map.get(task_type)}图片正在{task_... | fim | zhayujie/CowAgent | python |
<|fim_prefix|>import requests
from config import conf
from common.log import logger
import os
import html
class LinkSummary:
def __init__(self):
pass
def summary_file(self, file_path: str, app_code: str):
file_body = {
"file": open(file_path, "rb"),
"name": file_path.s... | fim | zhayujie/CowAgent | python |
<|fim_prefix|>import requests
from common.log import logger
from config import global_config
from bridge.reply import Reply, ReplyType
from plugins.event import EventContext, EventAction
from config import conf
class Util:
@staticmethod
def is_admin(e_context: EventContext) -> bool:
"""
判断消息是否由... | fim | zhayujie/CowAgent | python |
<|fim_prefix|>import os
import json
from config import pconf, plugin_config, conf, write_plugin_config
from common.log import logger
class Plugin:
def __init__(self):
self.handlers = {}
def load_config(self) -> dict:
"""
加载当前插件配置
:return: 插件配置字典
"""
# 优先获取 plug... | fim | zhayujie/CowAgent | python |
<|fim_prefix|># encoding:utf-8
import importlib
import importlib.util
import json
import os
import sys
from common.log import logger
from common.singleton import singleton
from common.sorted_dict import SortedDict
from config import conf, remove_plugin_config, write_plugin_config
from .event import *
@singleton
cl... | fim | zhayujie/CowAgent | python |
from .role import *
<|endoftext|> | fim | zhayujie/CowAgent | python |
<|fim_prefix|># encoding:utf-8
import json
import os
import plugins
from bridge.bridge import Bridge
from bridge.context import ContextType
from bridge.reply import Reply, ReplyType
from common import const
from common.log import logger
from config import conf
from plugins import *
class RolePlay:
def __init__(... | fim | zhayujie/CowAgent | python |
<|fim_prefix|>from chatgpt_tool_hub.apps import AppFactory
from chatgpt_tool_hub.apps.app import App
from chatgpt_tool_hub.tools.tool_register import main_tool_register
import plugins
from bridge.bridge import Bridge
from bridge.context import ContextType
from bridge.reply import Reply, ReplyType
from common import co... | fim | zhayujie/CowAgent | python |
<|fim_prefix|>#!/usr/bin/env python3
"""
Unified image generation script.
Usage:
python generate.py '<json_args>'
Supported model families (each provider is tried in priority order:
OpenAI → Gemini → Seedream → Qwen → MiniMax → LinkAI; missing API keys
are skipped, and the provider that natively owns the requeste... | fim | zhayujie/CowAgent | python |
<|fim_suffix|> except Exception as e:
print(f"❌ Error creating SKILL.md: {e}")
return None
# Create resource directories with example files
try:
# Create scripts/ directory with example script
scripts_dir = skill_dir / 'scripts'
scripts_dir.mkdir(exist_ok=True)
... | fim | zhayujie/CowAgent | python |
<|fim_suffix|> return None
def main():
if len(sys.argv) < 2:
print("Usage: python utils/package_skill.py <path/to/skill-folder> [output-directory]")
print("\nExample:")
print(" python utils/package_skill.py skills/public/my-skill")
print(" python utils/package_skill.py skills... | fim | zhayujie/CowAgent | python |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.