Forked from mberman84/gist:de81e435d2d10248551106903f8c0ae5
Created
August 4, 2024 01:12
-
-
Save edisplay/dfd917ef52b9d01dabb233e90be2bfef to your computer and use it in GitHub Desktop.
RouteLLM Script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
os.environ["OPENAI_API_KEY"] = "XXX" | |
os.environ["GROQ_API_KEY"] = "YYY" | |
from routellm.controller import Controller | |
client = Controller( | |
routers=["mf"], | |
strong_model="gpt-4-1106-preview", | |
weak_model="groq/llama3-8b-8192" | |
) | |
response = client.chat.completions.create( | |
# This tells RouteLLM to use the MF router with a cost threshold of 0.11593 | |
model="router-mf-0.11593", | |
messages=[ | |
{"role": "user", "content": "Write the game snake in python"} | |
] | |
) | |
message_content = response['choices'][0]['message']['content'] | |
model_name = response['model'] | |
print(f"Message content: {message_content}") | |
print(f"Model name: {model_name}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment