text
stringlengths
7
1.68M
id
stringlengths
17
99
metadata
dict
__index_level_0__
int64
0
33
import os import subprocess # set the OpenAI API key os.environ['OPENAI_API_KEY'] = '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' def call_gpt(input: str, prompt: str) -> str: """ This function calls GPT through the devchat chat command. It takes a string as input and returns a string as output. ...
devchat-vscode/prompt_test.py/0
{ "file_path": "devchat-vscode/prompt_test.py", "repo_id": "devchat-vscode", "token_count": 5150 }
11
/* 不同源码语言有不同语法信息,例如注释标记。 */ export const supportedLanguages: { [key: string]: string } = { bash: "bash", // tree-sitter-bash.wasm sh: "bash", // tree-sitter-bash.wasm c: "c", // tree-sitter-c.wasm h: "c", // tree-sitter-c.wasm cs: "c_sharp", // tree-sitter-c_sharp.wasm cpp: "...
devchat-vscode/src/contributes/codecomplete/ast/language.ts/0
{ "file_path": "devchat-vscode/src/contributes/codecomplete/ast/language.ts", "repo_id": "devchat-vscode", "token_count": 2610 }
12
export interface ModelConfigTemplate { template: string; stop: string[]; } const stableCodeTemplate: ModelConfigTemplate = { template: "<fim_prefix>{{{prefix}}}<fim_suffix>{{{suffix}}}<fim_middle>", stop: ["<fim_prefix>", "<fim_suffix>", "<fim_middle>", "<|endoftext|>"], }; const MODLE_COMPLETE_CONF...
devchat-vscode/src/contributes/codecomplete/modelConfig.ts/0
{ "file_path": "devchat-vscode/src/contributes/codecomplete/modelConfig.ts", "repo_id": "devchat-vscode", "token_count": 224 }
13
import * as vscode from 'vscode'; import { regInMessage, regOutMessage } from '../util/reg_messages'; export async function applyCode(text: string) { const validVisibleTextEditors = vscode.window.visibleTextEditors.filter(editor => editor.viewColumn !== undefined); if (validVisibleTextEditors.length > 1) { vscod...
devchat-vscode/src/handler/codeBlockHandler.ts/0
{ "file_path": "devchat-vscode/src/handler/codeBlockHandler.ts", "repo_id": "devchat-vscode", "token_count": 1482 }
14
import DevChat, { ChatOptions, ChatResponse } from '../toolwrapper/devchat'; import { logger } from '../util/logger'; import messageHistory from '../util/messageHistory'; import { assertValue } from '../util/check'; /** * Class to handle user interaction stop events. */ class UserStopHandler { /** * Flag to indi...
devchat-vscode/src/handler/sendMessageBase.ts/0
{ "file_path": "devchat-vscode/src/handler/sendMessageBase.ts", "repo_id": "devchat-vscode", "token_count": 2584 }
15
import * as vscode from "vscode"; import { applyCodeWithDiff } from "../../handler/diffHandler"; import { getSymbolDefines } from "../../context/contextRefDefs"; export namespace UnofficialEndpoints { export async function diffApply(filepath: string, content: string) { applyCodeWithDiff({ fileName: filepa...
devchat-vscode/src/ide_services/endpoints/unofficial.ts/0
{ "file_path": "devchat-vscode/src/ide_services/endpoints/unofficial.ts", "repo_id": "devchat-vscode", "token_count": 345 }
16
export function assertValue(value: any, message: string) { if (value) { throw new Error(message); } }
devchat-vscode/src/util/check.ts/0
{ "file_path": "devchat-vscode/src/util/check.ts", "repo_id": "devchat-vscode", "token_count": 36 }
17
/* Install specific version of package. e.g. devchat */ import { spawn } from 'child_process'; import { logger } from '../logger'; // install specific version of package // pythonCommand -m install pkgName // if install success, return true // else return false export async function installPackage(pythonCommand: s...
devchat-vscode/src/util/python_installer/package_install.ts/0
{ "file_path": "devchat-vscode/src/util/python_installer/package_install.ts", "repo_id": "devchat-vscode", "token_count": 1123 }
18
import { expect } from 'chai'; import { describe, it } from 'mocha'; import { FilePairManager } from '../../src/util/diffFilePairs'; describe('FilePairManager', () => { let filePairManager: FilePairManager; beforeEach(() => { filePairManager = FilePairManager.getInstance(); }); afterEach(() => { // C...
devchat-vscode/test/util/filePairManager.test.ts/0
{ "file_path": "devchat-vscode/test/util/filePairManager.test.ts", "repo_id": "devchat-vscode", "token_count": 596 }
19
import json import sys import time from typing import Optional, List, Iterator from devchat.message import Message from devchat.chat import Chat from devchat.openai.openai_prompt import OpenAIPrompt from devchat.store import Store from devchat.utils import get_logger logger = get_logger(__name__) class Assistant: ...
devchat/devchat/assistant.py/0
{ "file_path": "devchat/devchat/assistant.py", "repo_id": "devchat", "token_count": 3119 }
20
import re import os from .namespace import Namespace class RecursivePrompter: def __init__(self, namespace: Namespace): self.namespace = namespace def run(self, name: str) -> str: ancestors = name.split('.') merged_content = '' for index in range(len(ancestors)): a...
devchat/devchat/engine/recursive_prompter.py/0
{ "file_path": "devchat/devchat/engine/recursive_prompter.py", "repo_id": "devchat", "token_count": 709 }
21
class ChatMemory: """ ChatMemory is the base class for all chat memory classes. """ def __init__(self): pass def append(self, request, response): """ Append a request and response to the memory. """ # it must implemented in sub class def append_request(...
devchat/devchat/memory/base.py/0
{ "file_path": "devchat/devchat/memory/base.py", "repo_id": "devchat", "token_count": 251 }
22
import pytest from devchat.openai import OpenAIMessage def test_valid_message_creation(): message = OpenAIMessage(role="user", content="Hello, World!") assert message.role == "user" assert message.content == "Hello, World!" assert message.name is None def test_valid_message(): message = OpenAIMe...
devchat/tests/test_openai_message.py/0
{ "file_path": "devchat/tests/test_openai_message.py", "repo_id": "devchat", "token_count": 701 }
23
description: Automatically add docstrings. Select a function or method and execute this command to generate docstring. steps: - run: $devchat_python $command_path/main.py
workflows/docstring/command.yml/0
{ "file_path": "workflows/docstring/command.yml", "repo_id": "workflows", "token_count": 44 }
24
from typing import Dict, List, Optional, Union from .iobase import pipe_interaction from .widgets import Button, Widget class Form: """ A container for different widgets Syntax: """ def __init__( self, components: List[Union[Widget, str]], title: Optional[str] = None, ...
workflows/libs/chatmark/form.py/0
{ "file_path": "workflows/libs/chatmark/form.py", "repo_id": "workflows", "token_count": 1136 }
25
import json from typing import List, Optional from devchat.llm.openai import chat_completion_no_stream_return_json from llm_conf import ( CONTEXT_SIZE, DEFAULT_CONTEXT_SIZE, DEFAULT_ENCODING, USE_USER_MODEL, USER_LLM_MODEL, ) from model import FuncToTest from openai_util import create_chat_completi...
workflows/unit_tests/assistants/recommend_test_context.py/0
{ "file_path": "workflows/unit_tests/assistants/recommend_test_context.py", "repo_id": "workflows", "token_count": 1369 }
26
# ruff: noqa: E501 # Don not limit the length of each line of the prompts. PROPOSE_TEST_PROMPT = """ You're an advanced AI test case generator. Given a user prompt and a target function, propose detailed test cases for the function based on the prompt, categorizing each as either a 'happy path' or an 'edge case'. Th...
workflows/unit_tests/prompts.py/0
{ "file_path": "workflows/unit_tests/prompts.py", "repo_id": "workflows", "token_count": 821 }
27
import streamlit as st # 主函数 def main(): st.title('简单数据可视化') st.button('Hello') print("====> Hello", end="\n\n", flush=True) if __name__ == "__main__": main()
LabWorkflows/browser/command.py/0
{ "file_path": "LabWorkflows/browser/command.py", "repo_id": "LabWorkflows", "token_count": 100 }
0
description: 'Config LLM Module' input: required steps: - run: $command_python $command_path/../command.py "$input" "chat"
LabWorkflows/llm/chat/command.yml/0
{ "file_path": "LabWorkflows/llm/chat/command.yml", "repo_id": "LabWorkflows", "token_count": 39 }
1
import subprocess import sys import time import requests import json import os home = os.path.expanduser("~") org_libs_path = os.path.join(home, ".chat", "workflows", "org", "libs") sys_libs_path = os.path.join(home, ".chat", "workflows", "sys", "libs") sys.path.append(org_libs_path) sys.path.append(sys_libs_path) ...
LabWorkflows/ping-test/command.py/0
{ "file_path": "LabWorkflows/ping-test/command.py", "repo_id": "LabWorkflows", "token_count": 683 }
2
description: improve the readability and conformity of a given string to English language conventions. steps: - run: $devchat_python $command_path/../rewrite.py "enhance the given string's readability and ensure it adheres to English linguistic standards"
LabWorkflows/rewrite/optimize_string/command.yml/0
{ "file_path": "LabWorkflows/rewrite/optimize_string/command.yml", "repo_id": "LabWorkflows", "token_count": 60 }
3
""" /workflow.publish -> step1: 选择需要发布的command -> step2: 打包command目录为zip包 -> step3: 发布包到服务器 -> step3.1: 判断服务器是否存在同名包 -> step3.2: 如果有同名包,验证管理密码是否匹配 -> step3.3: 如果密码不匹配,返回没有权限提示 -> step3.4: 如果密码匹配,更新现有同名包 -> step3.5: 如果没有同名包,创建新包 """ import os import sys import zipfile import requests sys.path.append(os.path....
LabWorkflows/workflow/publish/command.py/0
{ "file_path": "LabWorkflows/workflow/publish/command.py", "repo_id": "LabWorkflows", "token_count": 1714 }
4
# DevChat Changelog ## Unreleased ### Added - EAP version of the DevChat
devchat-intellij/CHANGELOG.md/0
{ "file_path": "devchat-intellij/CHANGELOG.md", "repo_id": "devchat-intellij", "token_count": 26 }
5
{ "name": "devchat-intellij", "scripts": { "build": "cd ./gui && yarn && yarn idea" } }
devchat-intellij/package.json/0
{ "file_path": "devchat-intellij/package.json", "repo_id": "devchat-intellij", "token_count": 43 }
6
package ai.devchat.core.handlers import ai.devchat.common.Log import ai.devchat.core.BaseActionHandler import ai.devchat.core.DevChatActions import ai.devchat.plugin.currentProject import com.alibaba.fastjson.JSONObject import java.io.BufferedReader import java.io.File class CommitCodeRequestHandler(requestAction: St...
devchat-intellij/src/main/kotlin/ai/devchat/core/handlers/CommitCodeRequestHandler.kt/0
{ "file_path": "devchat-intellij/src/main/kotlin/ai/devchat/core/handlers/CommitCodeRequestHandler.kt", "repo_id": "devchat-intellij", "token_count": 450 }
7
package ai.devchat.core.handlers import ai.devchat.core.DevChatResponse import ai.devchat.common.Log import ai.devchat.core.BaseActionHandler import ai.devchat.core.DevChatActions import ai.devchat.storage.ActiveConversation import ai.devchat.storage.CONFIG import com.alibaba.fastjson.JSONObject import java.io.File im...
devchat-intellij/src/main/kotlin/ai/devchat/core/handlers/SendMessageRequestHandler.kt/0
{ "file_path": "devchat-intellij/src/main/kotlin/ai/devchat/core/handlers/SendMessageRequestHandler.kt", "repo_id": "devchat-intellij", "token_count": 3427 }
8
package ai.devchat.plugin.actions import ai.devchat.common.Log.info import ai.devchat.core.DevChatActions import ai.devchat.core.handlers.AddContextNotifyHandler import com.alibaba.fastjson.JSONObject class AddToDevChatAction { fun execute(filePath: String, fileContent: String, language: String, startLine: Int, i...
devchat-intellij/src/main/kotlin/ai/devchat/plugin/actions/AddToDevChatAction.kt/0
{ "file_path": "devchat-intellij/src/main/kotlin/ai/devchat/plugin/actions/AddToDevChatAction.kt", "repo_id": "devchat-intellij", "token_count": 437 }
9
package ai.devchat.storage import com.intellij.openapi.application.ApplicationManager import com.intellij.openapi.components.PersistentStateComponent import com.intellij.openapi.components.Service import com.intellij.openapi.components.State import com.intellij.openapi.components.Storage import com.intellij.util.xmlb....
devchat-intellij/src/main/kotlin/ai/devchat/storage/DevChatState.kt/0
{ "file_path": "devchat-intellij/src/main/kotlin/ai/devchat/storage/DevChatState.kt", "repo_id": "devchat-intellij", "token_count": 365 }
10
import * as path from 'path'; import { ChatContext } from './contextManager'; import { createTempSubdirectory, runCommandStringAndWriteOutput } from '../util/commonUtil'; import { logger } from '../util/logger'; export const gitDiffCachedContext: ChatContext = { name: 'git diff --cached', description: 'the stage...
devchat-vscode/src/context/contextGitDiffCached.ts/0
{ "file_path": "devchat-vscode/src/context/contextGitDiffCached.ts", "repo_id": "devchat-vscode", "token_count": 284 }
11
import * as path from 'path'; import * as fs from 'fs'; import { getAst, getTreePathAtCursor, RangeInFileWithContents } from "./ast/ast"; import Parser from "web-tree-sitter"; import { logger } from "../../util/logger"; import { getCommentPrefix, getLangageFunctionConfig, getLanguageFullName, LanguageFunctionsConfig } ...
devchat-vscode/src/contributes/codecomplete/astTest.ts/0
{ "file_path": "devchat-vscode/src/contributes/codecomplete/astTest.ts", "repo_id": "devchat-vscode", "token_count": 436 }
12
/* 获取符号名称、符号类型(函数、变量、类等)、符号所在文件路径、符号所在行数等信息 猜想这些信息会有助于代码补全功能的准确率提升 */
devchat-vscode/src/contributes/codecomplete/symbols.ts/0
{ "file_path": "devchat-vscode/src/contributes/codecomplete/symbols.ts", "repo_id": "devchat-vscode", "token_count": 144 }
13
/* check whether some feature is enabled */ import * as vscode from 'vscode'; import { regInMessage, regOutMessage } from '../util/reg_messages'; import { logger } from '../util/logger'; import { FT, FTs } from '../util/feature_flags/feature_toggles'; import { MessageHandler } from './messageHandler'; regInMessage({c...
devchat-vscode/src/handler/featureToggleHandler.ts/0
{ "file_path": "devchat-vscode/src/handler/featureToggleHandler.ts", "repo_id": "devchat-vscode", "token_count": 349 }
14
import * as vscode from "vscode"; import { IDEService } from "../types"; import { assert } from "console"; /** * Find definition locations for a symbol * * @param abspath: absolute path of the file * @param line: line number of the symbol, 0-based * @param character: character number, 0-based */ export async f...
devchat-vscode/src/ide_services/endpoints/findDefs.ts/0
{ "file_path": "devchat-vscode/src/ide_services/endpoints/findDefs.ts", "repo_id": "devchat-vscode", "token_count": 675 }
15
import * as vscode from 'vscode'; import * as path from 'path'; import WebviewManager from './webviewManager'; import '../handler/handlerRegister'; import handleMessage from '../handler/messageHandler'; import { createChatDirectoryAndCopyInstructionsSync } from '../init/chatConfig'; import { ExtensionContextHolder } f...
devchat-vscode/src/panel/devchatView.ts/0
{ "file_path": "devchat-vscode/src/panel/devchatView.ts", "repo_id": "devchat-vscode", "token_count": 814 }
16
import * as vscode from 'vscode'; import { ExtensionContextHolder } from './extensionContext'; import { UiUtil } from './uiUtil'; import { logger } from './logger'; export class UiUtilVscode implements UiUtil { public async languageId(uri: string): Promise<string> { const document = await vscode.workspace.openTex...
devchat-vscode/src/util/uiUtil_vscode.ts/0
{ "file_path": "devchat-vscode/src/util/uiUtil_vscode.ts", "repo_id": "devchat-vscode", "token_count": 1248 }
17
import os import subprocess import sys import threading import commit_cases ROOT_DIR = os.path.dirname(os.path.abspath(__file__)) def run_devchat_command(model, commit_command, input_mock): timeout = 300 # 超时时间,单位为秒 # 构建命令 command = [ sys.executable, '-m', 'devchat', 'route', '-m', 'gpt-3.5-tu...
devchat-vscode/test/workflows/workflow_test.py/0
{ "file_path": "devchat-vscode/test/workflows/workflow_test.py", "repo_id": "devchat-vscode", "token_count": 1441 }
18
# pylint: disable=import-outside-toplevel import json import sys import time from typing import Optional, List, Dict from dataclasses import dataclass, field from .command import command, Command @dataclass class PromptData: model: str = "none" messages: Optional[List[Dict]] = field(default_factory=list) ...
devchat/devchat/_cli/log.py/0
{ "file_path": "devchat/devchat/_cli/log.py", "repo_id": "devchat", "token_count": 1624 }
19
# disable pylint # pylint: disable=W0613 # pylint: disable=E1133 # pylint: disable=R1710 # pylint: disable=W0719 # pylint: disable=W3101 # pylint: disable=C0103 from typing import List from .rpc import rpc_method from .types import Location, SymbolNode, LocationWithText from .vscode_services import selected_range, vi...
devchat/devchat/ide/service.py/0
{ "file_path": "devchat/devchat/ide/service.py", "repo_id": "devchat", "token_count": 1945 }
20
import ast import json from dataclasses import dataclass, asdict, field, fields from typing import Dict, Optional from devchat.message import Message @dataclass class OpenAIMessage(Message): role: str = None name: Optional[str] = None function_call: Dict[str, str] = field(default_factory=dict) def _...
devchat/devchat/openai/openai_message.py/0
{ "file_path": "devchat/devchat/openai/openai_message.py", "repo_id": "devchat", "token_count": 1450 }
21
{ "choices": [ { "delta": { "content": "." }, "finish_reason": null, "index": 0 } ], "created": 1682163460, "id": "chatcmpl-785qeSHlUo3lH4OnLuovtk3NqLcD6", "model": "gpt-3.5-turbo-0301", "object": "chat.completion.ch...
devchat/tests/stream_responses/response5.json/0
{ "file_path": "devchat/tests/stream_responses/response5.json", "repo_id": "devchat", "token_count": 207 }
22
description: Explain selected code. steps: - run: $devchat_python $command_path/explain.py
workflows/explain/command.yml/0
{ "file_path": "workflows/explain/command.yml", "repo_id": "workflows", "token_count": 29 }
23
import os from functools import wraps from typing import List import requests from .types import Location, SymbolNode BASE_SERVER_URL = os.environ.get("DEVCHAT_IDE_SERVICE_URL", "http://localhost:3000") def rpc_method(f): """ Decorator for Service methods """ @wraps(f) def wrapper(self, *args,...
workflows/libs/ide_services/service.py/0
{ "file_path": "workflows/libs/ide_services/service.py", "repo_id": "workflows", "token_count": 1339 }
24
import os import re import sys from devchat.ide.service import IDEService from devchat.ide.vscode_services import selected_lines, visible_lines from devchat.llm import chat def get_selected_code(): """ Retrieves the selected lines of code from the user's selection. This function extracts the text select...
workflows/refactor/rewrite.py/0
{ "file_path": "workflows/refactor/rewrite.py", "repo_id": "workflows", "token_count": 1641 }
25
import gettext import os from enum import Enum class TUILanguage(Enum): EN = ("en", "English") ZH = ("zh", "Chinese") Other = ("en", "English") # default to show English @classmethod def from_str(cls, language: str) -> "TUILanguage": if language.lower().startswith("en"): retu...
workflows/unit_tests/i18n.py/0
{ "file_path": "workflows/unit_tests/i18n.py", "repo_id": "workflows", "token_count": 418 }
26
import os import re import sys from collections import defaultdict from typing import Dict, List, Optional, Tuple from tools.file_util import retrieve_file_content sys.path.append(os.path.join(os.path.dirname(__file__), "..", "..")) from libs.ide_services import Position, SymbolNode def split_tokens(text: str) -> ...
workflows/unit_tests/tools/symbol_util.py/0
{ "file_path": "workflows/unit_tests/tools/symbol_util.py", "repo_id": "workflows", "token_count": 1171 }
27
description: 'Streamlit browser' input: optional steps: - run: $command_python -m streamlit run $command_path/command.py --server.port 8900 --browser.serverAddress 0.0.0.0
LabWorkflows/browser/command.yml/0
{ "file_path": "LabWorkflows/browser/command.yml", "repo_id": "LabWorkflows", "token_count": 54 }
0
import json import sys import os home = os.path.expanduser("~") org_libs_path = os.path.join(home, ".chat", "workflows", "org", "libs") sys_libs_path = os.path.join(home, ".chat", "workflows", "sys", "libs") sys.path.append(org_libs_path) sys.path.append(sys_libs_path) sys.path.append(os.path.join(os.path.dirname(os....
LabWorkflows/git/new_branch/command.py/0
{ "file_path": "LabWorkflows/git/new_branch/command.py", "repo_id": "LabWorkflows", "token_count": 1043 }
1
import sys import os import requests import json import yaml from litellm import completion home = os.path.expanduser("~") org_libs_path = os.path.join(home, ".chat", "workflows", "org", "libs") sys_libs_path = os.path.join(home, ".chat", "workflows", "sys", "libs") sys.path.append(org_libs_path) sys.path.append(sys_...
LabWorkflows/llm/command.py/0
{ "file_path": "LabWorkflows/llm/command.py", "repo_id": "LabWorkflows", "token_count": 1343 }
2
description: 'Ping test' input: required steps: - run: $devchat_python $command_path/command.py "$input"
LabWorkflows/ping-test/command.yml/0
{ "file_path": "LabWorkflows/ping-test/command.yml", "repo_id": "LabWorkflows", "token_count": 34 }
3
import os import sys import re import json home = os.path.expanduser("~") org_libs_path = os.path.join(home, ".chat", "workflows", "org", "libs") sys_libs_path = os.path.join(home, ".chat", "workflows", "sys", "libs") sys.path.append(org_libs_path) sys.path.append(sys_libs_path) from llm_api import chat_completion_st...
LabWorkflows/rewrite/rewrite.py/0
{ "file_path": "LabWorkflows/rewrite/rewrite.py", "repo_id": "LabWorkflows", "token_count": 1758 }
4
""" 当前脚本用于实现 /workflow.edit """ import os import sys import requests sys.path.append(os.path.join(os.path.expanduser('~'), '.chat', 'workflows', 'org', 'libs')) sys.path.append(os.path.join(os.path.expanduser('~'), '.chat', 'workflows', 'sys', 'libs')) from chatmak import Radio from ide_services.vscode_services impo...
LabWorkflows/workflow/edit/command.py/0
{ "file_path": "LabWorkflows/workflow/edit/command.py", "repo_id": "LabWorkflows", "token_count": 557 }
5
description: publish workflow. input: optional steps: - run: $devchat_python $command_path/command.py
LabWorkflows/workflow/publish/command.yml/0
{ "file_path": "LabWorkflows/workflow/publish/command.yml", "repo_id": "LabWorkflows", "token_count": 30 }
6
<div align="center"> <br/> <img src="assets/devchat.png" width="100px" alt=""> <br/> # DevChat IntelliJ Platform Plugin **The AI Coding Assistant Made Effective with Human in the Loop** 🛠️ No excessive automation, just right AI where it works. ☕ Simple to use, without complicated prompt engineering. 🍻 Designed f...
devchat-intellij/README.md/0
{ "file_path": "devchat-intellij/README.md", "repo_id": "devchat-intellij", "token_count": 953 }
7
plugins { id("org.gradle.toolchains.foojay-resolver-convention") version "0.8.0" } rootProject.name = "devchat"
devchat-intellij/settings.gradle.kts/0
{ "file_path": "devchat-intellij/settings.gradle.kts", "repo_id": "devchat-intellij", "token_count": 45 }
8
package ai.devchat.core.handlers import ai.devchat.core.BaseActionHandler import ai.devchat.core.DevChatActions import com.alibaba.fastjson.JSONObject class DeleteLastConversationRequestHandler(requestAction: String, metadata: JSONObject?, payload: JSONObject?) : BaseActionHandler( requestAction, metadata, ...
devchat-intellij/src/main/kotlin/ai/devchat/core/handlers/DeleteLastConversationRequestHandler.kt/0
{ "file_path": "devchat-intellij/src/main/kotlin/ai/devchat/core/handlers/DeleteLastConversationRequestHandler.kt", "repo_id": "devchat-intellij", "token_count": 220 }
9
package ai.devchat.core.handlers import ai.devchat.core.* import com.alibaba.fastjson.JSONObject class SendUserMessageHandler(requestAction: String, metadata: JSONObject?, payload: JSONObject?) : BaseActionHandler( requestAction, metadata, payload ) { override val actionName: String = DevChatActions....
devchat-intellij/src/main/kotlin/ai/devchat/core/handlers/SendUserMessageHandler.kt/0
{ "file_path": "devchat-intellij/src/main/kotlin/ai/devchat/core/handlers/SendUserMessageHandler.kt", "repo_id": "devchat-intellij", "token_count": 231 }
10
package ai.devchat.plugin.actions import ai.devchat.common.DevChatBundle import ai.devchat.plugin.DevChatToolWindow import ai.devchat.storage.CONFIG import com.intellij.openapi.actionSystem.ActionUpdateThread import com.intellij.openapi.actionSystem.AnAction import com.intellij.openapi.actionSystem.AnActionEvent impor...
devchat-intellij/src/main/kotlin/ai/devchat/plugin/actions/AddToDevChatEditorAction.kt/0
{ "file_path": "devchat-intellij/src/main/kotlin/ai/devchat/plugin/actions/AddToDevChatEditorAction.kt", "repo_id": "devchat-intellij", "token_count": 886 }
11
package ai.devchat.storage import com.intellij.credentialStore.CredentialAttributes import com.intellij.credentialStore.Credentials import com.intellij.credentialStore.generateServiceName import com.intellij.ide.passwordSafe.PasswordSafe object SensitiveDataStorage { private const val KEY_NAME = "USER_KEY" pr...
devchat-intellij/src/main/kotlin/ai/devchat/storage/SensitiveDataStorage.kt/0
{ "file_path": "devchat-intellij/src/main/kotlin/ai/devchat/storage/SensitiveDataStorage.kt", "repo_id": "devchat-intellij", "token_count": 356 }
12
import * as path from 'path'; import { logger } from '../util/logger'; import { createTempSubdirectory } from '../util/commonUtil'; import CustomContexts from './customContext'; import { UiUtilWrapper } from '../util/uiUtil'; export interface ChatContext { name: string; description: string; handler: () =...
devchat-vscode/src/context/contextManager.ts/0
{ "file_path": "devchat-vscode/src/context/contextManager.ts", "repo_id": "devchat-vscode", "token_count": 874 }
13
/* 使用内存存储最近的代码补全结果 */ type CacheItem = { value: any; timestamp: number; }; class MemoryCacheManager { private maxCapacity: number = 5; private cache: Map<string, CacheItem>; constructor(maxCapacity: number = 5) { this.maxCapacity = maxCapacity; this.cache = new Map<string, CacheI...
devchat-vscode/src/contributes/codecomplete/cache.ts/0
{ "file_path": "devchat-vscode/src/contributes/codecomplete/cache.ts", "repo_id": "devchat-vscode", "token_count": 1031 }
14
import * as vscode from 'vscode'; export interface Range { start: Position; end: Position; } export interface Position { line: number; character: number; } export interface RangeInFile { filepath: string; range: Range; } export async function readRangeInFile( filepath: string, range:...
devchat-vscode/src/contributes/codecomplete/utils.ts/0
{ "file_path": "devchat-vscode/src/contributes/codecomplete/utils.ts", "repo_id": "devchat-vscode", "token_count": 1072 }
15
import * as vscode from 'vscode'; import * as fs from "fs"; import { MessageHandler } from './messageHandler'; import { regInMessage, regOutMessage } from '../util/reg_messages'; import { logger } from "../util/logger"; // New: writeFile message handler regInMessage({ command: 'writeFile', file: '', content: '' }); ...
devchat-vscode/src/handler/fileHandler.ts/0
{ "file_path": "devchat-vscode/src/handler/fileHandler.ts", "repo_id": "devchat-vscode", "token_count": 433 }
16
import * as vscode from 'vscode'; import { dependencyCheck } from './statusBarViewBase'; import { ProgressBar } from '../util/progressBar'; import { logger } from '../util/logger'; import { DevChatConfig } from '../util/config'; export function createStatusBarItem(context: vscode.ExtensionContext): vscode.StatusBarI...
devchat-vscode/src/panel/statusBarView.ts/0
{ "file_path": "devchat-vscode/src/panel/statusBarView.ts", "repo_id": "devchat-vscode", "token_count": 835 }
17
export interface LogChannel { info(message: string, ...args: any[]): void; warn(message: string, ...args: any[]): void; error(message: string | Error, ...args: any[]): void; debug(message: string, ...args: any[]): void; show(): void; } // eslint-disable-next-line @typescript-eslint/naming-convention export class...
devchat-vscode/src/util/logger.ts/0
{ "file_path": "devchat-vscode/src/util/logger.ts", "repo_id": "devchat-vscode", "token_count": 173 }
18
import { expect } from 'chai'; // import { describe, it, afterEach, beforeEach } from 'mocha'; import { handleCodeSelected } from '../../src/context/contextCodeSelected'; import * as path from 'path'; import { UiUtilWrapper } from '../../src/util/uiUtil'; import sinon from 'sinon'; describe('handleCodeSelected', () =>...
devchat-vscode/test/context/contextCodeSelected.test.ts/0
{ "file_path": "devchat-vscode/test/context/contextCodeSelected.test.ts", "repo_id": "devchat-vscode", "token_count": 580 }
19
{ "compilerOptions": { "module": "commonjs", "target": "ES2020", "lib": [ "ES2020", "es6", "dom" ], "outDir": "./dist", "sourceMap": true, "rootDir": "src", "strict": true, "jsx": "react", "esModuleInterop": true, "noImplicitAny": false, "paths": { "@/*": [ "./src/*" ] } }...
devchat-vscode/tsconfig.json/0
{ "file_path": "devchat-vscode/tsconfig.json", "repo_id": "devchat-vscode", "token_count": 193 }
20
""" This module contains the main function for the DevChat CLI. """ import argparse import sys from devchat.utils import get_logger # pylint: disable=unused-import from devchat._cli import log from devchat._cli import prompt from devchat._cli import run from devchat._cli import topic from devchat._cli import route from...
devchat/devchat/_cli/main.py/0
{ "file_path": "devchat/devchat/_cli/main.py", "repo_id": "devchat", "token_count": 321 }
21
from typing import List from pydantic import BaseModel __all__ = [ "Position", "Range", "Location", "SymbolNode", "LocationWithText" ] class Position(BaseModel): line: int # 0-based character: int # 0-based def __repr__(self): return f"Ln{self.line}:Col{self.character}" ...
devchat/devchat/ide/types.py/0
{ "file_path": "devchat/devchat/ide/types.py", "repo_id": "devchat", "token_count": 477 }
22
from dataclasses import dataclass import json import sys from typing import List, Optional from devchat.prompt import Prompt from devchat.message import Message from devchat.utils import update_dict, get_logger from devchat.utils import openai_message_tokens, openai_response_tokens from .openai_message import OpenAIMes...
devchat/devchat/openai/openai_prompt.py/0
{ "file_path": "devchat/devchat/openai/openai_prompt.py", "repo_id": "devchat", "token_count": 4905 }
23
import os import sys from devchat.ide.service import IDEService from devchat.llm import chat def get_selected_code(): """ Retrieves the selected lines of code from the user's selection. This function extracts the text selected by the user in their IDE or text editor. If no text has been selected, it...
workflows/explain/explain.py/0
{ "file_path": "workflows/explain/explain.py", "repo_id": "workflows", "token_count": 1077 }
24
import os USE_USER_MODEL = bool(os.environ.get("DEVCHAT_UNIT_TESTS_USE_USER_MODEL", False)) USER_LLM_MODEL = os.environ.get("LLM_MODEL", "gpt-4-turbo-preview") DEFAULT_CONTEXT_SIZE = 4000 CONTEXT_SIZE = { "gpt-3.5-turbo": 16000, "gpt-4": 8000, "gpt-4-turbo-preview": 128000, "claude-3-sonnet": 1000000,...
workflows/unit_tests/llm_conf.py/0
{ "file_path": "workflows/unit_tests/llm_conf.py", "repo_id": "workflows", "token_count": 328 }
25
import tiktoken def get_encoding(encoding_name: str): """ Get a tiktoken encoding by name. """ try: return tiktoken.get_encoding(encoding_name) except Exception: from tiktoken import registry from tiktoken.core import Encoding from tiktoken.registry import _find_con...
workflows/unit_tests/tools/tiktoken_util.py/0
{ "file_path": "workflows/unit_tests/tools/tiktoken_util.py", "repo_id": "workflows", "token_count": 242 }
26