Skip to content

Commit

Permalink
Merge pull request #18 from enoch3712/17-ollama-support-for-local-llms
Browse files Browse the repository at this point in the history
Ollama support added. With a test connecting to a phi-3 mini model
  • Loading branch information
enoch3712 authored Jun 13, 2024
2 parents 5e3126c + ae19a39 commit fdfda7f
Show file tree
Hide file tree
Showing 4 changed files with 147 additions and 36 deletions.
10 changes: 8 additions & 2 deletions extract_thinker/llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,13 @@


class LLM:
def __init__(self, model: str):
def __init__(self, model: str, api_base: str = None, api_key: str = None, api_version: str = None):
self.client = instructor.from_litellm(litellm.completion, mode=instructor.Mode.MD_JSON)
self.model = model
self.router = None
self.api_base = api_base
self.api_key = api_key
self.api_version = api_version

def load_router(self, router: Router) -> None:
self.router = router
Expand All @@ -31,7 +34,10 @@ def request(self, messages: List[Dict[str, str]], response_model: str) -> Any:
model=self.model,
max_tokens=max_tokens,
messages=messages,
response_model=response_model
response_model=response_model,
api_base=self.api_base,
api_key=self.api_key,
api_version=self.api_version
)

return response
138 changes: 105 additions & 33 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "extract_thinker"
version = "0.0.5"
version = "0.0.6"
description = "Library to extract data from files and documents agnositicaly using LLMs"
authors = ["Júlio Almeida <[email protected]>"]
readme = "README.md"
Expand Down
Loading

0 comments on commit fdfda7f

Please sign in to comment.