-
Notifications
You must be signed in to change notification settings - Fork 147
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support custom llm #503
Support custom llm #503
Conversation
@nihit . instantiating NOTE: [Its still pending] Please skim through it and suggest changes, if needed. |
@@ -30,6 +28,12 @@ class AnthropicLLM(BaseModel): | |||
|
|||
def __init__(self, config: AutolabelConfig, cache: BaseCache = None) -> None: | |||
super().__init__(config, cache) | |||
|
|||
from langchain.chat_models import ChatAnthropic |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
did we move this in order to prevent import errors? Should we catch import errors in that case and return the command to install the extras related to this model?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was done to mimic the imports as part of previously deployed code. If langchain
is a base dependency it makes more sense to have top level imports.
Agreed that we should be catching import errors during test cases.
src/autolabel/models/palm.py
Outdated
|
||
from langchain.chat_models import ChatVertexAI | ||
from langchain.llms import VertexAI | ||
from langchain.schema import LLMResult, HumanMessage, Generation |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can keep this out? langchain is a dependency of the library
src/autolabel/models/openai.py
Outdated
|
||
from langchain.chat_models import ChatOpenAI | ||
from langchain.llms import OpenAI | ||
from langchain.schema import HumanMessage |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can keep this out?
@rajasbansal With the updated code below is how we register the model.
Note: The |
src/autolabel/models/__init__.py
Outdated
) | ||
|
||
|
||
def _register_refuel() -> None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to do this in functions, we can add to the dictionary directly,
MODEL_REGISTRY = {
ModelProvider.HUGGINGFACE_PIPELINE: HFPipelineLLM,
ModelProvider.GOOGLE: PaLMLM
...
}
src/autolabel/models/openai.py
Outdated
import tiktoken | ||
|
||
from autolabel.models import BaseModel | ||
from autolabel.configs import AutolabelConfig | ||
from autolabel.cache import BaseCache | ||
from autolabel.schema import RefuelLLMResult | ||
|
||
from langchain.chat_models import ChatOpenAI |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lets move this to inside the model so that we don't fail if openai is not installed
src/autolabel/models/palm.py
Outdated
from autolabel.models import BaseModel | ||
from autolabel.configs import AutolabelConfig | ||
from autolabel.cache import BaseCache | ||
from autolabel.schema import RefuelLLMResult | ||
|
||
from langchain.chat_models import ChatVertexAI |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lets move this
src/autolabel/models/cohere.py
Outdated
from autolabel.models import BaseModel | ||
from autolabel.configs import AutolabelConfig | ||
from autolabel.cache import BaseCache | ||
from autolabel.schema import RefuelLLMResult | ||
from langchain.llms import Cohere |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same: move
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm. Thanks for the changes!
Custom Model and Global Dict
ModelRegistry
support