-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add Novita support to Python-TGPT library
fix: Update README.md to include Novita details patch: Bump version number to 0.7.5 fix: Add Novita provider to async_providers.py feat: Implement Novita provider in console.py fix: Add UnsupportedModelError exception handling
- Loading branch information
Showing
11 changed files
with
147 additions
and
6 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
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
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 |
---|---|---|
|
@@ -28,6 +28,7 @@ | |
"groq", | ||
"perplexity", | ||
"yepchat", | ||
"novita", | ||
] | ||
|
||
gpt4free_providers = [ | ||
|
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
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,4 +1,6 @@ | ||
class FailedToGenerateResponseError(Exception): | ||
"""Provider failed to fetch response""" | ||
|
||
pass | ||
|
||
class UnsupportedModelError(Exception): | ||
"""Model passed is not supported by the provider""" |
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,9 @@ | ||
from pytgpt.novita.main import NOVITA | ||
from pytgpt.novita.main import AsyncNOVITA | ||
from pytgpt.novita.main import available_models | ||
from pytgpt.openai.main import session | ||
|
||
|
||
__info__ = "Interact with NOVITA's model. " "API key is required" | ||
|
||
__all__ = ["NOVITA", "AsyncNOVITA", "available_models", "session"] |
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,58 @@ | ||
from pytgpt.openai import OPENAI, AsyncOPENAI | ||
from pytgpt.exceptions import UnsupportedModelError | ||
|
||
model = "meta-llama/llama-3.1-8b-instruct" | ||
|
||
available_models = [ | ||
"meta-llama/llama-3.1-8b-instruct", | ||
"meta-llama/llama-3.1-70b-instruct", | ||
"meta-llama/llama-3.1-405b-instruct", | ||
"meta-llama/llama-3-8b-instruct", | ||
"meta-llama/llama-3-70b-instruct", | ||
"gryphe/mythomax-l2-13b", | ||
"google/gemma-2-9b-it", | ||
"mistralai/mistral-nemo", | ||
"microsoft/wizardlm-2-8x22b", | ||
"mistralai/mistral-7b-instruct", | ||
"microsoft/wizardlm-2-7b", | ||
"openchat/openchat-7b", | ||
"nousresearch/hermes-2-pro-llama-3-8b", | ||
"sao10k/l3-70b-euryale-v2.1", | ||
"cognitivecomputations/dolphin-mixtral-8x22b", | ||
"jondurbin/airoboros-l2-70b", | ||
"lzlv_70b", | ||
"nousresearch/nous-hermes-llama2-13b", | ||
"teknium/openhermes-2.5-mistral-7b", | ||
"sophosympatheia/midnight-rose-70b", | ||
"meta-llama/llama-3.1-8b-instruct-bf16", | ||
"qwen/qwen-2.5-72b-instruct", | ||
"sao10k/l31-70b-euryale-v2.2", | ||
"qwen/qwen-2-7b-instruct", | ||
"qwen/qwen-2-72b-instruct", | ||
] | ||
|
||
|
||
class NOVITA(OPENAI): | ||
"""Novita AI provider""" | ||
|
||
def __init__(self, *args, **kwargs): | ||
kwargs.setdefault("model", model) | ||
if not model in available_models: | ||
raise UnsupportedModelError( | ||
f"Model '{model}' is not yet supported. Choose from {available_models}" | ||
) | ||
super().__init__(*args, **kwargs) | ||
self.chat_endpoint = "https://api.novita.ai/v3/openai/chat/completions" | ||
|
||
|
||
class AsyncNOVITA(AsyncOPENAI): | ||
"""Async Novita AI provider""" | ||
|
||
def __init__(self, *args, **kwargs): | ||
kwargs.setdefault("model", model) | ||
if not model in available_models: | ||
raise UnsupportedModelError( | ||
f"Model '{model}' is not yet supported choose from {available_models}" | ||
) | ||
super().__init__(*args, **kwargs) | ||
self.chat_endpoint = "https://api.novita.ai/v3/openai/chat/completions" |
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,24 @@ | ||
import unittest | ||
import tests.base as base | ||
from os import getenv | ||
from pytgpt.novita import NOVITA | ||
from pytgpt.novita import AsyncNOVITA | ||
|
||
API_KEY = getenv("NOVITA_API_KEY") | ||
|
||
|
||
class TestOpenai(base.llmBase): | ||
def setUp(self): | ||
self.bot = NOVITA(API_KEY) | ||
self.prompt = base.prompt | ||
|
||
|
||
class TestAsyncOpenai(base.AsyncProviderBase): | ||
|
||
def setUp(self): | ||
self.bot = AsyncNOVITA(API_KEY) | ||
self.prompt = base.prompt | ||
|
||
|
||
if __name__ == "__main__": | ||
unittest.main() |
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