|
| 1 | +from typing import List |
1 | 2 | from cat.mad_hatter.decorators import tool, hook, plugin |
2 | | -from pydantic import BaseModel |
3 | | -from datetime import datetime, date |
4 | 3 |
|
5 | | -class MySettings(BaseModel): |
6 | | - required_int: int |
7 | | - optional_int: int = 69 |
8 | | - required_str: str |
9 | | - optional_str: str = "meow" |
10 | | - required_date: date |
11 | | - optional_date: date = 1679616000 |
| 4 | +from .llm.anthropic import LLMAnthropicChatConfig |
| 5 | +from .llm.cohere import LLMCohereConfig |
| 6 | +from .llm.gemini import LLMGeminiChatConfig |
| 7 | +from .llm.hugging_face import LLMHuggingFaceEndpointConfig, LLMHuggingFaceTextGenInferenceConfig |
| 8 | +from .llm.openai import ( |
| 9 | + LLMOpenAIChatConfig, |
| 10 | + LLMOpenAIConfig, |
| 11 | + LLMOpenAICompatibleConfig, |
| 12 | + LLMAzureOpenAIConfig, |
| 13 | + LLMAzureChatOpenAIConfig, |
| 14 | +) |
| 15 | +from .llm.ollama import LLMOllamaConfig |
| 16 | + |
| 17 | +from .embedder.embedder import ( |
| 18 | + EmbedderOpenAICompatibleConfig, |
| 19 | + EmbedderOpenAIConfig, |
| 20 | + EmbedderAzureOpenAIConfig, |
| 21 | + EmbedderCohereConfig, |
| 22 | + EmbedderQdrantFastEmbedConfig, |
| 23 | + EmbedderGeminiChatConfig, |
| 24 | +) |
| 25 | + |
| 26 | +# TODO: Add settings to allow model management |
| 27 | + |
| 28 | +llms = [ |
| 29 | + LLMAnthropicChatConfig, |
| 30 | + LLMCohereConfig, |
| 31 | + LLMGeminiChatConfig, |
| 32 | + LLMHuggingFaceEndpointConfig, |
| 33 | + LLMHuggingFaceTextGenInferenceConfig, |
| 34 | + LLMOpenAIChatConfig, |
| 35 | + LLMOpenAIConfig, |
| 36 | + LLMOpenAICompatibleConfig, |
| 37 | + LLMAzureOpenAIConfig, |
| 38 | + LLMAzureChatOpenAIConfig, |
| 39 | + LLMOllamaConfig, |
| 40 | +] |
12 | 41 |
|
13 | | -@plugin |
14 | | -def settings_model(): |
15 | | - return MySettings |
| 42 | +@hook |
| 43 | +def factory_allowed_llms(allowed, cat) -> List: |
| 44 | + allowed = allowed + llms |
| 45 | + return allowed |
16 | 46 |
|
17 | | -@tool |
18 | | -def get_the_day(tool_input, cat): |
19 | | - """Get the day of the week. Input is always None.""" |
20 | 47 |
|
21 | | - dt = datetime.now() |
| 48 | +embedders = [ |
| 49 | + EmbedderOpenAICompatibleConfig, |
| 50 | + EmbedderOpenAIConfig, |
| 51 | + EmbedderAzureOpenAIConfig, |
| 52 | + EmbedderCohereConfig, |
| 53 | + EmbedderQdrantFastEmbedConfig, |
| 54 | + EmbedderGeminiChatConfig, |
| 55 | +] |
22 | 56 |
|
23 | | - return dt.strftime('%A') |
24 | 57 |
|
25 | 58 | @hook |
26 | | -def before_cat_sends_message(message, cat): |
27 | | - |
28 | | - prompt = f'Rephrase the following sentence in a grumpy way: {message["content"]}' |
29 | | - message["content"] = cat.llm(prompt) |
30 | | - |
31 | | - return message |
| 59 | +def factory_allowed_embedders(allowed, cat) -> List: |
| 60 | + allowed = allowed + embedders |
| 61 | + return allowed |
0 commit comments