Skip to content

Commit

Permalink
models temp removed, deepseek reasoner support
Browse files Browse the repository at this point in the history
  • Loading branch information
frdel committed Jan 20, 2025
1 parent 97b5e64 commit 7a7d2ee
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 159 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

</div>

[![Browser Agent](/docs/res/081_vid.png)](https://youtu.be/quv145buW74)

> [!NOTE]
> **🎉 v0.8.1 Release**: Now featuring a browser agent capable of using Chromium for web interactions! This enables Agent Zero to browse the web, gather information, and interact with web content autonomously.
Expand Down
Binary file added docs/res/081_vid.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 4 additions & 15 deletions initialize.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,7 @@ def initialize():
limit_requests=current_settings["chat_model_rl_requests"],
limit_input=current_settings["chat_model_rl_input"],
limit_output=current_settings["chat_model_rl_output"],
kwargs={
"temperature": current_settings["chat_model_temperature"],
**current_settings["chat_model_kwargs"],
},
kwargs=current_settings["chat_model_kwargs"],
)

# utility model from user settings
Expand All @@ -30,29 +27,21 @@ def initialize():
limit_requests=current_settings["util_model_rl_requests"],
limit_input=current_settings["util_model_rl_input"],
limit_output=current_settings["util_model_rl_output"],
kwargs={
"temperature": current_settings["util_model_temperature"],
**current_settings["util_model_kwargs"],
},
kwargs=current_settings["util_model_kwargs"],
)
# embedding model from user settings
embedding_llm = ModelConfig(
provider=models.ModelProvider[current_settings["embed_model_provider"]],
name=current_settings["embed_model_name"],
limit_requests=current_settings["embed_model_rl_requests"],
kwargs={
**current_settings["embed_model_kwargs"],
},
kwargs=current_settings["embed_model_kwargs"],
)
# browser model from user settings
browser_llm = ModelConfig(
provider=models.ModelProvider[current_settings["browser_model_provider"]],
name=current_settings["browser_model_name"],
vision=current_settings["browser_model_vision"],
kwargs={
"temperature": current_settings["browser_model_temperature"],
**current_settings["browser_model_kwargs"],
},
kwargs=current_settings["browser_model_kwargs"],
)
# agent configuration
config = AgentConfig(
Expand Down
59 changes: 25 additions & 34 deletions models.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
embeddings as google_embeddings,
)
from langchain_mistralai import ChatMistralAI

# from pydantic.v1.types import SecretStr
from python.helpers import dotenv, runtime
from python.helpers.dotenv import load_dotenv
Expand All @@ -34,9 +35,6 @@
# environment variables
load_dotenv()

# Configuration
DEFAULT_TEMPERATURE = 0.0


class ModelType(Enum):
CHAT = "Chat"
Expand Down Expand Up @@ -110,7 +108,6 @@ def get_ollama_base_url():

def get_ollama_chat(
model_name: str,
temperature=DEFAULT_TEMPERATURE,
base_url=None,
num_ctx=8192,
**kwargs,
Expand All @@ -119,7 +116,6 @@ def get_ollama_chat(
base_url = get_ollama_base_url()
return ChatOllama(
model=model_name,
temperature=temperature,
base_url=base_url,
num_ctx=num_ctx,
**kwargs,
Expand All @@ -128,22 +124,21 @@ def get_ollama_chat(

def get_ollama_embedding(
model_name: str,
temperature=DEFAULT_TEMPERATURE,
base_url=None,
num_ctx=8192,
**kwargs,
):
if not base_url:
base_url = get_ollama_base_url()
return OllamaEmbeddings(
model=model_name, temperature=temperature, base_url=base_url, **kwargs
model=model_name, base_url=base_url, num_ctx=num_ctx, **kwargs
)


# HuggingFace models
def get_huggingface_chat(
model_name: str,
api_key=None,
temperature=DEFAULT_TEMPERATURE,
**kwargs,
):
# different naming convention here
Expand All @@ -155,7 +150,6 @@ def get_huggingface_chat(
repo_id=model_name,
task="text-generation",
do_sample=True,
temperature=temperature,
**kwargs,
)

Expand All @@ -177,13 +171,12 @@ def get_lmstudio_base_url():

def get_lmstudio_chat(
model_name: str,
temperature=DEFAULT_TEMPERATURE,
base_url=None,
**kwargs,
):
if not base_url:
base_url = get_lmstudio_base_url()
return ChatOpenAI(model_name=model_name, base_url=base_url, temperature=temperature, api_key="none", **kwargs) # type: ignore
return ChatOpenAI(model_name=model_name, base_url=base_url, api_key="none", **kwargs) # type: ignore


def get_lmstudio_embedding(
Expand All @@ -200,12 +193,16 @@ def get_lmstudio_embedding(
def get_anthropic_chat(
model_name: str,
api_key=None,
temperature=DEFAULT_TEMPERATURE,
base_url=None,
**kwargs,
):
if not api_key:
api_key = get_api_key("anthropic")
return ChatAnthropic(model_name=model_name, temperature=temperature, api_key=api_key, **kwargs) # type: ignore
if not base_url:
base_url = (
dotenv.get_dotenv_value("ANTHROPIC_BASE_URL") or "https://api.anthropic.com"
)
return ChatAnthropic(model_name=model_name, api_key=api_key, base_url=base_url, **kwargs) # type: ignore


# right now anthropic does not have embedding models, but that might change
Expand All @@ -223,12 +220,11 @@ def get_anthropic_embedding(
def get_openai_chat(
model_name: str,
api_key=None,
temperature=DEFAULT_TEMPERATURE,
**kwargs,
):
if not api_key:
api_key = get_api_key("openai")
return ChatOpenAI(model_name=model_name, temperature=temperature, api_key=api_key, **kwargs) # type: ignore
return ChatOpenAI(model_name=model_name, api_key=api_key, **kwargs) # type: ignore


def get_openai_embedding(model_name: str, api_key=None, **kwargs):
Expand All @@ -240,15 +236,14 @@ def get_openai_embedding(model_name: str, api_key=None, **kwargs):
def get_openai_azure_chat(
deployment_name: str,
api_key=None,
temperature=DEFAULT_TEMPERATURE,
azure_endpoint=None,
**kwargs,
):
if not api_key:
api_key = get_api_key("openai_azure")
if not azure_endpoint:
azure_endpoint = dotenv.get_dotenv_value("OPENAI_AZURE_ENDPOINT")
return AzureChatOpenAI(deployment_name=deployment_name, temperature=temperature, api_key=api_key, azure_endpoint=azure_endpoint, **kwargs) # type: ignore
return AzureChatOpenAI(deployment_name=deployment_name, api_key=api_key, azure_endpoint=azure_endpoint, **kwargs) # type: ignore


def get_openai_azure_embedding(
Expand All @@ -268,12 +263,11 @@ def get_openai_azure_embedding(
def get_google_chat(
model_name: str,
api_key=None,
temperature=DEFAULT_TEMPERATURE,
**kwargs,
):
if not api_key:
api_key = get_api_key("google")
return GoogleGenerativeAI(model=model_name, temperature=temperature, google_api_key=api_key, safety_settings={HarmCategory.HARM_CATEGORY_DANGEROUS_CONTENT: HarmBlockThreshold.BLOCK_NONE}, **kwargs) # type: ignore
return GoogleGenerativeAI(model=model_name, google_api_key=api_key, safety_settings={HarmCategory.HARM_CATEGORY_DANGEROUS_CONTENT: HarmBlockThreshold.BLOCK_NONE}, **kwargs) # type: ignore


def get_google_embedding(
Expand All @@ -290,49 +284,48 @@ def get_google_embedding(
def get_mistralai_chat(
model_name: str,
api_key=None,
temperature=DEFAULT_TEMPERATURE,
**kwargs,
):
if not api_key:
api_key = get_api_key("mistral")
return ChatMistralAI(model=model_name, temperature=temperature, api_key=api_key, **kwargs) # type: ignore
return ChatMistralAI(model=model_name, api_key=api_key, **kwargs) # type: ignore


# Groq models
def get_groq_chat(
model_name: str,
api_key=None,
temperature=DEFAULT_TEMPERATURE,
**kwargs,
):
if not api_key:
api_key = get_api_key("groq")
return ChatGroq(model_name=model_name, temperature=temperature, api_key=api_key, **kwargs) # type: ignore
return ChatGroq(model_name=model_name, api_key=api_key, **kwargs) # type: ignore


# DeepSeek models
def get_deepseek_chat(
model_name: str,
api_key=None,
temperature=DEFAULT_TEMPERATURE,
base_url=None,
**kwargs,
):
if not api_key:
api_key = get_api_key("deepseek")
if not base_url:
base_url = (
dotenv.get_dotenv_value("DEEPSEEK_BASE_URL")
or "https://api.deepseek.com"
dotenv.get_dotenv_value("DEEPSEEK_BASE_URL") or "https://api.deepseek.com"
)
return ChatOpenAI(api_key=api_key, model=model_name, temperature=temperature, base_url=base_url, **kwargs) # type: ignore


model = ChatOpenAI(api_key=api_key, model=model_name, base_url=base_url, **kwargs) # type: ignore
# little hack for reasoning model's problem with temperature
if not "temperature" in kwargs:
model.temperature = None # type: ignore
return model

# OpenRouter models
def get_openrouter_chat(
model_name: str,
api_key=None,
temperature=DEFAULT_TEMPERATURE,
base_url=None,
**kwargs,
):
Expand All @@ -343,7 +336,7 @@ def get_openrouter_chat(
dotenv.get_dotenv_value("OPEN_ROUTER_BASE_URL")
or "https://openrouter.ai/api/v1"
)
return ChatOpenAI(api_key=api_key, model=model_name, temperature=temperature, base_url=base_url, **kwargs) # type: ignore
return ChatOpenAI(api_key=api_key, model=model_name, base_url=base_url, **kwargs) # type: ignore


def get_openrouter_embedding(
Expand All @@ -366,7 +359,6 @@ def get_openrouter_embedding(
def get_sambanova_chat(
model_name: str,
api_key=None,
temperature=DEFAULT_TEMPERATURE,
base_url=None,
max_tokens=1024,
**kwargs,
Expand All @@ -378,7 +370,7 @@ def get_sambanova_chat(
dotenv.get_dotenv_value("SAMBANOVA_BASE_URL")
or "https://fast-api.snova.ai/v1"
)
return ChatOpenAI(api_key=api_key, model=model_name, temperature=temperature, base_url=base_url, max_tokens=max_tokens, **kwargs) # type: ignore
return ChatOpenAI(api_key=api_key, model=model_name, base_url=base_url, max_tokens=max_tokens, **kwargs) # type: ignore


# right now sambanova does not have embedding models, but that might change
Expand All @@ -402,11 +394,10 @@ def get_sambanova_embedding(
def get_other_chat(
model_name: str,
api_key=None,
temperature=DEFAULT_TEMPERATURE,
base_url=None,
**kwargs,
):
return ChatOpenAI(api_key=api_key, model=model_name, temperature=temperature, base_url=base_url, **kwargs) # type: ignore
return ChatOpenAI(api_key=api_key, model=model_name, base_url=base_url, **kwargs) # type: ignore


def get_other_embedding(model_name: str, api_key=None, base_url=None, **kwargs):
Expand Down
2 changes: 1 addition & 1 deletion prompts/default/agent.system.main.role.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
## Your role
{{agent_name}} autonomous json ai agent
agent zero autonomous json ai agent
solve superior tasks using tools and subordinates
follow behavioral rules instructions
execute code actions yourself not instruct superior
Expand Down
Loading

0 comments on commit 7a7d2ee

Please sign in to comment.