text stringlengths 7 1.68M | id stringlengths 17 99 | metadata dict | __index_level_0__ int64 0 33 |
|---|---|---|---|
import * as path from 'path';
import * as fsE from 'fs';
import fs from 'fs/promises';
import { logger } from '../../../util/logger';
import { embeddingQuery, embeddingBlocks, getFileBlock } from './embedding';
import { UiUtilWrapper } from '../../../util/uiUtil';
import { getLanguageFullName } from '../ast/language';
... | devchat-vscode/src/contributes/codecomplete/symbolindex/index.ts/0 | {
"file_path": "devchat-vscode/src/contributes/codecomplete/symbolindex/index.ts",
"repo_id": "devchat-vscode",
"token_count": 5036
} | 13 |
import * as vscode from 'vscode';
import * as path from 'path';
import { createTempSubdirectory } from '../util/commonUtil';
import { regInMessage, regOutMessage } from '../util/reg_messages';
import { applyCodeChanges, isValidActionString } from '../util/appyDiff';
import { logger } from '../util/logger';
import { Fi... | devchat-vscode/src/handler/diffHandler.ts/0 | {
"file_path": "devchat-vscode/src/handler/diffHandler.ts",
"repo_id": "devchat-vscode",
"token_count": 1330
} | 14 |
# IDE Service
This module is the VSCode implementation of IDE Service Protocol. | devchat-vscode/src/ide_services/README.md/0 | {
"file_path": "devchat-vscode/src/ide_services/README.md",
"repo_id": "devchat-vscode",
"token_count": 18
} | 15 |
import * as vscode from "vscode";
import * as fs from "fs";
import * as path from "path";
import { logger } from "../util/logger";
import { log } from "console";
interface FunctionDefinition {
name: string;
containerName: string | null;
containerRange: vscode.Range | null;
range: vscode.Range;
}
type CodeLens... | devchat-vscode/src/panel/codeLens.ts/0 | {
"file_path": "devchat-vscode/src/panel/codeLens.ts",
"repo_id": "devchat-vscode",
"token_count": 3369
} | 16 |
import * as vscode from 'vscode';
import * as fs from 'fs';
import * as path from 'path';
import { DevChatConfig } from '../config';
const featureTogglesJson = `
{
"ask-code-summary": false,
"ask-code": true,
"ask-code-dfs": false
}`;
const featureToggles = JSON.parse(featureTogglesJson);
// eslint-disable-next-l... | devchat-vscode/src/util/feature_flags/feature_toggles.ts/0 | {
"file_path": "devchat-vscode/src/util/feature_flags/feature_toggles.ts",
"repo_id": "devchat-vscode",
"token_count": 304
} | 17 |
export interface UiUtil {
languageId(uri: string): Promise<string>;
workspaceFoldersFirstPath(): string | undefined;
secretStorageGet(key: string): Promise<string | undefined>;
writeFile(uri: string, content: string): Promise<void>;
showInputBox(option: object): Promise<string | undefined>;
storeSecret(key: stri... | devchat-vscode/src/util/uiUtil.ts/0 | {
"file_path": "devchat-vscode/src/util/uiUtil.ts",
"repo_id": "devchat-vscode",
"token_count": 793
} | 18 |
"""
checkbox:
```chatmark type=form
Which files would you like to commit? I've suggested a few.
> [x](file1) devchat/engine/prompter.py
> [x](file2) devchat/prompt.py
> [](file3) tests/test_cli_prompt.py
```
radio:
```chatmark type=form
How would you like to make the change?
> - (insert) Insert the new code.
> - (new... | devchat-vscode/test/workflows/ui_parser.py/0 | {
"file_path": "devchat-vscode/test/workflows/ui_parser.py",
"repo_id": "devchat-vscode",
"token_count": 1379
} | 19 |
class MissContentInPromptException(Exception):
pass
| devchat/devchat/_cli/errors.py/0 | {
"file_path": "devchat/devchat/_cli/errors.py",
"repo_id": "devchat",
"token_count": 18
} | 20 |
# pylint: disable=C0103
# pylint: disable=W3101
# pylint: disable=W0719
# pylint: disable=R1710
# pylint: disable=W0212
import os
from functools import wraps
import requests
BASE_SERVER_URL = os.environ.get("DEVCHAT_IDE_SERVICE_URL", "http://localhost:3000")
def rpc_call(f):
@wraps(f)
def wrapper(*args, **k... | devchat/devchat/ide/rpc.py/0 | {
"file_path": "devchat/devchat/ide/rpc.py",
"repo_id": "devchat",
"token_count": 1125
} | 21 |
# pylint: disable=import-outside-toplevel
import json
import os
from typing import Optional, Union, List, Dict, Iterator
from pydantic import BaseModel, Field
from devchat.chat import Chat
from devchat.utils import get_user_info, user_id
from .openai_message import OpenAIMessage
from .openai_prompt import OpenAIPrompt... | devchat/devchat/openai/openai_chat.py/0 | {
"file_path": "devchat/devchat/openai/openai_chat.py",
"repo_id": "devchat",
"token_count": 2050
} | 22 |
version: 2.1
commands:
git_diff:
description: "Runs the 'git diff' command with optional flags and a specified path."
parameters:
option_string:
type: string
default: ""
description: "Optional flags or arguments to pass to the 'git diff' command."
path:
type: string... | devchat/workflow/commands/git/git.yml/0 | {
"file_path": "devchat/workflow/commands/git/git.yml",
"repo_id": "devchat",
"token_count": 339
} | 23 |
# flake8: noqa: E402
import os
import re
import subprocess
import sys
sys.path.append(os.path.join(os.path.dirname(__file__), "..", "libs"))
sys.path.append(os.path.join(os.path.dirname(__file__), "..", "..", "libs"))
sys.path.append(os.path.dirname(__file__))
from chatmark import Checkbox, Form, TextEditor # noqa: ... | workflows/commit/commit.py/0 | {
"file_path": "workflows/commit/commit.py",
"repo_id": "workflows",
"token_count": 6799
} | 24 |
### 操作指南
生成代码解释,请按照如下步骤操作:
1. 选中行间代码。
2. 输入\/explain,回车发送;或右键点击**DevChat: Generate Explain**按钮。
3. 开始生成代码解释,等待生成结束。
如图所示:
 | workflows/explain/README.md/0 | {
"file_path": "workflows/explain/README.md",
"repo_id": "workflows",
"token_count": 207
} | 25 |
import os
from functools import wraps
import requests
BASE_SERVER_URL = os.environ.get("DEVCHAT_IDE_SERVICE_URL", "http://localhost:3000")
def rpc_call(f):
@wraps(f)
def wrapper(*args, **kwargs):
if os.environ.get("DEVCHAT_IDE_SERVICE_URL", "") == "":
# maybe in a test, user don't want t... | workflows/libs/ide_services/rpc.py/0 | {
"file_path": "workflows/libs/ide_services/rpc.py",
"repo_id": "workflows",
"token_count": 517
} | 26 |
description: Automatically rename poorly-named local variables for improved readability. Select the code segment and execute this command to optimize variable names.
steps:
- run: $devchat_python $command_path/../rewrite.py "Refine internal variable and function names within the code to achieve concise and meaningful... | workflows/refactor/names/command.yml/0 | {
"file_path": "workflows/refactor/names/command.yml",
"repo_id": "workflows",
"token_count": 76
} | 27 |
from typing import List
from assistants.directory_structure.relevant_file_finder import RelevantFileFinder
from prompts import FIND_REFERENCE_PROMPT
from tools.file_util import verify_file_list
def find_reference_tests(root_path: str, function_name: str, file_path: str) -> List[str]:
"""Find reference tests for ... | workflows/unit_tests/find_reference_tests.py/0 | {
"file_path": "workflows/unit_tests/find_reference_tests.py",
"repo_id": "workflows",
"token_count": 384
} | 28 |
import functools
import os
from collections import defaultdict
from pathlib import Path
from typing import Callable, Dict, List
import pathspec
# NOTE: git-ignore pattern examples
# https://www.atlassian.com/git/tutorials/saving-changes/gitignore#git-ignore-patterns
def load_gitignore_spec_from_file(
ignore_fil... | workflows/unit_tests/tools/git_util.py/0 | {
"file_path": "workflows/unit_tests/tools/git_util.py",
"repo_id": "workflows",
"token_count": 1865
} | 29 |
"""
根据当前测试用例文件,生成新的单元测试用例
"""
import sys
import os
import json
from typing import List
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_... | LabWorkflows/add_tests/command.py/0 | {
"file_path": "LabWorkflows/add_tests/command.py",
"repo_id": "LabWorkflows",
"token_count": 1898
} | 0 |
description: 'Writes a well-formatted commit message for selected code changes and commits them via Git. Include an issue number if desired (e.g., input "/commit to close #12").'
hint: to close Issue #issue_number
input: optional
steps:
- run: $devchat_python $command_path/commit.py "$input" "english" | LabWorkflows/git/commit/command.yml/0 | {
"file_path": "LabWorkflows/git/commit/command.yml",
"repo_id": "LabWorkflows",
"token_count": 84
} | 1 |
import subprocess
import requests
import time
import json
# Reuse the GitHub related variables from the context
ISSUE_REPO_URL = "https://github.com/devchat-ai/devchat/issues"
ISSUE_API_URL = "https://api.github.com/repos/devchat-ai/devchat/issues"
GITHUB_ACCESS_TOKEN = "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"
GIT... | LabWorkflows/git/git_api.py/0 | {
"file_path": "LabWorkflows/git/git_api.py",
"repo_id": "LabWorkflows",
"token_count": 5479
} | 2 |
description: "ide services demo"
steps:
- run: $devchat_python $command_path/command.py | LabWorkflows/ide_service_demo/command.yml/0 | {
"file_path": "LabWorkflows/ide_service_demo/command.yml",
"repo_id": "LabWorkflows",
"token_count": 28
} | 3 |
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)
fr... | LabWorkflows/optimize_naming/command.py/0 | {
"file_path": "LabWorkflows/optimize_naming/command.py",
"repo_id": "LabWorkflows",
"token_count": 413
} | 4 |
description: add doc comment for selected code
steps:
- run: $devchat_python $command_path/../rewrite.py "add doc comment" | LabWorkflows/rewrite/doc_comment/command.yml/0 | {
"file_path": "LabWorkflows/rewrite/doc_comment/command.yml",
"repo_id": "LabWorkflows",
"token_count": 36
} | 5 |
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Palette2">
<group name="Swing">
<item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false... | devchat-intellij/.idea/uiDesigner.xml/0 | {
"file_path": "devchat-intellij/.idea/uiDesigner.xml",
"repo_id": "devchat-intellij",
"token_count": 3616
} | 6 |
#!/bin/sh
#
# Copyright © 2015-2021 the original authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicab... | devchat-intellij/gradlew/0 | {
"file_path": "devchat-intellij/gradlew",
"repo_id": "devchat-intellij",
"token_count": 3158
} | 7 |
package ai.devchat.core.handlers
import ai.devchat.core.*
import com.alibaba.fastjson.JSONObject
class AddContextNotifyHandler(requestAction: String, metadata: JSONObject?, payload: JSONObject?) : BaseActionHandler(
requestAction,
metadata,
payload
) {
override val actionName: String = DevChatActions... | devchat-intellij/src/main/kotlin/ai/devchat/core/handlers/AddContextNotifyHandler.kt/0 | {
"file_path": "devchat-intellij/src/main/kotlin/ai/devchat/core/handlers/AddContextNotifyHandler.kt",
"repo_id": "devchat-intellij",
"token_count": 250
} | 8 |
package ai.devchat.core.handlers
import ai.devchat.core.BaseActionHandler
import ai.devchat.core.DevChatActions
import com.alibaba.fastjson.JSONObject
import com.intellij.ide.BrowserUtil
import java.net.URL
class OpenLinkRequestHandler(requestAction: String, metadata: JSONObject?, payload: JSONObject?) : BaseActionHa... | devchat-intellij/src/main/kotlin/ai/devchat/core/handlers/OpenLinkRequestHandler.kt/0 | {
"file_path": "devchat-intellij/src/main/kotlin/ai/devchat/core/handlers/OpenLinkRequestHandler.kt",
"repo_id": "devchat-intellij",
"token_count": 211
} | 9 |
package ai.devchat.plugin
import ai.devchat.common.Log
import ai.devchat.common.Notifier
import ai.devchat.storage.CONFIG
import com.intellij.codeInsight.navigation.actions.GotoTypeDeclarationAction
import com.intellij.lang.Language
import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi... | devchat-intellij/src/main/kotlin/ai/devchat/plugin/IDEServer.kt/0 | {
"file_path": "devchat-intellij/src/main/kotlin/ai/devchat/plugin/IDEServer.kt",
"repo_id": "devchat-intellij",
"token_count": 5924
} | 10 |
package ai.devchat.storage
import ai.devchat.common.PathUtils
import com.fasterxml.jackson.core.type.TypeReference
import com.fasterxml.jackson.databind.ObjectMapper
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory
import com.fasterxml.jackson.module.kotlin.registerKotlinModule
import com.moandjiezana.toml.Tom... | devchat-intellij/src/main/kotlin/ai/devchat/storage/DevChatConfig.kt/0 | {
"file_path": "devchat-intellij/src/main/kotlin/ai/devchat/storage/DevChatConfig.kt",
"repo_id": "devchat-intellij",
"token_count": 1893
} | 11 |
<div align="center">
<br/>
<img src="assets/devchat.png" width="100px" alt="">
<br/>
# DevChat Visual Studio Code Extension
**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.
🍻 Design... | devchat-vscode/README.md/0 | {
"file_path": "devchat-vscode/README.md",
"repo_id": "devchat-vscode",
"token_count": 2613
} | 12 |
import * as fs from 'fs';
import * as path from 'path';
// 对代码文件进行管理,记录每个文件的block信息
// 同时支持本地文件存储结果,以及支持针对新变量集合进行相似度计算,并返回相似度最高的一组block
import { BlockInfo, FileBlockInfo } from "./types";
import { UiUtilWrapper } from '../../../util/uiUtil';
// difine interface for {score: number, block: BlockInfo}
export interface S... | devchat-vscode/src/contributes/codecomplete/astIndex/indexStore.ts/0 | {
"file_path": "devchat-vscode/src/contributes/codecomplete/astIndex/indexStore.ts",
"repo_id": "devchat-vscode",
"token_count": 2354
} | 13 |
import * as path from 'path';
import * as fs from 'fs';
import fspromises from 'fs/promises';
import { getAst } from '../ast/ast';
import Parser from 'web-tree-sitter';
import { UiUtilWrapper } from '../../../util/uiUtil';
import { findFunctionRanges } from '../ast/findFunctions';
import { findIdentifiers } from '../as... | devchat-vscode/src/contributes/codecomplete/symbolindex/embedding.ts/0 | {
"file_path": "devchat-vscode/src/contributes/codecomplete/symbolindex/embedding.ts",
"repo_id": "devchat-vscode",
"token_count": 4140
} | 14 |
import * as vscode from 'vscode';
import * as fs from "fs";
import { ChatContextManager } from '../context/contextManager';
import { MessageHandler } from './messageHandler';
import { regInMessage, regOutMessage } from '../util/reg_messages';
import { logger } from "../util/logger";
regInMessage({command: 'addContex... | devchat-vscode/src/handler/contextHandler.ts/0 | {
"file_path": "devchat-vscode/src/handler/contextHandler.ts",
"repo_id": "devchat-vscode",
"token_count": 418
} | 15 |
import * as vscode from 'vscode';
import { ChatContextManager } from '../context/contextManager';
import { MessageHandler } from './messageHandler';
import { regInMessage, regOutMessage } from '../util/reg_messages';
regInMessage({command: 'regContextList'});
regOutMessage({command: 'regContextList', result: [{name:... | devchat-vscode/src/handler/workflowContextHandler.ts/0 | {
"file_path": "devchat-vscode/src/handler/workflowContextHandler.ts",
"repo_id": "devchat-vscode",
"token_count": 189
} | 16 |
import * as vscode from 'vscode';
import * as fs from 'fs';
import * as path from 'path';
import { logger } from '../util/logger';
import { UiUtilWrapper } from '../util/uiUtil';
function copyFileSync(source: string, target: string) {
const data = fs.readFileSync(source);
if (!fs.existsSync(target)) {
fs.writeFi... | devchat-vscode/src/init/chatConfig.ts/0 | {
"file_path": "devchat-vscode/src/init/chatConfig.ts",
"repo_id": "devchat-vscode",
"token_count": 688
} | 17 |
import * as vscode from 'vscode';
import { DevChatViewProvider } from '../panel/devchatView';
export class ExtensionContextHolder {
private static _context: vscode.ExtensionContext | undefined;
private static _provider: DevChatViewProvider | undefined;
static set context(context: vscode.ExtensionContext | undef... | devchat-vscode/src/util/extensionContext.ts/0 | {
"file_path": "devchat-vscode/src/util/extensionContext.ts",
"repo_id": "devchat-vscode",
"token_count": 186
} | 18 |
let inMessages: object[] = [];
let outMessages: object[] = [];
export function regInMessage(message: object) {
inMessages.push(message);
}
export function regOutMessage(message: object) {
outMessages.push(message);
}
export function getInMessages(): object[] {
return inMessages;
}
export function getOutMessages... | devchat-vscode/src/util/reg_messages.ts/0 | {
"file_path": "devchat-vscode/src/util/reg_messages.ts",
"repo_id": "devchat-vscode",
"token_count": 112
} | 19 |
import subprocess
import re
import shutil
import os
import json
import ui_parser
import yaml
import openai
# Extract the repository URL and commit hash from the GitHub link
def extract_repo_info(github_link):
match = re.match(r'https://github\.com/(.+)/(.+)/commit/(.+)', github_link)
if not match:
rai... | devchat-vscode/test/workflows/commit_cases.py/0 | {
"file_path": "devchat-vscode/test/workflows/commit_cases.py",
"repo_id": "devchat-vscode",
"token_count": 4239
} | 20 |
commands = {}
class Command:
def __init__(self, name, help_text):
self.parser = None
self.func = None
self.name = name
self.help = help_text
self.options = []
commands[name] = self
def add_option(self, option):
self.options.append(option)
@staticmet... | devchat/devchat/_cli/command.py/0 | {
"file_path": "devchat/devchat/_cli/command.py",
"repo_id": "devchat",
"token_count": 1194
} | 21 |
from .types import LocationWithText
from .rpc import rpc_method
class IdeaIDEService:
def __init__(self):
self._result = None
@rpc_method
def get_visible_range(self) -> LocationWithText:
return LocationWithText.parse_obj(self._result)
@rpc_method
def get_selected_range(self) -> L... | devchat/devchat/ide/idea_services.py/0 | {
"file_path": "devchat/devchat/ide/idea_services.py",
"repo_id": "devchat",
"token_count": 148
} | 22 |
import http.client
import json
import sys
class LineReader:
def __init__(self, response):
self.response = response
def __iter__(self):
return self
def __next__(self):
line = self.response.readline()
if not line:
raise StopIteration
line = line.strip()
... | devchat/devchat/openai/http_openai.py/0 | {
"file_path": "devchat/devchat/openai/http_openai.py",
"repo_id": "devchat",
"token_count": 825
} | 23 |
import pytest
from devchat.utils import parse_files
def test_parse_files_empty_input():
assert not parse_files([])
def test_parse_files_nonexistent_file():
with pytest.raises(ValueError, match="File .* does not exist."):
parse_files(["nonexistent_file.txt"])
def test_parse_files_empty_file(tmpdir)... | devchat/tests/test_utils.py/0 | {
"file_path": "devchat/tests/test_utils.py",
"repo_id": "devchat",
"token_count": 483
} | 24 |
description: 解释当前代码仓库的目录结构
hint: 请帮助我理解当前仓库的目录结构
input: optional
steps:
- run: $command_python $command_path/../main.py "$input" -lang zh | workflows/expl_struct/zh/_command.yml/0 | {
"file_path": "workflows/expl_struct/zh/_command.yml",
"repo_id": "workflows",
"token_count": 99
} | 25 |
from .service import IDEService
from .types import *
__all__ = types.__all__ + [
"IDEService",
]
| workflows/libs/ide_services/__init__.py/0 | {
"file_path": "workflows/libs/ide_services/__init__.py",
"repo_id": "workflows",
"token_count": 39
} | 26 |
import os
import sys
from collections import defaultdict
from dataclasses import dataclass
from typing import Dict, List, Optional, Set
from assistants.recommend_test_context import get_recommended_symbols
from model import FuncToTest
from tools.symbol_util import (
find_symbol_nodes,
get_symbol_content,
l... | workflows/unit_tests/find_context.py/0 | {
"file_path": "workflows/unit_tests/find_context.py",
"repo_id": "workflows",
"token_count": 3314
} | 27 |
import os
from pathlib import Path
from typing import List
def retrieve_file_content(file_path: str, root_path: str) -> str:
"""
Retrieve the content of a file given its relative or absolute path.
If a relative path is provided, it will be joined with the root_path to form an absolute path.
Args:
... | workflows/unit_tests/tools/file_util.py/0 | {
"file_path": "workflows/unit_tests/tools/file_util.py",
"repo_id": "workflows",
"token_count": 1809
} | 28 |
description: run code interpreter
input: optional
steps:
- run: $command_python $command_path/command.py "$input"
| LabWorkflows/code_interpreter/command.yml/0 | {
"file_path": "LabWorkflows/code_interpreter/command.yml",
"repo_id": "LabWorkflows",
"token_count": 33
} | 0 |
import sys
import os
sys.path.append(os.path.join(os.path.dirname(__file__), "..", "..", "..", "libs"))
from llm_api import chat_completion_stream # noqa: E402
messages = [{"role": "user", "content": sys.argv[1]}]
llm_config = {"model": "gpt-4-1106-preview"}
os.environ["OPENAI_API_KEY"] = os.environ["DEVCHAT_API... | LabWorkflows/git/commit/test/prompt/llm_devchat.py/0 | {
"file_path": "LabWorkflows/git/commit/test/prompt/llm_devchat.py",
"repo_id": "LabWorkflows",
"token_count": 193
} | 1 |
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)
from llm_api import (
chat
)
@chat(prompt="hello")
def ... | LabWorkflows/llm_demo/chat/command.py/0 | {
"file_path": "LabWorkflows/llm_demo/chat/command.py",
"repo_id": "LabWorkflows",
"token_count": 222
} | 2 |
{
"sha": "91da857973f5684d0956fa6e623f14edc99adad5504632d6ee4ddac6ae501761",
"command_python": "/Users/admin/miniconda3/envs/pr_test2/bin/python"
} | LabWorkflows/pr/describe/runtime.json/0 | {
"file_path": "LabWorkflows/pr/describe/runtime.json",
"repo_id": "LabWorkflows",
"token_count": 79
} | 3 |
## Add Context(Add to DevChat)
### Java to JS (notify)
```json
{
"action": "addContext/notify",
"metadata": null,
"payload": {
"path": "src/main/Hello.java",
"startLine": 0,
"languageId": "JAVA",
"content": "public static void main(..."
}
}
```
## List Contexts
### JS to Java (command)
```j... | devchat-intellij/api/context.md/0 | {
"file_path": "devchat-intellij/api/context.md",
"repo_id": "devchat-intellij",
"token_count": 523
} | 4 |
package ai.devchat.common
import java.io.IOException
import java.nio.file.*
import java.nio.file.attribute.BasicFileAttributes
object PathUtils {
val workPath: String = Paths.get(System.getProperty("user.home"), ".chat").toString()
val pythonPath: String = Paths.get(workPath, "site-packages").toString()
... | devchat-intellij/src/main/kotlin/ai/devchat/common/PathUtils.kt/0 | {
"file_path": "devchat-intellij/src/main/kotlin/ai/devchat/common/PathUtils.kt",
"repo_id": "devchat-intellij",
"token_count": 971
} | 5 |
package ai.devchat.core.handlers
import ai.devchat.core.BaseActionHandler
import ai.devchat.core.DevChatActions
import ai.devchat.plugin.currentProject
import com.alibaba.fastjson.JSONObject
import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.command.CommandProcessor
import com.intel... | devchat-intellij/src/main/kotlin/ai/devchat/core/handlers/InsertCodeRequestHandler.kt/0 | {
"file_path": "devchat-intellij/src/main/kotlin/ai/devchat/core/handlers/InsertCodeRequestHandler.kt",
"repo_id": "devchat-intellij",
"token_count": 457
} | 6 |
package ai.devchat.core.handlers
import ai.devchat.core.BaseActionHandler
import ai.devchat.core.DevChatActions
import ai.devchat.storage.CONFIG
import com.alibaba.fastjson.JSONObject
class UpdateSettingRequestHandler(requestAction: String, metadata: JSONObject?, payload: JSONObject?) : BaseActionHandler(
request... | devchat-intellij/src/main/kotlin/ai/devchat/core/handlers/UpdateSettingRequestHandler.kt/0 | {
"file_path": "devchat-intellij/src/main/kotlin/ai/devchat/core/handlers/UpdateSettingRequestHandler.kt",
"repo_id": "devchat-intellij",
"token_count": 181
} | 7 |
package ai.devchat.plugin.hints
import ai.devchat.core.DevChatActions
import ai.devchat.core.handlers.SendUserMessageHandler
import ai.devchat.plugin.DevChatToolWindow
import com.alibaba.fastjson.JSONObject
import com.intellij.codeInsight.codeVision.*
import com.intellij.codeInsight.codeVision.ui.model.ClickableTextCo... | devchat-intellij/src/main/kotlin/ai/devchat/plugin/hints/ChatCVProviderBase.kt/0 | {
"file_path": "devchat-intellij/src/main/kotlin/ai/devchat/plugin/hints/ChatCVProviderBase.kt",
"repo_id": "devchat-intellij",
"token_count": 1414
} | 8 |
settings.code.vision.docstring.name=Docstring
settings.code.vision.docstring.hint=Docstring
settings.code.vision.docstring.hint.zh=函数注释
settings.code.vision.docstring.description=Automatically add docstrings. Select a function or method and execute this command to generate docstring.
settings.code.vision.explainCode.na... | devchat-intellij/src/main/resources/messages/DevChatBundle.properties/0 | {
"file_path": "devchat-intellij/src/main/resources/messages/DevChatBundle.properties",
"repo_id": "devchat-intellij",
"token_count": 309
} | 9 |
import * as path from "path";
import Parser from "web-tree-sitter";
import { getParserForFile } from "./treeSitter";
import MemoryCacheManager from "../cache";
import * as crypto from 'crypto';
import { UiUtilWrapper } from "../../../util/uiUtil";
export interface RangeInFileWithContents {
filepath: string;
... | devchat-vscode/src/contributes/codecomplete/ast/ast.ts/0 | {
"file_path": "devchat-vscode/src/contributes/codecomplete/ast/ast.ts",
"repo_id": "devchat-vscode",
"token_count": 1635
} | 10 |
/*
通过LLM模型生成代码补全
*/
import axios from 'axios';
import { logger } from "../../util/logger";
import { Chunk } from 'webpack';
import { DevChatConfig } from '../../util/config';
// 定义代码补全chunk结构内容
export interface CodeCompletionChunk {
text: string;
id: string;
}
export async function* streamComplete(prompt:... | devchat-vscode/src/contributes/codecomplete/llm.ts/0 | {
"file_path": "devchat-vscode/src/contributes/codecomplete/llm.ts",
"repo_id": "devchat-vscode",
"token_count": 5018
} | 11 |
import * as vscode from 'vscode';
import { handleCodeSelected } from '../context/contextCodeSelected';
import { handleFileSelected } from '../context/contextFileSelected';
import { MessageHandler } from '../handler/messageHandler';
import { regOutMessage } from '../util/reg_messages';
import { logger } from '../util/l... | devchat-vscode/src/contributes/util.ts/0 | {
"file_path": "devchat-vscode/src/contributes/util.ts",
"repo_id": "devchat-vscode",
"token_count": 335
} | 12 |
import * as vscode from 'vscode';
import { getInMessages, getOutMessages } from '../util/reg_messages';
import { MessageHandler } from './messageHandler';
export async function listAllMessages(message: any, panel: vscode.WebviewPanel|vscode.WebviewView): Promise<void> {
const inMessages = getInMessages();
const outM... | devchat-vscode/src/handler/listMessages.ts/0 | {
"file_path": "devchat-vscode/src/handler/listMessages.ts",
"repo_id": "devchat-vscode",
"token_count": 161
} | 13 |
import { logger } from "../../util/logger";
import {
createEnvByConda,
createEnvByMamba,
} from "../../util/python_installer/app_install";
import { installRequirements } from "../../util/python_installer/package_install";
export async function installPythonEnv(
command_name: string,
requirements_file:... | devchat-vscode/src/ide_services/endpoints/installPythonEnv.ts/0 | {
"file_path": "devchat-vscode/src/ide_services/endpoints/installPythonEnv.ts",
"repo_id": "devchat-vscode",
"token_count": 927
} | 14 |
declare global {
interface Window {
[key: string]: any;
}
}
export {};
| devchat-vscode/src/types/globle.d.ts/0 | {
"file_path": "devchat-vscode/src/types/globle.d.ts",
"repo_id": "devchat-vscode",
"token_count": 30
} | 15 |
/*
Install conda command
Install file from https://repo.anaconda.com/miniconda/
*/
import { logger } from "../logger";
import { getCondaDownloadUrl } from "./conda_url";
import { downloadFile } from "./https_download";
import { exec, spawn } from 'child_process';
const fs = require('fs');
const path = require('pat... | devchat-vscode/src/util/python_installer/conda_install.ts/0 | {
"file_path": "devchat-vscode/src/util/python_installer/conda_install.ts",
"repo_id": "devchat-vscode",
"token_count": 2434
} | 16 |
// test/mocks/vscode.js
// 定义一个模拟的openTextDocument函数
function openTextDocumentMock() {
return new Promise(resolve => {
// 模拟异步返回一个文档对象
resolve({
// 根据需要模拟文档对象的属性和方法
getText: () => "模拟文档内容",
// 其他需要模拟的方法和属性
});
});
}
// 定义一个模拟的showTextDocument函数
funct... | devchat-vscode/test/mocks/vscode.js/0 | {
"file_path": "devchat-vscode/test/mocks/vscode.js",
"repo_id": "devchat-vscode",
"token_count": 698
} | 17 |
# pylint: disable=import-outside-toplevel
from .command import command, Command
@command('topic', help='Manage topics')
@Command.option('--list', '-l', dest='list_topics', is_flag=True,
help='List topics in reverse chronological order.')
@Command.option('--skip', default=0, help='Skip number of topics b... | devchat/devchat/_cli/topic.py/0 | {
"file_path": "devchat/devchat/_cli/topic.py",
"repo_id": "devchat",
"token_count": 455
} | 18 |
from .command_parser import parse_command, Command, CommandParser
from .namespace import Namespace
from .recursive_prompter import RecursivePrompter
from .router import run_command, load_workflow_instruction
__all__ = [
'parse_command',
'Command',
'CommandParser',
'Namespace',
'RecursivePrompter',
... | devchat/devchat/engine/__init__.py/0 | {
"file_path": "devchat/devchat/engine/__init__.py",
"repo_id": "devchat",
"token_count": 126
} | 19 |
import sys
from typing import Dict
import openai
class RetryException(Exception):
def __init__(self, err):
self.error = err
def retry(func, times):
def wrapper(*args, **kwargs):
for index in range(times):
try:
return func(*args, **kwargs)
except Retry... | devchat/devchat/llm/pipeline.py/0 | {
"file_path": "devchat/devchat/llm/pipeline.py",
"repo_id": "devchat",
"token_count": 957
} | 20 |
set -e
source $CONDA_PREFIX/etc/profile.d/conda.sh
# input target dir with shell script argument
if [ -n "$1" ]; then
TARGET_DIR=$1
else
# Error
echo "Please input a target dir with shell script argument"
exit 1
fi
mkdir -p $TARGET_DIR
conda remove -n devchat-no-binary --all --yes
conda create -n devc... | devchat/no_binary_install.sh/0 | {
"file_path": "devchat/no_binary_install.sh",
"repo_id": "devchat",
"token_count": 448
} | 21 |
import json
import sys
import time
from click.testing import CliRunner
from devchat.utils import get_prompt_hash
from devchat._cli.click_main import click_main
runner = CliRunner()
def test_topic_list(git_repo): # pylint: disable=W0613
request = "Complete the sequence 1, 1, 3, 5, 9, ( ). Reply the number only."... | devchat/tests/test_cli_topic.py/0 | {
"file_path": "devchat/tests/test_cli_topic.py",
"repo_id": "devchat",
"token_count": 467
} | 22 |
# ChatMark
ChatMark is a markup language for user interaction in chat message.
This module provides python implementation for common widgets in ChatMark.
| workflows/libs/chatmark/README.md/0 | {
"file_path": "workflows/libs/chatmark/README.md",
"repo_id": "workflows",
"token_count": 34
} | 23 |
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
pass
def ap... | workflows/libs/llm_api/memory/base.py/0 | {
"file_path": "workflows/libs/llm_api/memory/base.py",
"repo_id": "workflows",
"token_count": 287
} | 24 |
# Chinese translations for PACKAGE package.
# Copyright (C) 2023 THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# kagami <mingjing@merico.dev>, 2023.
#
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024... | workflows/unit_tests/locales/zh/base.po/0 | {
"file_path": "workflows/unit_tests/locales/zh/base.po",
"repo_id": "workflows",
"token_count": 1446
} | 25 |
import sys
import os
sys.path.append(os.path.join(os.path.dirname(__file__), "..", "..", "..", "libs"))
from llm_api import chat_completion_stream # noqa: E402
messages = [{"role": "user", "content": sys.argv[1]}]
llm_config = {"model": "gpt-4-1106-preview"}
response = chat_completion_stream(messages, llm_config... | LabWorkflows/git/commit/test/prompt/llm_openai.py/0 | {
"file_path": "LabWorkflows/git/commit/test/prompt/llm_openai.py",
"repo_id": "LabWorkflows",
"token_count": 136
} | 0 |
import subprocess
import sys
import requests
import json
import os
import time
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)
sy... | LabWorkflows/git/new_pr/command.py/0 | {
"file_path": "LabWorkflows/git/new_pr/command.py",
"repo_id": "LabWorkflows",
"token_count": 1383
} | 1 |
description: "demo for chat"
steps:
- run: $devchat_python $command_path/command.py | LabWorkflows/llm_demo/chat/command.yml/0 | {
"file_path": "LabWorkflows/llm_demo/chat/command.yml",
"repo_id": "LabWorkflows",
"token_count": 29
} | 2 |
description: "translate chinese to english"
| LabWorkflows/translate/command.yml/0 | {
"file_path": "LabWorkflows/translate/command.yml",
"repo_id": "LabWorkflows",
"token_count": 11
} | 3 |
devchat | devchat-intellij/.idea/.name/0 | {
"file_path": "devchat-intellij/.idea/.name",
"repo_id": "devchat-intellij",
"token_count": 2
} | 4 |
## Set or Update Key
### JS to Java
```json
{
"action": "setOrUpdateKey/request",
"metadata": {
"callback": "responseFunctionName"
},
"payload": {
"key": "DC.abcdef123456"
}
}
```
### Java to JS
- success
```json
{
"action": "setOrUpdateKey/response",
"metadata": {
"status": "success",
... | devchat-intellij/api/key.md/0 | {
"file_path": "devchat-intellij/api/key.md",
"repo_id": "devchat-intellij",
"token_count": 437
} | 5 |
package ai.devchat.common
import ai.devchat.storage.CONFIG
object Settings {
fun getAPISettings() : Triple<String?, String?, String?> {
val apiBaseK = "providers.devchat.api_base"
val apiKey = CONFIG["providers.devchat.api_key"] as? String
val defaultModel = CONFIG["default_model"] as? Str... | devchat-intellij/src/main/kotlin/ai/devchat/common/Settings.kt/0 | {
"file_path": "devchat-intellij/src/main/kotlin/ai/devchat/common/Settings.kt",
"repo_id": "devchat-intellij",
"token_count": 348
} | 6 |
package ai.devchat.core.handlers
import ai.devchat.core.BaseActionHandler
import ai.devchat.core.DevChatActions
import ai.devchat.storage.recommendedWorkflows
import com.alibaba.fastjson.JSONObject
class ListCommandsRequestHandler(requestAction: String, metadata: JSONObject?, payload: JSONObject?) : BaseActionHandle... | devchat-intellij/src/main/kotlin/ai/devchat/core/handlers/ListCommandsRequestHandler.kt/0 | {
"file_path": "devchat-intellij/src/main/kotlin/ai/devchat/core/handlers/ListCommandsRequestHandler.kt",
"repo_id": "devchat-intellij",
"token_count": 279
} | 7 |
package ai.devchat.core.handlers
import ai.devchat.core.BaseActionHandler
import ai.devchat.core.DevChatActions
import ai.devchat.plugin.DiffViewerDialog
import ai.devchat.plugin.currentProject
import com.alibaba.fastjson.JSONObject
import com.intellij.diff.DiffContentFactory
import com.intellij.diff.DiffManager
impor... | devchat-intellij/src/main/kotlin/ai/devchat/core/handlers/ViewDiffRequestHandler.kt/0 | {
"file_path": "devchat-intellij/src/main/kotlin/ai/devchat/core/handlers/ViewDiffRequestHandler.kt",
"repo_id": "devchat-intellij",
"token_count": 404
} | 8 |
package ai.devchat.plugin.hints
import ai.devchat.common.DevChatBundle
import ai.devchat.storage.CONFIG
import com.alibaba.fastjson.JSONObject
import com.intellij.openapi.editor.Editor
import com.intellij.psi.*
import com.intellij.refactoring.suggested.endOffset
import com.intellij.refactoring.suggested.startOffset
im... | devchat-intellij/src/main/kotlin/ai/devchat/plugin/hints/DocStringCVProvider.kt/0 | {
"file_path": "devchat-intellij/src/main/kotlin/ai/devchat/plugin/hints/DocStringCVProvider.kt",
"repo_id": "devchat-intellij",
"token_count": 504
} | 9 |
<!DOCTYPE html>
<html>
<head>
<title>Intellij Plugin Demo</title>
<style>
body {
font-family: Arial, sans-serif;
}
</style>
</head>
<body>
<label for="textInput" style="color: white;">JSON Input: </label>
<textarea id="textInput" cols="50" rows="10">{"action":"listComma... | devchat-intellij/src/main/resources/static/main.html/0 | {
"file_path": "devchat-intellij/src/main/resources/static/main.html",
"repo_id": "devchat-intellij",
"token_count": 278
} | 10 |
{
"extension": ["ts"],
"spec": "test/**/*.test.ts",
"require": "ts-node/register",
"project": "tsconfig.test.json"
} | devchat-vscode/.mocharc.json/0 | {
"file_path": "devchat-vscode/.mocharc.json",
"repo_id": "devchat-vscode",
"token_count": 51
} | 11 |
module.exports = {
preset: "ts-jest",
testEnvironment: "node",
testMatch: ["<rootDir>/test/**/*.test.ts"],
}; | devchat-vscode/jest.config.js/0 | {
"file_path": "devchat-vscode/jest.config.js",
"repo_id": "devchat-vscode",
"token_count": 52
} | 12 |
/*
针对代码补全功能,构建prompt
prompt的好坏,取决于提供的上下文信息。
通过AST获取相对完整的信息,可能会增加提示的准确度,但也会增加代码提示的复杂度。
*/
import { logger } from "../../../util/logger";
import { getAst, getTreePathAtCursor, RangeInFileWithContents } from "./ast";
import Parser from "web-tree-sitter";
import { getCommentPrefix, getLangageFunctionConfig, Langu... | devchat-vscode/src/contributes/codecomplete/ast/collapseBlock.ts/0 | {
"file_path": "devchat-vscode/src/contributes/codecomplete/ast/collapseBlock.ts",
"repo_id": "devchat-vscode",
"token_count": 2654
} | 13 |
const DEFAULT_MAX_TOKENS = 1024;
const DEFAULT_CONTEXT_LENGTH = 4096;
const DEFAULT_TEMPERATURE = 0.5;
const DEFAULT_ARGS = {
maxTokens: DEFAULT_MAX_TOKENS,
temperature: DEFAULT_TEMPERATURE,
};
const CONTEXT_LENGTH_FOR_MODEL: { [name: string]: number } = {
"gpt-3.5-turbo": 4096,
"gpt-3.5-turbo-0613": 4096,
... | devchat-vscode/src/contributes/codecomplete/llm/constants.ts/0 | {
"file_path": "devchat-vscode/src/contributes/codecomplete/llm/constants.ts",
"repo_id": "devchat-vscode",
"token_count": 439
} | 14 |
import * as vscode from 'vscode';
import { DevChatViewProvider } from '../panel/devchatView';
import { ExtensionContextHolder } from '../util/extensionContext';
export function regDevChatView(context: vscode.ExtensionContext) {
ExtensionContextHolder.provider = new DevChatViewProvider(context);
context.subscription... | devchat-vscode/src/contributes/views.ts/0 | {
"file_path": "devchat-vscode/src/contributes/views.ts",
"repo_id": "devchat-vscode",
"token_count": 150
} | 15 |
// messageHandler.ts
import * as vscode from 'vscode';
import '../context/loadContexts';
import { logger } from '../util/logger';
export class MessageHandler {
private handlers: { [command: string]: (message: any, panel: vscode.WebviewPanel|vscode.WebviewView) => Promise<void> } = {};
constructor() {
}
regist... | devchat-vscode/src/handler/messageHandler.ts/0 | {
"file_path": "devchat-vscode/src/handler/messageHandler.ts",
"repo_id": "devchat-vscode",
"token_count": 771
} | 16 |
/**
* Legacy endpoints migrated from language-bridge for ask-code
*
* Should remove these endpoints after ask-code migrated to new endpoints
*/
import {
findDefinitions,
findDefinitionsOfToken,
} from "./legacy_bridge/feature/find-defs";
import { findReferences } from "./legacy_bridge/feature/find-refs";
... | devchat-vscode/src/ide_services/endpoints/legacy.ts/0 | {
"file_path": "devchat-vscode/src/ide_services/endpoints/legacy.ts",
"repo_id": "devchat-vscode",
"token_count": 511
} | 17 |
// src/apiKey.ts
import DevChat from '@/toolwrapper/devchat';
import { UiUtilWrapper } from './uiUtil';
import { DevChatConfig } from './config';
import { logger } from './logger';
export class ApiKeyManager {
static async llmModel() {
const devchatConfig = DevChatConfig.getInstance();
const defaultModel = devch... | devchat-vscode/src/util/apiKey.ts/0 | {
"file_path": "devchat-vscode/src/util/apiKey.ts",
"repo_id": "devchat-vscode",
"token_count": 684
} | 18 |
/*
Get conda download url
*/
import os from 'os';
import { logger } from '../logger';
import { UiUtilVscode } from '../uiUtil_vscode';
import { UiUtilWrapper } from '../uiUtil';
import path from 'path';
function getDownloadFileName(): string {
const platform = os.platform();
const arch = os.arch();
logger.chan... | devchat-vscode/src/util/python_installer/conda_url.ts/0 | {
"file_path": "devchat-vscode/src/util/python_installer/conda_url.ts",
"repo_id": "devchat-vscode",
"token_count": 1080
} | 19 |
import { expect } from 'chai';
// import { describe, it } from 'mocha';
import sinon from 'sinon';
import DevChat, { ChatOptions } from '../../src/toolwrapper/devchat';
import { CommandRun } from '../../src/util/commonUtil';
import { UiUtilWrapper } from '../../src/util/uiUtil';
import { ApiKeyManager } from '../../src... | devchat-vscode/test/toolwrapper/devchat.test.ts/0 | {
"file_path": "devchat-vscode/test/toolwrapper/devchat.test.ts",
"repo_id": "devchat-vscode",
"token_count": 938
} | 20 |
version: 2.1
jobs:
build:
docker:
- image: circleci/python:3.9
steps:
- checkout
- run:
name: Install Poetry
command: |
curl -sSL https://install.python-poetry.org | python3 -
- run:
name: Setup Python Environment
command: |
... | devchat/.circleci/config.yml/0 | {
"file_path": "devchat/.circleci/config.yml",
"repo_id": "devchat",
"token_count": 307
} | 21 |
[BASIC]
good-names=id,db
[MESSAGES CONTROL]
disable=
missing-docstring,
broad-exception-caught,
too-few-public-methods,
too-many-instance-attributes,
too-many-arguments,
too-many-locals,
too-many-branches,
fixme,
R0801
[MASTER]
extension-pkg-whitelist=pydantic
| devchat/.pylintrc/0 | {
"file_path": "devchat/.pylintrc",
"repo_id": "devchat",
"token_count": 138
} | 22 |
# pylint: disable=import-outside-toplevel
from contextlib import contextmanager
import os
import sys
import shutil
from typing import Tuple, List, Optional, Any
import zipfile
from devchat._cli.errors import MissContentInPromptException
from devchat.utils import find_root_dir, add_gitignore, setup_logger, get_logger
... | devchat/devchat/_cli/utils.py/0 | {
"file_path": "devchat/devchat/_cli/utils.py",
"repo_id": "devchat",
"token_count": 2278
} | 23 |
import os
from typing import List, Dict, Optional
from pydantic import BaseModel
import oyaml as yaml
from .namespace import Namespace
class Parameter(BaseModel):
type: str = "string"
description: Optional[str] = None
enum: Optional[List[str]] = None
default: Optional[str] = None
class Command(BaseM... | devchat/devchat/engine/command_parser.py/0 | {
"file_path": "devchat/devchat/engine/command_parser.py",
"repo_id": "devchat",
"token_count": 629
} | 24 |
# flake8: noqa: E402
from functools import wraps
from devchat.chatmark import Checkbox, Form, TextEditor
class MissEditConfirmFieldException(Exception):
pass
def edit_confirm(response):
need_regenerate = Checkbox(["Need Regenerate"])
edit_text = TextEditor(response)
feedback_text = TextEditor("")
... | devchat/devchat/llm/text_confirm.py/0 | {
"file_path": "devchat/devchat/llm/text_confirm.py",
"repo_id": "devchat",
"token_count": 683
} | 25 |
import os
import tempfile
import pytest
from devchat.engine import Command, parse_command
from devchat.engine import CommandParser, Namespace
def test_parse_command():
# Test with a valid configuration file with most fields filled
with tempfile.NamedTemporaryFile('w', delete=False) as config_file:
con... | devchat/tests/test_command_parser.py/0 | {
"file_path": "devchat/tests/test_command_parser.py",
"repo_id": "devchat",
"token_count": 1908
} | 26 |
description: Generate code with a general template embedded into the prompt. | workflows/code/command.yml/0 | {
"file_path": "workflows/code/command.yml",
"repo_id": "workflows",
"token_count": 14
} | 27 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.