Skip to content

Commit

Permalink
refactor: Refactor proxy LLM (#1064)
Browse files Browse the repository at this point in the history
  • Loading branch information
fangyinc authored Jan 14, 2024
1 parent a035433 commit 22bfd01
Show file tree
Hide file tree
Showing 95 changed files with 2,040 additions and 1,285 deletions.
32 changes: 2 additions & 30 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -37,42 +37,14 @@ fmt: setup ## Format Python code
# TODO: Use isort to sort Python imports.
# https://github.com/PyCQA/isort
# $(VENV_BIN)/isort .
$(VENV_BIN)/isort dbgpt/agent/
$(VENV_BIN)/isort dbgpt/app/
$(VENV_BIN)/isort dbgpt/cli/
$(VENV_BIN)/isort dbgpt/configs/
$(VENV_BIN)/isort dbgpt/core/
$(VENV_BIN)/isort dbgpt/datasource/
$(VENV_BIN)/isort dbgpt/model/
# TODO: $(VENV_BIN)/isort dbgpt/serve
$(VENV_BIN)/isort dbgpt/serve/core/
$(VENV_BIN)/isort dbgpt/serve/agent/
$(VENV_BIN)/isort dbgpt/serve/conversation/
$(VENV_BIN)/isort dbgpt/serve/utils/_template_files
$(VENV_BIN)/isort dbgpt/storage/
$(VENV_BIN)/isort dbgpt/train/
$(VENV_BIN)/isort dbgpt/util/
$(VENV_BIN)/isort dbgpt/vis/
$(VENV_BIN)/isort dbgpt/__init__.py
$(VENV_BIN)/isort dbgpt/component.py
$(VENV_BIN)/isort dbgpt/
$(VENV_BIN)/isort --extend-skip="examples/notebook" examples
# https://github.com/psf/black
$(VENV_BIN)/black --extend-exclude="examples/notebook" .
# TODO: Use blackdoc to format Python doctests.
# https://blackdoc.readthedocs.io/en/latest/
# $(VENV_BIN)/blackdoc .
$(VENV_BIN)/blackdoc dbgpt/agent/
$(VENV_BIN)/blackdoc dbgpt/app/
$(VENV_BIN)/blackdoc dbgpt/cli/
$(VENV_BIN)/blackdoc dbgpt/configs/
$(VENV_BIN)/blackdoc dbgpt/core/
$(VENV_BIN)/blackdoc dbgpt/datasource/
$(VENV_BIN)/blackdoc dbgpt/model/
$(VENV_BIN)/blackdoc dbgpt/serve/
# TODO: $(VENV_BIN)/blackdoc dbgpt/storage/
$(VENV_BIN)/blackdoc dbgpt/train/
$(VENV_BIN)/blackdoc dbgpt/util/
$(VENV_BIN)/blackdoc dbgpt/vis/
$(VENV_BIN)/blackdoc dbgpt
$(VENV_BIN)/blackdoc examples
# TODO: Type checking of Python code.
# https://github.com/python/mypy
Expand Down
3 changes: 2 additions & 1 deletion dbgpt/_private/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
from __future__ import annotations

import os
from typing import List, Optional, TYPE_CHECKING
from typing import TYPE_CHECKING, List, Optional

from dbgpt.util.singleton import Singleton

if TYPE_CHECKING:
from auto_gpt_plugin_template import AutoGPTPluginTemplate

from dbgpt.component import SystemApp


Expand Down
2 changes: 1 addition & 1 deletion dbgpt/_private/llm_metadata.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from dbgpt._private.pydantic import Field, BaseModel
from dbgpt._private.pydantic import BaseModel, Field

DEFAULT_CONTEXT_WINDOW = 3900
DEFAULT_NUM_OUTPUTS = 256
Expand Down
4 changes: 2 additions & 2 deletions dbgpt/_private/pydantic.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
NonNegativeInt,
PositiveFloat,
PositiveInt,
PrivateAttr,
ValidationError,
root_validator,
validator,
PrivateAttr,
)
else:
PYDANTIC_VERSION = 2
Expand All @@ -26,10 +26,10 @@
NonNegativeInt,
PositiveFloat,
PositiveInt,
PrivateAttr,
ValidationError,
root_validator,
validator,
PrivateAttr,
)


Expand Down
19 changes: 10 additions & 9 deletions dbgpt/app/chat_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,14 +178,15 @@ def get_generate_stream_func(self, model_path: str):
return falcon_generate_output


class ProxyllmChatAdapter(BaseChatAdpter):
def match(self, model_path: str):
return "proxyllm" in model_path

def get_generate_stream_func(self, model_path: str):
from dbgpt.model.llm_out.proxy_llm import proxyllm_generate_stream

return proxyllm_generate_stream
#
# class ProxyllmChatAdapter(BaseChatAdpter):
# def match(self, model_path: str):
# return "proxyllm" in model_path
#
# def get_generate_stream_func(self, model_path: str):
# from dbgpt.model.llm_out.proxy_llm import proxyllm_generate_stream
#
# return proxyllm_generate_stream


class GorillaChatAdapter(BaseChatAdpter):
Expand Down Expand Up @@ -286,6 +287,6 @@ def get_conv_template(self, model_path: str) -> Conversation:
register_llm_model_chat_adapter(InternLMChatAdapter)

# Proxy model for test and develop, it's cheap for us now.
register_llm_model_chat_adapter(ProxyllmChatAdapter)
# register_llm_model_chat_adapter(ProxyllmChatAdapter)

register_llm_model_chat_adapter(BaseChatAdpter)
Loading

0 comments on commit 22bfd01

Please sign in to comment.