python+qwen实现似cursor的 AI编程助手代码

代码语言:python

所属分类:人工智能

代码描述:python+qwen实现似cursor的 AI编程助手代码

代码标签: python qwen cursor AI 编程 助手 代码

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开

from asynchat import async_chat
from itertools import tee
import os
import json
import re
import sys
from pathlib import Path
from typing import List, Dict
from openai import OpenAI
import aiohttp

api_key="sk-apikey"#自己去阿里百炼开通
base_url="https://dashscope.aliyuncs.com/compatible-mode/v1"

class CodeAssistant:
    def __init__(self, project_dir: str):
        """初始化代码助手"""
        self.project_dir = Path(project_dir)
        self.project_dir.mkdir(parents=True, exist_ok=True)
        
    def _get_file_context(self) -> str:
        """获取项目目录中所有代码文件的内容作为上下文"""
        context = []
        for file_path in self.project_dir.rglob("*"):
            if file_path.is_file() and file_path.suffix in [
                '.php', '.js', '.html', '.css', '.json', '.py', '.java', '.cpp', '.c', 
                '.cs', '.rb', '.go', '.rs', '.ts', '.swift', '.kt', '.m', '.sh', '.xml', 
                '.yml', '.yaml', '.sql', '.r', '.pl', '.lua', '.scala', '.vb', '.hs', 
                '.erl', '.ex', '.exs&#.........完整代码请登录后点击上方下载按钮下载查看

网友评论0