Skip to content

Commit

Permalink
Refactoring: now using the langchain class
Browse files Browse the repository at this point in the history
  • Loading branch information
valentimarco committed Oct 20, 2023
1 parent 30e8a45 commit 26f060a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 18 deletions.
14 changes: 0 additions & 14 deletions core/cat/factory/custom_llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import requests
from langchain.llms.base import LLM
from langchain.llms.openai import OpenAI
from langchain.llms.ollama import Ollama


class LLMDefault(LLM):
Expand Down Expand Up @@ -88,18 +87,5 @@ def __init__(self, **kwargs):
self.url = kwargs['url']
self.openai_api_base = os.path.join(self.url, "v1")

class CustomOllama(Ollama):


def __init__(self, **kwargs):

super().__init__(
base_url=kwargs["base_url"],
model=kwargs["model"],
num_ctx=kwargs["num_ctx"],
repeat_last_n=kwargs["repeat_last_n"],
repeat_penalty=kwargs["repeat_penalty"],
temperature=kwargs["temperature"],
)


8 changes: 4 additions & 4 deletions core/cat/factory/llm.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import langchain
from langchain.chat_models import ChatOpenAI, AzureChatOpenAI
from langchain.llms import OpenAI, AzureOpenAI

from langchain.llms.ollama import Ollama
from typing import Dict, List, Type
import json
from pydantic import BaseModel, ConfigDict

from cat.factory.custom_llm import CustomOllama, LLMDefault, LLMCustom, CustomOpenAI
from cat.factory.custom_llm import LLMDefault, LLMCustom, CustomOpenAI


# Base class to manage LLM configuration.
Expand Down Expand Up @@ -279,8 +279,8 @@ class LLMCustomOllama(LLMSettings):
repeat_last_n: int = 64
repeat_penalty: float = 1.1
temperature: float = 0.8

_pyclass: Type = CustomOllama
_pyclass: Type = Ollama

model_config = ConfigDict(
json_schema_extra = {
Expand Down

0 comments on commit 26f060a

Please sign in to comment.