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

Bug: integration with giphy API is not working #147

Open
davorrunje opened this issue Sep 9, 2024 · 0 comments · Fixed by #165
Open

Bug: integration with giphy API is not working #147

davorrunje opened this issue Sep 9, 2024 · 0 comments · Fixed by #165
Assignees
Labels
bug Something isn't working

Comments

@davorrunje
Copy link
Contributor

davorrunje commented Sep 9, 2024

Describe the bug
Standalone client with security created for giphy API works but it fails when running it with fastagency run

How to reproduce
Include source code:

import os

import requests
from autogen.agentchat import ConversableAgent
from autogen import UserProxyAgent

from fastagency.core import Chatable
from fastagency.core.runtimes.autogen.base import AutoGenWorkflows
from fastagency.core.io.console import ConsoleIO
from fastagency.openapi.client import Client
from fastagency.openapi.security import APIKeyQuery

from fastagency import FastAgency

llm_config = {
    "config_list": [
        {
            "model": "gpt-4o-mini",
            "api_key": os.getenv("OPENAI_API_KEY"),
        }
    ],
    "temperature": 0.8,
}

GIPHY_OPENAPI_URL = "https://raw.githubusercontent.com/airtai/fastagency/main/examples/openapi/giphy_openapi.json"
with requests.get(GIPHY_OPENAPI_URL, timeout=10) as response:
    response.raise_for_status()
    openapi_json = response.text
# print(openapi_json)
print(type(openapi_json))

wf = AutoGenWorkflows()

@wf.register(name="simple_gif_search", description="Giphy gif chat")
def gif_workflow(io: Chatable, initial_message: str, session_id: str) -> str:
    
    giphy_client = Client.create(openapi_json=openapi_json)
    giphy_client.set_security_params(APIKeyQuery.Parameters(value="ASK_KUMARAN"))

    user_agent = UserProxyAgent(
        name="User_Agent",
        system_message="You are a user agent",
        llm_config=llm_config,
        human_input_mode="NEVER",
    )
    giphy_agent = ConversableAgent(
        name="Giphy_Agent",
        system_message="You are a gif agent who search for random gifs on Giphy",
        llm_config=llm_config,
        human_input_mode="NEVER",
    )

    giphy_client.register_for_llm(giphy_agent)
    giphy_client.register_for_execution(user_agent)

    chat_result = user_agent.initiate_chat(
        giphy_agent,
        message=initial_message,
        summary_method="reflection_with_llm",
        max_turns=3,
    )

    return chat_result.summary

app = FastAgency(wf=wf, io=ConsoleIO())

Get an API key from giphy, update it in the above code and run it

Expected behavior
Agents should fetch a gif url using giphy api

Observed behavior
Fails with TypeError: Object of type Path is not JSON serializable

Full traceback
Full traceback is available with @kumaranvpl if needed. Too many lines to paste it here.

@davorrunje davorrunje added the bug Something isn't working label Sep 9, 2024
@davorrunje davorrunje assigned kumaranvpl and davorrunje and unassigned kumaranvpl Sep 9, 2024
@harishmohanraj harishmohanraj mentioned this issue Sep 10, 2024
13 tasks
@kumaranvpl kumaranvpl reopened this Sep 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants