Skip to main content
Loading navigation
Back to prompt library

Integrate Gemini 2.5 Flash and LIME

Linked challenge: Multi-Agent Ad Policy Auditor

Prompt source

implementation17 lines5 sectionsNo variables1 code block
Implement the `UserTopicAnalyzer` agent to call Gemini 2.5 Flash for extracting topics from simulated user data. Subsequently, integrate LIME to explain the `AdStrategist`'s targeting decisions and the `PrivacyAuditor`'s flagging decisions. This might involve creating a wrapper function or a custom tool for the agents to invoke LIME.

```python
# Example of how UserTopicAnalyzer might use Gemini
def analyze_topics(user_data: str) -> str:
    response = autogen.Completion.create(context=user_data, llm_config=llm_config)
    return response.get("choices")[0].get("message").get("content")

# Integrate this function into UserTopicAnalyzer's capabilities or tools

# Consider a custom tool for LIME:
# from autogen.agentchat.contrib.llm_utils import register_for_llm
# from lime.lime_text import LimeTextExplainer

# @register_for_llm(name="explain_decision", description="Generates a LIME explanation for a text-based decision.")
# def explain_decision(text_input: str, model_prediction_function, class_names: list) -> str:
#     explainer = LimeTextExplainer(class_names=class_names)
#     explanation = explainer.explain_instance(text_input, model_prediction_function, num_features=6)
#     return explanation.as_plain_text()
# # ... then make this tool available to the relevant agents
```