-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from hookla/11-add-meeting-object
- Loading branch information
Showing
17 changed files
with
253 additions
and
128 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
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,3 +1,4 @@ | ||
from .base import AIClient | ||
from .config import AIClientConfig | ||
from .get_client import AIClientType, GPTClient, get_ai_client | ||
from .config import AIClientConfig, AIClientType | ||
from .get_client import GPTClient, ai_client_factory, get_ai_client | ||
from .gpt_client import Models |
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,7 +1,15 @@ | ||
from dataclasses import dataclass | ||
from enum import Enum | ||
|
||
from .gpt_client import Models | ||
|
||
|
||
class AIClientType(str, Enum): | ||
ChatGPT = "ChatGPT" | ||
|
||
|
||
@dataclass | ||
class AIClientConfig: | ||
client_type: AIClientType | ||
api_key: str | ||
model: str | None | ||
model: Models | None |
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,16 +1,50 @@ | ||
from enum import Enum | ||
from dataclasses import dataclass | ||
from typing import Any, Callable | ||
|
||
from dream_team_gpt.clients.base import AIClient | ||
from dream_team_gpt.clients.config import AIClientConfig | ||
from dream_team_gpt.clients.gpt_client import GPTClient | ||
from .base import AIClient | ||
from .config import AIClientConfig, AIClientType | ||
from .gpt_client import GPTClient, Models | ||
|
||
|
||
class AIClientType(str, Enum): | ||
ChatGPT = "ChatGPT" | ||
|
||
|
||
def get_ai_client(client_type: AIClientType, config: AIClientConfig) -> AIClient: | ||
if client_type == AIClientType.ChatGPT: | ||
def get_ai_client(config: AIClientConfig) -> AIClient: | ||
if config.client_type == AIClientType.ChatGPT: | ||
return GPTClient(config.api_key) | ||
else: | ||
raise ValueError(f"Unknown AI client type: {client_type}") | ||
raise ValueError(f"Unknown AI client type: {config.client_type}") | ||
|
||
|
||
def ai_client_factory(config: AIClientConfig) -> Callable[[Any], AIClient]: | ||
return lambda _: get_ai_client(config) | ||
|
||
|
||
@dataclass | ||
class AIClientFactory: | ||
"""Callable factory for AIClient. | ||
Usage: | ||
factory = AIClientFactory(config=AIClientConfig(...)) | ||
Agent(factory) | ||
or | ||
factory.config.client_type=<AIClientType> | ||
factory.config.model=<Models> | ||
Agent(factory) | ||
or update these config params in Agent on calling the factory: | ||
factory(client_type=<AIClientType>,model=<Models>) | ||
""" | ||
|
||
config: AIClientConfig | ||
|
||
def __call__( | ||
self, client_type: AIClientType = None, model: Models = None | ||
) -> Callable[[Any], AIClient]: | ||
if client_type: | ||
self.config.client_type = client_type | ||
if model: | ||
self.config.model = model | ||
|
||
return lambda _: get_ai_client(self.config) |
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
Oops, something went wrong.