mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-09 16:18:30 +00:00
* rebuilding executor * removing langchain * Making all tests good * fixing types and adding ability for nor using system prompts * improving types * pleasing the types gods * pleasing the types gods * fixing parser, tools and executor * making sure all tests pass * final pass * fixing type * Updating Docs * preparing to cut new version
21 lines
649 B
Python
21 lines
649 B
Python
from typing import Any, Dict, List
|
|
from litellm import completion
|
|
import litellm
|
|
|
|
|
|
class LLM:
|
|
def __init__(self, model: str, stop: List[str] = [], callbacks: List[Any] = []):
|
|
self.stop = stop
|
|
self.model = model
|
|
litellm.callbacks = callbacks
|
|
|
|
def call(self, messages: List[Dict[str, str]]) -> Dict[str, Any]:
|
|
response = completion(
|
|
stop=self.stop, model=self.model, messages=messages, num_retries=5
|
|
)
|
|
return response["choices"][0]["message"]["content"]
|
|
|
|
def _call_callbacks(self, formatted_answer):
|
|
for callback in self.callbacks:
|
|
callback(formatted_answer)
|