pull/440/head
Kye 9 months ago
parent ffd53e1c65
commit 7ec5ce2d1e

@ -16,6 +16,7 @@ model = AutoModelForCausalLM.from_pretrained(
# Load the pre-trained model and tokenizer # Load the pre-trained model and tokenizer
tokenizer = AutoTokenizer.from_pretrained(model_name) tokenizer = AutoTokenizer.from_pretrained(model_name)
# Initialize the schema for the person's information # Initialize the schema for the person's information
class APIExampleRequestSchema(BaseModel): class APIExampleRequestSchema(BaseModel):
endpoint: str = Field( endpoint: str = Field(
@ -31,22 +32,25 @@ class APIExampleRequestSchema(BaseModel):
..., description="The body of the example request" ..., description="The body of the example request"
) )
response: dict = Field( response: dict = Field(
..., description="The expected response of the example request" ...,
description="The expected response of the example request",
) )
# Convert the schema to a JSON string # Convert the schema to a JSON string
api_example_schema = base_model_to_json(APIExampleRequestSchema) api_example_schema = base_model_to_json(APIExampleRequestSchema)
# Convert the schema to a JSON string # Convert the schema to a JSON string
# Define the task to generate a person's information # Define the task to generate a person's information
task = ( task = "Generate an example API request using this code:\n"
"Generate an example API request using this code:\n"
)
# Create an instance of the ToolAgent class # Create an instance of the ToolAgent class
agent = ToolAgent( agent = ToolAgent(
name="Command R Tool Agent", name="Command R Tool Agent",
description="An agent that generates an API request using the Command R model.", description=(
"An agent that generates an API request using the Command R"
" model."
),
model=model, model=model,
tokenizer=tokenizer, tokenizer=tokenizer,
json_schema=api_example_schema, json_schema=api_example_schema,

@ -16,6 +16,7 @@ model = AutoModelForCausalLM.from_pretrained(
# Load the pre-trained model and tokenizer # Load the pre-trained model and tokenizer
tokenizer = AutoTokenizer.from_pretrained(model_name) tokenizer = AutoTokenizer.from_pretrained(model_name)
# Initialize the schema for the person's information # Initialize the schema for the person's information
class APIExampleRequestSchema(BaseModel): class APIExampleRequestSchema(BaseModel):
endpoint: str = Field( endpoint: str = Field(
@ -31,22 +32,25 @@ class APIExampleRequestSchema(BaseModel):
..., description="The body of the example request" ..., description="The body of the example request"
) )
response: dict = Field( response: dict = Field(
..., description="The expected response of the example request" ...,
description="The expected response of the example request",
) )
# Convert the schema to a JSON string # Convert the schema to a JSON string
api_example_schema = base_model_to_json(APIExampleRequestSchema) api_example_schema = base_model_to_json(APIExampleRequestSchema)
# Convert the schema to a JSON string # Convert the schema to a JSON string
# Define the task to generate a person's information # Define the task to generate a person's information
task = ( task = "Generate an example API request using this code:\n"
"Generate an example API request using this code:\n"
)
# Create an instance of the ToolAgent class # Create an instance of the ToolAgent class
agent = ToolAgent( agent = ToolAgent(
name="Command R Tool Agent", name="Command R Tool Agent",
description="An agent that generates an API request using the Command R model.", description=(
"An agent that generates an API request using the Command R"
" model."
),
model=model, model=model,
tokenizer=tokenizer, tokenizer=tokenizer,
json_schema=api_example_schema, json_schema=api_example_schema,

@ -32,6 +32,7 @@ from swarms.models.popular_llms import (
from swarms.models.popular_llms import ( from swarms.models.popular_llms import (
ReplicateLLM as Replicate, ReplicateLLM as Replicate,
) )
from swarms.models.popular_llms import OctoAIChat
from swarms.models.qwen import QwenVLMultiModal # noqa: E402 from swarms.models.qwen import QwenVLMultiModal # noqa: E402
from swarms.models.sampling_params import SamplingParams, SamplingType from swarms.models.sampling_params import SamplingParams, SamplingType
@ -79,4 +80,5 @@ __all__ = [
"AudioModality", "AudioModality",
"ImageModality", "ImageModality",
"VideoModality", "VideoModality",
"OctoAIChat",
] ]

@ -11,6 +11,7 @@ from langchain_community.llms import (
OpenAI, OpenAI,
Replicate, Replicate,
) )
from langchain_community.llms.octoai_endpoint import OctoAIEndpoint
class AnthropicChat(Anthropic): class AnthropicChat(Anthropic):
@ -46,3 +47,8 @@ class AzureOpenAILLM(AzureChatOpenAI):
class OpenAIChatLLM(OpenAIChat): class OpenAIChatLLM(OpenAIChat):
def __call__(self, *args, **kwargs): def __call__(self, *args, **kwargs):
return self.invoke(*args, **kwargs) return self.invoke(*args, **kwargs)
class OctoAIChat(OctoAIEndpoint):
def __call__(self, *args, **kwargs):
return self.invoke(*args, **kwargs)

@ -40,6 +40,7 @@ from swarms.utils.remove_json_whitespace import (
remove_whitespace_from_yaml, remove_whitespace_from_yaml,
) )
from swarms.utils.save_logs import parse_log_file from swarms.utils.save_logs import parse_log_file
# from swarms.utils.supervision_visualizer import MarkVisualizer # from swarms.utils.supervision_visualizer import MarkVisualizer
from swarms.utils.try_except_wrapper import try_except_wrapper from swarms.utils.try_except_wrapper import try_except_wrapper
from swarms.utils.yaml_output_parser import YamlOutputParser from swarms.utils.yaml_output_parser import YamlOutputParser

Loading…
Cancel
Save