sentient-engineering / sentient

the framework/ sdk that lets you build browser controlling agents in 3 lines of code. join chat @ https://discord.gg/umgnyQU2K8
MIT License
457 stars 51 forks source link

provide support for https://openrouter.ai/ #27

Closed pleabargain closed 1 month ago

pleabargain commented 2 months ago

provide support for https://openrouter.ai/

image

OSH212 commented 1 month ago

add the following to utils/providers.py:

class OpenRouterProvider(LLMProvider):
    def get_client_config(self) -> Dict[str, str]:
        return {
            "api_key": os.environ.get("OPENROUTER_API_KEY"),
            "base_url": "https://openrouter.ai/api/v1",
        }

    def get_provider_name(self) -> str:
        return "openrouter"

PROVIDER_MAP = {
    "openai": OpenAIProvider(),
    "together": TogetherAIProvider(),
    "ollama": OllamaProvider(),
    "groq": GroqProvider(),
    "anthropic": AnthropicProvider(),
    "openrouter": OpenRouterProvider(),
    # "google": GoogleProvider(),

-You can test it like:


from sentient import sentient
import asyncio
import nest_asyncio
nest_asyncio.apply()

custom_instructions = """
1. Directly go to youtube.com rather than searching for the song on google!

"""

#use with openrouter
result = asyncio.run(sentient.invoke(
    goal="play shape of you on youtube",
    task_instructions=custom_instructions,
    provider="openrouter",
    model="openai/gpt-4o-2024-08-06"))
thebhulawat commented 1 month ago

which model are you trying to use using open router?

thebhulawat commented 1 month ago

https://github.com/sentient-engineering/sentient/pull/30

thebhulawat commented 1 month ago

pls feel free to open this if you face any issue!