-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Intense cleanup of the API, rename of components and streamlining con…
…cept.
- Loading branch information
Showing
22 changed files
with
440 additions
and
275 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,13 @@ | ||
[project] | ||
name = "tackleberry" | ||
version = "0.1.0.dev1" | ||
version = "0.1.0" | ||
description = "Tackleberry (or TB) is helping you tackle the access to AI" | ||
authors = [ | ||
{ name = "Torsten Raudßus", email = "[email protected]" }, | ||
] | ||
dependencies = [ | ||
"pydantic>=2.0.0", | ||
"instructor>=1.7.0", | ||
"typing-extensions>=4.0.0", | ||
"pyyaml>=6.0.0", | ||
] | ||
|
@@ -27,7 +28,9 @@ dev = [ | |
"ollama", | ||
"transformers", | ||
"groq", | ||
"instructor[groq]", | ||
"anthropic", | ||
"instructor[anthropic]", | ||
] | ||
|
||
[build-system] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
from typing import Union | ||
|
||
from .context import TBContext | ||
from .model import TBModel | ||
|
||
from pydantic import BaseModel | ||
|
||
class TBChat: | ||
count = 0 | ||
|
||
def __init__(self, | ||
model_name_or_model: Union[str, TBModel], | ||
context: TBContext = None, | ||
system_prompt: str = None, | ||
struct: BaseModel = None, | ||
name: str = None, | ||
**kwargs, | ||
): | ||
TBChat.count += 1 | ||
self.name = name or f'TBChat-{TBChat.count}' | ||
if isinstance(model_name_or_model, TBModel): | ||
self.model = model_name_or_model | ||
else: | ||
from . import TB | ||
self.model = TB.model(model_name_or_model) | ||
self.struct = struct | ||
self.context = context if context is not None else TBContext() | ||
if system_prompt is not None: | ||
self.context.add_system(system_prompt) | ||
self.model_name = self.model.name | ||
self.runtime = self.model.runtime | ||
|
||
def get_messages(self): | ||
return self.runtime.get_messages_from_context(self.context) | ||
|
||
def query(self, | ||
query_or_context: Union[str, TBContext], | ||
struct: BaseModel = None, | ||
**kwargs, | ||
): | ||
context = query_or_context if isinstance(query_or_context, TBContext) else self.context.copy_with_query(query_or_context) | ||
return self.runtime.chat_context(self, context, struct=struct, **kwargs) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
from .runtime import TBRuntime | ||
|
||
class TBModel: | ||
|
||
def __init__(self, runtime: TBRuntime, name: str, **kwargs): | ||
self.runtime = runtime | ||
self.name = name | ||
self.options = kwargs | ||
|
||
def chat(self, **kwargs): | ||
from .chat import TBChat | ||
return TBChat(self, **kwargs) |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.