You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To avoid long import paths and make it easier to change model using just a string, add a model function that returns the appropriate ChatModel instance based on the name provided. This should also accept all other model args (temperature, max_tokens, etc.). For models that do not support the provided args we can raise an error, warn, or ignore, and this should be configurable by a parameter.
This function should be used for creation of the default ChatModel from env vars, to keep behavior consistent. Including giving a clear error message if the required dependency is not installed. Related issue: #415
There should be a way to register new ChatModel classes for users that create their own.
Usage
frommagenticimportmodel, prompt@prompt("Say hello")defsay_hello() ->str: ...
@prompt("Say hello",model=model("anthropic:claude-3-5-sonnet-latest"),# And even justmodel="anthropic:claude-3-5-sonnet-latest",)defsay_hello_anthropic() ->str: ...
say_hello() # Uses env vars or default settingswithmodel("openai:gpt-4o-mini", temperature=1):
say_hello() # Uses openai with gpt-4o-mini and temperature=1 due to context managersay_hello_anthropic() # Uses Anthropic claude-3-5-sonnet-latest because explicitly configured
The text was updated successfully, but these errors were encountered:
To avoid long import paths and make it easier to change model using just a string, add a
model
function that returns the appropriateChatModel
instance based on the name provided. This should also accept all other model args (temperature, max_tokens, etc.). For models that do not support the provided args we can raise an error, warn, or ignore, and this should be configurable by a parameter.This function should be used for creation of the default ChatModel from env vars, to keep behavior consistent. Including giving a clear error message if the required dependency is not installed. Related issue: #415
There should be a way to register new
ChatModel
classes for users that create their own.Usage
The text was updated successfully, but these errors were encountered: