Skip to content

Instantly share code, notes, and snippets.

@ranfysvalle02
Created October 31, 2023 02:16
Show Gist options
  • Save ranfysvalle02/d300bd984b57891f32e8088bd89db576 to your computer and use it in GitHub Desktop.
Save ranfysvalle02/d300bd984b57891f32e8088bd89db576 to your computer and use it in GitHub Desktop.
Council-AI-Routing.py
from council.agents import Agent
from council.chains import Chain
from council.llm import AzureLLM
from council.skills import LLMSkill
from council.agents import Agent
from council.filters import BasicFilter
from council.controllers import LLMController
from council.evaluators import LLMEvaluator
import os
os.environ["AZURE_LLM_API_KEY"] = ""
os.environ["AZURE_LLM_DEPLOYMENT_NAME"] = "gpt-4"
os.environ["AZURE_LLM_API_VERSION"] = "2023-05-15"
os.environ["AZURE_LLM_API_BASE"] = "https://.openai.azure.com/"
llm = AzureLLM.from_env()
openai_llm = llm
prompt = "Respond ONLY with 'Proof-Points Coming Soon'"
hw_skill = LLMSkill(llm=openai_llm, system_prompt=prompt)
hw_chain = Chain(name="MarketingAgent", description="can answer questions that mention 'proof points'", runners=[hw_skill])
prompt = "Respond ONLY with 'MDBvsX Coming Soon'"
em_skill = LLMSkill(llm=openai_llm, system_prompt=prompt)
em_chain = Chain(name="CompetitionAgent", description="can answer questions about MongoDB vs (competition)",
runners=[em_skill])
fake_prompt = "you will provide an answer not related to the question. specifically respond with 'The council does not approve.'"
fake_skill = LLMSkill(llm=openai_llm, system_prompt=fake_prompt)
fake_chain = Chain(name="fake", description="Can answer all questions", runners=[fake_skill])
controller = LLMController(llm=openai_llm, chains=[hw_chain, em_chain, fake_chain], response_threshold=5)
evaluator = LLMEvaluator(llm=openai_llm)
agent = Agent(controller=controller, evaluator=evaluator, filter=BasicFilter())
print("what is cosmosdb?")
result = agent.execute_from_user_message("what is cosmosdb?")
print(result.best_message.message)
print("show me some proof points where MongoDB does something amazing")
result = agent.execute_from_user_message("show me some proof points where MongoDB does something amazing")
print(result.best_message.message)
print("what is the best movie in 2001?")
result = agent.execute_from_user_message("what is the best movie in 2001?")
print(result.best_message.message)
@ranfysvalle02
Copy link
Author

what is cosmosdb?
MDBvsX Coming Soon
show me some proof points where MongoDB does something amazing
Proof-Points Coming Soon
what is the best movie in 2001?
The council does not approve.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment