Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added HuggingFaceTool to Explore HF Hub #97

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

sk5268
Copy link
Contributor

@sk5268 sk5268 commented Dec 30, 2024

Purpose

I made a new tool openagi.actions.tools.huggingface.HuggingFaceTool that can search for models and datasets across the HuggingFace Hub.

Usage

Agent = Worker(
    role = "Model and Dataset searching agent",
    instructions = "Search for the prompted model or dataset",
    actions = [HuggingFaceTool]
)

Demo

import os
from openagi.agent import Admin
from openagi.memory import Memory
from openagi.worker import Worker
from openagi.llms.gemini import GeminiModel
from openagi.planner.task_decomposer import TaskPlanner
from openagi.actions.tools.hf import HuggingFaceTool

os.environ['GOOGLE_API_KEY'] = "YOUR_GEMINI_API_KEY"
os.environ['Gemini_MODEL'] = "gemini-1.5-flash"
os.environ['Gemini_TEMP'] = "0.5"

config = GeminiModel.load_from_env_config()
llm = GeminiModel(config=config)



# Implementing HuggingFace Agent

search_agent = Worker(
    role="Search Agent",
    instructions="""
    Search for the prompted model or dataset.
    """,
    actions=[HuggingFaceTool]
)

admin = Admin(
    llm=llm,
    planner=TaskPlanner(
        autonomous=False,
        human_intervene=False
    ),
    memory=Memory(),
    verbose=True
)

admin.assign_workers([
    search_agent
])

response = admin.run(
    query="gemma model",
    description="",
)

print(response)

Output

677118ff5e14911d6219773f

@lucifertrj

models = api.list_models(search=self.query, limit=15)
datasets = api.list_datasets(search=self.query, limit=15)

for model in models:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you also extract other details as well. just model ID is very limited context given to the LLM

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The API returns the following details:

ModelInfo(id='prithivMLmods/Qwen2-VL-Math-Prase-2B-Instruct', author=None, sha=None,
created_at=datetime.datetime(2024, 12, 19, 4, 38, 46, tzinfo=datetime.timezone.utc),
last_modified=None, private=False, disabled=None, downloads=248, downloads_all_time=None,
gated=None, gguf=None, inference=None, likes=8, library_name='transformers',
tags=['transformers', 'safetensors', 'qwen2_vl', 'image-text-to-text', 'conversational', 'en',
'base_model:Qwen/Qwen2-VL-2B-Instruct', 'base_model:finetune:Qwen/Qwen2-VL-2B-Instruct',
'license:apache-2.0', 'text-generation-inference', 'endpoints_compatible', 'region:us'],
pipeline_tag='image-text-to-text', mask_token=None, card_data=None, widget_data=None, model_index=None,
config=None, transformers_info=None, trending_score=8, siblings=None, spaces=None,
safetensors=None, security_repo_status=None)

I think we can add:

  • tags
  • pipeline_tag
  • config
  • transfotmers_info

@tarun-aiplanet please let me know which one's to add and i'll make the changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants