repo_id stringclasses 46
values | file_path stringlengths 36 118 | content stringlengths 7 1.68M | __index_level_0__ int64 0 0 |
|---|---|---|---|
devchat_public_repos | devchat_public_repos/devchat/.flake8 | [flake8]
max-line-length = 100
ignore = E712,W503 | 0 |
devchat_public_repos | devchat_public_repos/devchat/.pylintrc | [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
| 0 |
devchat_public_repos | devchat_public_repos/devchat/LICENSE | Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
... | 0 |
devchat_public_repos | devchat_public_repos/devchat/pyproject.toml | [tool.poetry]
name = "devchat"
version = "0.2.10"
description = "DevChat is an open-source tool that helps developers write prompts to generate code and documentation."
authors = ["DevChat Team <hello@devchat.ai>"]
license = "Apache License 2.0"
readme = "README.md"
homepage = "https://github.com/devchat-ai/devchat"
cl... | 0 |
devchat_public_repos | devchat_public_repos/devchat/README.md | <div align="center">

# DevChat: Intelligent Scripts that Streamline Your Dev Workflows
[](http://makeapullrequest.com)
[![Circ... | 0 |
devchat_public_repos | devchat_public_repos/devchat/no_binary_install.sh | 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... | 0 |
devchat_public_repos | devchat_public_repos/devchat/poetry.lock | # This file is automatically @generated by Poetry 1.5.1 and should not be changed by hand.
[[package]]
name = "anyio"
version = "4.3.0"
description = "High level compatibility layer for multiple asynchronous event loop implementations"
optional = false
python-versions = ">=3.8"
files = [
{file = "anyio-4.3.0-py3-n... | 0 |
devchat_public_repos/devchat | devchat_public_repos/devchat/devchat/store.py | # pylint: disable=import-outside-toplevel
from dataclasses import asdict
import json
import os
from typing import List, Dict, Any, Optional
from tinydb import TinyDB, where, Query
from tinydb.table import Table
from devchat.chat import Chat
from devchat.prompt import Prompt
from devchat.utils import get_logger
logger ... | 0 |
devchat_public_repos/devchat | devchat_public_repos/devchat/devchat/config.py | import os
import sys
from typing import List, Dict, Tuple, Optional
from pydantic import BaseModel
import oyaml as yaml
class GeneralProviderConfig(BaseModel):
api_key: Optional[str]
api_base: Optional[str]
class ModelConfig(BaseModel):
max_input_tokens: Optional[int] = sys.maxsize
provider: Optional... | 0 |
devchat_public_repos/devchat | devchat_public_repos/devchat/devchat/assistant.py | 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:
... | 0 |
devchat_public_repos/devchat | devchat_public_repos/devchat/devchat/message.py | from abc import ABC, abstractmethod
from dataclasses import dataclass
@dataclass
class Message(ABC):
"""
The basic unit of information in a prompt.
"""
content: str = ""
INSTRUCT = "instruct"
CONTEXT = "context"
FUNCTION = "function"
CHAT = "chat"
@abstractmethod
def to_dict(... | 0 |
devchat_public_repos/devchat | devchat_public_repos/devchat/devchat/chat.py | from abc import ABC, abstractmethod
from typing import Iterator
from devchat.prompt import Prompt
class Chat(ABC):
"""
Chat interface for managing chat-related interactions.
This interface defines methods for prompting a chat system with
a list of Message objects and retrieving responses, either as a... | 0 |
devchat_public_repos/devchat | devchat_public_repos/devchat/devchat/utils.py | # pylint: disable=import-outside-toplevel
import logging
import os
import re
import getpass
import socket
import subprocess
from typing import List, Tuple, Optional
import datetime
import hashlib
log_formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
# pylint: disable=invalid-name
e... | 0 |
devchat_public_repos/devchat | devchat_public_repos/devchat/devchat/prompt.py | from abc import ABC, abstractmethod
from dataclasses import dataclass, field, asdict
import hashlib
from datetime import datetime
import sys
from typing import Dict, List
from devchat.message import Message
from devchat.utils import unix_to_local_datetime, get_logger, user_id
logger = get_logger(__name__)
@dataclas... | 0 |
devchat_public_repos/devchat | devchat_public_repos/devchat/devchat/__main__.py | import sys
if __name__ == "__main__":
from devchat._cli.main import main as _main
sys.exit(_main())
| 0 |
devchat_public_repos/devchat/devchat | devchat_public_repos/devchat/devchat/ide/service.py | # 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... | 0 |
devchat_public_repos/devchat/devchat | devchat_public_repos/devchat/devchat/ide/__init__.py | from .service import IDEService
from .types import *
from .types import __all__ as types_all
__all__ = types_all + [
"IDEService",
]
| 0 |
devchat_public_repos/devchat/devchat | devchat_public_repos/devchat/devchat/ide/types.py | 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}"
... | 0 |
devchat_public_repos/devchat/devchat | devchat_public_repos/devchat/devchat/ide/rpc.py | # 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... | 0 |
devchat_public_repos/devchat/devchat | devchat_public_repos/devchat/devchat/ide/vscode_services.py | import os
from .rpc import rpc_call
from .types import LocationWithText
@rpc_call
def run_code(code: str): # pylint: disable=unused-argument
pass
@rpc_call
def diff_apply(filepath, content): # pylint: disable=unused-argument
pass
@rpc_call
def get_symbol_defines_in_selected_code():
pass
def find_sy... | 0 |
devchat_public_repos/devchat/devchat | devchat_public_repos/devchat/devchat/ide/idea_services.py | 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... | 0 |
devchat_public_repos/devchat/devchat | devchat_public_repos/devchat/devchat/llm/text_confirm.py | # 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("")
... | 0 |
devchat_public_repos/devchat/devchat | devchat_public_repos/devchat/devchat/llm/tools_call.py | import json
import os
import sys
from functools import wraps
from devchat.memory import ChatMemory
from devchat.chatmark import Form, Radio, TextEditor
from devchat.ide import IDEService
from .openai import chat_call_completion_stream
class MissToolsFieldException(Exception):
pass
def openai_tool_schema(name,... | 0 |
devchat_public_repos/devchat/devchat | devchat_public_repos/devchat/devchat/llm/__init__.py | from .chat import chat, chat_json
from .openai import chat_completion_no_stream_return_json, chat_completion_stream
from .text_confirm import llm_edit_confirm
from .tools_call import chat_tools, llm_func, llm_param
__all__ = [
"chat_completion_stream",
"chat_completion_no_stream_return_json",
"chat_json",
... | 0 |
devchat_public_repos/devchat/devchat | devchat_public_repos/devchat/devchat/llm/openai.py | # flake8: noqa: E402
import json
import os
import re
from typing import Dict, List
import openai
from .pipeline import (
RetryException,
exception_handle,
exception_output_handle,
parallel,
pipeline,
retry,
)
def _try_remove_markdown_block_flag(content):
"""
如果content是一个markdown块,则删除... | 0 |
devchat_public_repos/devchat/devchat | devchat_public_repos/devchat/devchat/llm/chat.py | import json
import os
import sys
from functools import wraps
import openai
from devchat.memory import ChatMemory
from .openai import (
chat_completion_no_stream_return_json,
chat_completion_stream,
chat_completion_stream_commit,
chunks_content,
retry_timeout,
stream_out_chunk,
to_dict_con... | 0 |
devchat_public_repos/devchat/devchat | devchat_public_repos/devchat/devchat/llm/pipeline.py | 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... | 0 |
devchat_public_repos/devchat/devchat | devchat_public_repos/devchat/devchat/memory/fixsize_memory.py | from .base import ChatMemory
class FixSizeChatMemory(ChatMemory):
"""
FixSizeChatMemory is a memory class that stores up
to a fixed number of requests and responses.
"""
def __init__(self, max_size: int = 5, messages=None, system_prompt=None):
"""
init the memory
"""
... | 0 |
devchat_public_repos/devchat/devchat | devchat_public_repos/devchat/devchat/memory/__init__.py |
from .base import ChatMemory
from .fixsize_memory import FixSizeChatMemory
__all__ = [
"ChatMemory",
"FixSizeChatMemory",
]
| 0 |
devchat_public_repos/devchat/devchat | devchat_public_repos/devchat/devchat/memory/base.py | 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(... | 0 |
devchat_public_repos/devchat/devchat | devchat_public_repos/devchat/devchat/tiktoken_cache/9b5ad71b2ce5302211f9c61530b329a4922fc6a4 | IQ== 0
Ig== 1
Iw== 2
JA== 3
JQ== 4
Jg== 5
Jw== 6
KA== 7
KQ== 8
Kg== 9
Kw== 10
LA== 11
LQ== 12
Lg== 13
Lw== 14
MA== 15
MQ== 16
Mg== 17
Mw== 18
NA== 19
NQ== 20
Ng== 21
Nw== 22
OA== 23
OQ== 24
Og== 25
Ow== 26
PA== 27
PQ== 28
Pg== 29
Pw== 30
QA== 31
QQ== 32
Qg== 33
Qw== 34
RA== 35
RQ== 36
Rg== 37
Rw== 38
SA== 39
SQ== 40
Sg... | 0 |
devchat_public_repos/devchat/devchat | devchat_public_repos/devchat/devchat/_cli/run.py | # pylint: disable=import-outside-toplevel
from typing import List, Optional, Tuple
from .command import command, Command
@command('run',
help="The 'command' argument is the name of the command to run or get information about.")
@Command.argument('command', nargs='?', default='')
@Command.option('--list', dest='l... | 0 |
devchat_public_repos/devchat/devchat | devchat_public_repos/devchat/devchat/_cli/command.py | 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... | 0 |
devchat_public_repos/devchat/devchat | devchat_public_repos/devchat/devchat/_cli/log.py | # 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)
... | 0 |
devchat_public_repos/devchat/devchat | devchat_public_repos/devchat/devchat/_cli/route.py | # pylint: disable=import-outside-toplevel
import sys
from typing import List, Optional
from .command import command, Command
@command('route', help='Route a prompt to the specified LLM')
@Command.argument('content')
@Command.option('-p', '--parent', help='Input the parent prompt hash to continue the conversation.')
... | 0 |
devchat_public_repos/devchat/devchat | devchat_public_repos/devchat/devchat/_cli/click_main.py | import click
from .main import main as main_from_argparse # 导入修改后的main函数
@click.command(context_settings={
"ignore_unknown_options": True,
"allow_extra_args": True
})
@click.pass_context
def click_main(ctx):
"""调用基于argparse的CLI程序,传递参数列表。"""
main_from_argparse(ctx.args)
| 0 |
devchat_public_repos/devchat/devchat | devchat_public_repos/devchat/devchat/_cli/__init__.py | from .log import log
from .prompt import prompt
from .run import run
from .topic import topic
from .route import route
from .command import commands, command, Command
__all__ = [
'log',
'prompt',
'run',
'topic',
'route',
'commands',
'command',
'Command'
]
| 0 |
devchat_public_repos/devchat/devchat | devchat_public_repos/devchat/devchat/_cli/utils.py | # 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
... | 0 |
devchat_public_repos/devchat/devchat | devchat_public_repos/devchat/devchat/_cli/topic.py | # 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... | 0 |
devchat_public_repos/devchat/devchat | devchat_public_repos/devchat/devchat/_cli/errors.py |
class MissContentInPromptException(Exception):
pass
| 0 |
devchat_public_repos/devchat/devchat | devchat_public_repos/devchat/devchat/_cli/prompt.py | # pylint: disable=import-outside-toplevel
import sys
from typing import List, Optional
from .command import command, Command
@command('prompt', help='Interact with the large language model (LLM).')
@Command.argument('content')
@Command.option('-p', '--parent', help='Input the parent prompt hash to continue the conve... | 0 |
devchat_public_repos/devchat/devchat | devchat_public_repos/devchat/devchat/_cli/router.py | # pylint: disable=import-outside-toplevel
import json
import sys
from typing import List, Optional
def _get_model_and_config(
model: Optional[str],
config_str: Optional[str]):
from devchat._cli.utils import init_dir, get_model_config
_1, user_chat_dir = init_dir()
model, config = get_mode... | 0 |
devchat_public_repos/devchat/devchat | devchat_public_repos/devchat/devchat/_cli/main.py | """
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... | 0 |
devchat_public_repos/devchat/devchat | devchat_public_repos/devchat/devchat/anthropic/anthropic_chat.py | from typing import List, Optional, Dict, Any
from pydantic import BaseModel, Field
class AnthropicChatParameters(BaseModel, extra='ignore'):
max_tokens_to_sample: int = Field(1024, ge=1)
stop_sequences: Optional[List[str]]
temperature: Optional[float] = Field(0.2, ge=0, le=1)
top_p: Optional[float]
... | 0 |
devchat_public_repos/devchat/devchat | devchat_public_repos/devchat/devchat/anthropic/__init__.py | from .anthropic_chat import AnthropicChatParameters
__all__ = [
'AnthropicChatParameters'
]
| 0 |
devchat_public_repos/devchat/devchat | devchat_public_repos/devchat/devchat/chatmark/__init__.py | from .form import Form
from .step import Step
from .widgets import Button, Checkbox, Radio, TextEditor
__all__ = [
"Checkbox",
"TextEditor",
"Radio",
"Button",
"Form",
"Step",
]
| 0 |
devchat_public_repos/devchat/devchat | devchat_public_repos/devchat/devchat/chatmark/widgets.py | from abc import ABC, abstractmethod
from typing import Dict, List, Optional, Tuple
from uuid import uuid4
from .iobase import pipe_interaction
class Widget(ABC):
"""
Abstract base class for widgets
"""
def __init__(self, submit: Optional[str] = None, cancel: Optional[str] = None):
self._rend... | 0 |
devchat_public_repos/devchat/devchat | devchat_public_repos/devchat/devchat/chatmark/README.md | # ChatMark
ChatMark is a markup language for user interaction in chat message.
This module provides python implementation for common widgets in ChatMark.
| 0 |
devchat_public_repos/devchat/devchat | devchat_public_repos/devchat/devchat/chatmark/step.py | from contextlib import AbstractContextManager
class Step(AbstractContextManager):
"""
Show a running step in the TUI.
ChatMark syntax:
```Step
# Something is running...
some details...
```
Usage:
with Step("Something is running..."):
print("some details...")
"""
... | 0 |
devchat_public_repos/devchat/devchat | devchat_public_repos/devchat/devchat/chatmark/form.py | # pylint: disable=C0103
# pylint: disable=W0212
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... | 0 |
devchat_public_repos/devchat/devchat | devchat_public_repos/devchat/devchat/chatmark/iobase.py | import yaml
def _send_message(message):
out_data = f"""\n{message}\n"""
print(out_data, flush=True)
def _parse_chatmark_response(response):
# resonse looks like:
"""
``` some_name
some key name 1: value1
some key name 2: value2
```
"""
# parse key values
lines = response.... | 0 |
devchat_public_repos/devchat/devchat/chatmark | devchat_public_repos/devchat/devchat/chatmark/chatmark_example/README.md | # chatmark_exmaple
This is an example of how to use the chatmark module.
Usage:
1. Copy the `chatmark_example` folder under `~/.chat/workflow/org`
2. Create `command.yml` under `~/.chat/workflow/org/chatmark_example` with the following content:
```yaml
description: chatmark examples
steps:
- run: $command_python ... | 0 |
devchat_public_repos/devchat/devchat/chatmark | devchat_public_repos/devchat/devchat/chatmark/chatmark_example/main.py | import time
from devchat.chatmark import Button, Checkbox, Form, Radio, Step, TextEditor # pylint: disable=E402
def main():
print("\n\n---\n\n")
# Step
print("\n\n# Step Example\n\n")
with Step("Something is running..."):
print("Will sleep for 5 seconds...", flush=True)
time.sleep(... | 0 |
devchat_public_repos/devchat/devchat | devchat_public_repos/devchat/devchat/engine/util.py | # pylint: disable=import-outside-toplevel
import os
import sys
import json
from typing import List, Dict
from devchat._cli.utils import init_dir
from devchat.utils import get_logger
from .namespace import Namespace
from .command_parser import CommandParser, Command
logger = get_logger(__name__)
DEFAULT_MODEL = "g... | 0 |
devchat_public_repos/devchat/devchat | devchat_public_repos/devchat/devchat/engine/command_runner.py | """
Run Command with a input text.
"""
import os
import sys
import json
import threading
import subprocess
from typing import List, Dict
import shlex
from devchat.utils import get_logger
from .command_parser import Command
from .util import ToolUtil
logger = get_logger(__name__)
DEVCHAT_COMMAND_MISS_ERROR_MESSAGE ... | 0 |
devchat_public_repos/devchat/devchat | devchat_public_repos/devchat/devchat/engine/__init__.py | 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',
... | 0 |
devchat_public_repos/devchat/devchat | devchat_public_repos/devchat/devchat/engine/recursive_prompter.py | 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... | 0 |
devchat_public_repos/devchat/devchat | devchat_public_repos/devchat/devchat/engine/router.py | import os
from typing import List
from .command_runner import CommandRunner
from .util import CommandUtil
from .namespace import Namespace
from.recursive_prompter import RecursivePrompter
def load_workflow_instruction(user_input: str):
user_input = user_input.strip()
if len(user_input) == 0:
return No... | 0 |
devchat_public_repos/devchat/devchat | devchat_public_repos/devchat/devchat/engine/namespace.py | import os
from typing import List, Optional
import re
class Namespace:
def __init__(self, root_path: str,
branches: List[str] = None):
"""
:param root_path: The root path of the namespace.
:param branches: The hidden branches with ascending order of priority.
"""
... | 0 |
devchat_public_repos/devchat/devchat | devchat_public_repos/devchat/devchat/engine/command_parser.py | 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... | 0 |
devchat_public_repos/devchat/devchat | devchat_public_repos/devchat/devchat/openai/openai_chat.py | # 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... | 0 |
devchat_public_repos/devchat/devchat | devchat_public_repos/devchat/devchat/openai/openai_prompt.py | 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... | 0 |
devchat_public_repos/devchat/devchat | devchat_public_repos/devchat/devchat/openai/__init__.py | from .openai_chat import OpenAIChatParameters, OpenAIChatConfig, OpenAIChat
from .openai_message import OpenAIMessage
from .openai_prompt import OpenAIPrompt
__all__ = [
'OpenAIChat',
'OpenAIChatConfig',
'OpenAIChatParameters',
'OpenAIMessage',
'OpenAIPrompt'
]
| 0 |
devchat_public_repos/devchat/devchat | devchat_public_repos/devchat/devchat/openai/openai_message.py | 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 _... | 0 |
devchat_public_repos/devchat/devchat | devchat_public_repos/devchat/devchat/openai/http_openai.py | 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()
... | 0 |
devchat_public_repos/devchat | devchat_public_repos/devchat/tests/test_cli_prompt.py | import os
import json
import pytest
from click.testing import CliRunner
from devchat.config import ConfigManager, GeneralModelConfig
from devchat._cli.click_main import click_main
from devchat.utils import openai_response_tokens
from devchat.utils import check_format, get_content, get_prompt_hash
runner = CliRunner()
... | 0 |
devchat_public_repos/devchat | devchat_public_repos/devchat/tests/test_utils.py | 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)... | 0 |
devchat_public_repos/devchat | devchat_public_repos/devchat/tests/conftest.py | import os
import shutil
import tempfile
from pathlib import Path
import pytest
from git import Repo
@pytest.fixture(scope='function')
def git_repo(request):
# Create a temporary directory
repo_dir = tempfile.mkdtemp()
# Initialize a new Git repository in the temporary directory
Repo.init(repo_dir)
... | 0 |
devchat_public_repos/devchat | devchat_public_repos/devchat/tests/test_openai_message.py | 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... | 0 |
devchat_public_repos/devchat | devchat_public_repos/devchat/tests/test_command_parser.py | 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... | 0 |
devchat_public_repos/devchat | devchat_public_repos/devchat/tests/test_namespace.py | import os
import pytest
from devchat.engine import Namespace
def test_is_valid_name():
# Test valid names
assert Namespace.is_valid_name('') is True
assert Namespace.is_valid_name('a') is True
assert Namespace.is_valid_name('A.b') is True
assert Namespace.is_valid_name('a.2.c') is True
assert ... | 0 |
devchat_public_repos/devchat | devchat_public_repos/devchat/tests/test_prompter.py | import os
from devchat.engine import Namespace, RecursivePrompter
def test_prompter(tmp_path):
namespace = Namespace(tmp_path)
prompter = RecursivePrompter(namespace)
# Test when there are no 'prompt.txt' files
os.makedirs(os.path.join(tmp_path, 'usr', 'a', 'b', 'c'))
assert prompter.run('a.b.c')... | 0 |
devchat_public_repos/devchat | devchat_public_repos/devchat/tests/test_cli_log.py | import json
from click.testing import CliRunner
from devchat.utils import get_prompt_hash, get_content
from devchat._cli.click_main import click_main
runner = CliRunner()
def test_log_no_args(git_repo): # pylint: disable=W0613
result = runner.invoke(click_main, ['log'])
assert result.exit_code == 0
logs... | 0 |
devchat_public_repos/devchat | devchat_public_repos/devchat/tests/test_openai_prompt.py | # pylint: disable=protected-access
import json
import os
import pytest
from devchat.message import Message
from devchat.openai import OpenAIMessage
from devchat.openai import OpenAIPrompt
from devchat.utils import get_user_info
def test_prompt_init_and_set_response():
name, email = get_user_info()
prompt = Op... | 0 |
devchat_public_repos/devchat | devchat_public_repos/devchat/tests/test_store.py | from typing import Tuple
import pytest
from devchat.openai import OpenAIChatConfig, OpenAIChat
from devchat.store import Store
@pytest.fixture(name="chat_store", scope="function")
def create_chat_store(tmp_path) -> Tuple[OpenAIChat, Store]:
config = OpenAIChatConfig(model="gpt-3.5-turbo")
chat = OpenAIChat(co... | 0 |
devchat_public_repos/devchat | devchat_public_repos/devchat/tests/test_cli_topic.py | 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."... | 0 |
devchat_public_repos/devchat | devchat_public_repos/devchat/tests/test_config.py | import os
from click.testing import CliRunner
from devchat.config import ConfigManager, GeneralModelConfig, ChatConfig
runner = CliRunner()
def test_create_sample_config(tmp_path):
ConfigManager(tmp_path)
assert os.path.exists(os.path.join(tmp_path, 'config.yml'))
def test_load_and_validate_config(tmp_path... | 0 |
devchat_public_repos/devchat/tests | devchat_public_repos/devchat/tests/stream_responses/response5.json | {
"choices": [
{
"delta": {
"content": "."
},
"finish_reason": null,
"index": 0
}
],
"created": 1682163460,
"id": "chatcmpl-785qeSHlUo3lH4OnLuovtk3NqLcD6",
"model": "gpt-3.5-turbo-0301",
"object": "chat.completion.ch... | 0 |
devchat_public_repos/devchat/tests | devchat_public_repos/devchat/tests/stream_responses/response4.json | {
"choices": [
{
"delta": {
"content": "Tomorrow"
},
"finish_reason": null,
"index": 1
}
],
"created": 1682163460,
"id": "chatcmpl-785qeSHlUo3lH4OnLuovtk3NqLcD6",
"model": "gpt-3.5-turbo-0301",
"object": "chat.comple... | 0 |
devchat_public_repos/devchat/tests | devchat_public_repos/devchat/tests/stream_responses/response8.json | {
"choices": [
{
"delta": {},
"finish_reason": "stop",
"index": 1
}
],
"created": 1682163460,
"id": "chatcmpl-785qeSHlUo3lH4OnLuovtk3NqLcD6",
"model": "gpt-3.5-turbo-0301",
"object": "chat.completion.chunk"
} | 0 |
devchat_public_repos/devchat/tests | devchat_public_repos/devchat/tests/stream_responses/response3.json | {
"choices": [
{
"delta": {
"role": "assistant"
},
"finish_reason": null,
"index": 1
}
],
"created": 1682163460,
"id": "chatcmpl-785qeSHlUo3lH4OnLuovtk3NqLcD6",
"model": "gpt-3.5-turbo-0301",
"object": "chat.completi... | 0 |
devchat_public_repos/devchat/tests | devchat_public_repos/devchat/tests/stream_responses/response2.json | {
"choices": [
{
"delta": {
"content": "Tomorrow"
},
"finish_reason": null,
"index": 0
}
],
"created": 1682163460,
"id": "chatcmpl-785qeSHlUo3lH4OnLuovtk3NqLcD6",
"model": "gpt-3.5-turbo-0301",
"object": "chat.comple... | 0 |
devchat_public_repos/devchat/tests | devchat_public_repos/devchat/tests/stream_responses/response1.json | {
"choices": [
{
"delta": {
"role": "assistant"
},
"finish_reason": null,
"index": 0
}
],
"created": 1682163460,
"id": "chatcmpl-785qeSHlUo3lH4OnLuovtk3NqLcD6",
"model": "gpt-3.5-turbo-0301",
"object": "chat.completi... | 0 |
devchat_public_repos/devchat/tests | devchat_public_repos/devchat/tests/stream_responses/response7.json | {
"choices": [
{
"delta": {},
"finish_reason": "stop",
"index": 0
}
],
"created": 1682163460,
"id": "chatcmpl-785qeSHlUo3lH4OnLuovtk3NqLcD6",
"model": "gpt-3.5-turbo-0301",
"object": "chat.completion.chunk"
} | 0 |
devchat_public_repos/devchat/tests | devchat_public_repos/devchat/tests/stream_responses/response6.json | {
"choices": [
{
"delta": {
"content": "!"
},
"finish_reason": null,
"index": 1
}
],
"created": 1682163460,
"id": "chatcmpl-785qeSHlUo3lH4OnLuovtk3NqLcD6",
"model": "gpt-3.5-turbo-0301",
"object": "chat.completion.ch... | 0 |
devchat_public_repos/devchat/workflow/workflows | devchat_public_repos/devchat/workflow/workflows/release_note/instruct.txt | As a software developer assistant, your task is to provide clear and concise responses and write release notes based on the given context.
Follow these guidelines:
1. A release note should at least contain two sections, "Highlights" and "Change Log" unless required otherwise.
2. In the "Highlights" section, summarize ... | 0 |
devchat_public_repos/devchat/workflow/workflows | devchat_public_repos/devchat/workflow/workflows/code/python.txt | When writing Python code, include type hints where appropriate and maintain compliance with PEP-8 guidelines, such as providing docstrings for modules, classes, and functions.
| 0 |
devchat_public_repos/devchat/workflow/workflows | devchat_public_repos/devchat/workflow/workflows/code/instruct.txt | As a software developer assistant, your tasks are to:
- Provide a clear and concise response to address the user's requirements.
- Write code and give advice based on given code or information in the <context> if provided.
- Follow language-specific best practices and common coding standards.
When responding:
1. Fir... | 0 |
devchat_public_repos/devchat/workflow/workflows | devchat_public_repos/devchat/workflow/workflows/commit_message/instruct.txt | As a software developer assistant, your task is to provide clear and concise responses and write commit messages based on given code, requirements, or conversations.
Follow these guidelines:
1. A commit message should include a title and multiple body lines.
2. Adhere to best practices, such as keeping titles under 50... | 0 |
devchat_public_repos/devchat/workflow/commands | devchat_public_repos/devchat/workflow/commands/git/git.yml | 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... | 0 |
devchat_public_repos/devchat | devchat_public_repos/devchat/scripts/purge_topics.py | import sys
from tinydb import TinyDB
def remove_topic_table(file_path: str):
try:
db = TinyDB(file_path)
if 'topics' in db.tables():
db.drop_table('topics')
print("The 'topics' table has been removed.")
else:
print("The file does not contain a 'topics' t... | 0 |
devchat_public_repos/devchat | devchat_public_repos/devchat/.circleci/config.yml | 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: |
... | 0 |
devchat_public_repos | devchat_public_repos/devchat-intellij/CHANGELOG.md | # DevChat Changelog
## Unreleased
### Added
- EAP version of the DevChat
| 0 |
devchat_public_repos | devchat_public_repos/devchat-intellij/README.md | <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... | 0 |
devchat_public_repos | devchat_public_repos/devchat-intellij/gradlew | #!/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... | 0 |
devchat_public_repos | devchat_public_repos/devchat-intellij/package.json | {
"name": "devchat-intellij",
"scripts": {
"build": "cd ./gui && yarn && yarn idea"
}
}
| 0 |
devchat_public_repos | devchat_public_repos/devchat-intellij/build.gradle.kts | plugins {
id("java")
id("org.jetbrains.intellij") version "1.17.3"
id("org.jetbrains.changelog") version "2.2.0"
kotlin("jvm") version "1.9.23"
kotlin("plugin.serialization") version "1.9.23"
}
group = "ai.devchat"
version = "0.2.6"
repositories {
mavenCentral()
}
dependencies {
implement... | 0 |
devchat_public_repos | devchat_public_repos/devchat-intellij/settings.gradle.kts | plugins {
id("org.gradle.toolchains.foojay-resolver-convention") version "0.8.0"
}
rootProject.name = "devchat" | 0 |
devchat_public_repos | devchat_public_repos/devchat-intellij/gradlew.bat | @rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unles... | 0 |
devchat_public_repos/devchat-intellij/gradle | devchat_public_repos/devchat-intellij/gradle/wrapper/gradle-wrapper.properties | distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
| 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.