Spaces:
Sleeping
Sleeping
Commit ·
0dbfea5
1
Parent(s): cd225db
llm config groq,together and openai
Browse files- LLMCONFIG/TOGETHERAI_CONFIG_LIST.json +23 -0
- LLMHandler/llmhandler.py +25 -24
- LLMS/oaillm.py +23 -0
- README.md +4 -0
- images/togetherai.png +0 -0
- streamlitui/loadui.py +30 -23
LLMCONFIG/TOGETHERAI_CONFIG_LIST.json
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[
|
| 2 |
+
|
| 3 |
+
{
|
| 4 |
+
"model": "meta-llama/Llama-3.3-70B-Instruct-Turbo",
|
| 5 |
+
"api_key": "your Together.AI API Key goes here",
|
| 6 |
+
"api_type": "together"
|
| 7 |
+
},
|
| 8 |
+
{
|
| 9 |
+
"model": "codellama/CodeLlama-70b-Instruct-hf",
|
| 10 |
+
"api_key": "your Together.AI API Key goes here",
|
| 11 |
+
"api_type": "together"
|
| 12 |
+
},
|
| 13 |
+
{
|
| 14 |
+
"model": "meta-llama/Llama-2-13b-chat-hf",
|
| 15 |
+
"api_key": "your Together.AI API Key goes here",
|
| 16 |
+
"api_type": "together"
|
| 17 |
+
},
|
| 18 |
+
{
|
| 19 |
+
"model": "Qwen/Qwen2-72B-Instruct",
|
| 20 |
+
"api_key": "your Together.AI API Key goes here",
|
| 21 |
+
"api_type": "together"
|
| 22 |
+
}
|
| 23 |
+
]
|
LLMHandler/llmhandler.py
CHANGED
|
@@ -1,4 +1,5 @@
|
|
| 1 |
from LLMS.groqllm import GroqLLM
|
|
|
|
| 2 |
|
| 3 |
|
| 4 |
class LLMHandler:
|
|
@@ -19,29 +20,29 @@ class LLMHandler:
|
|
| 19 |
obj_llm_config = GroqLLM(user_controls_input=self.user_control)
|
| 20 |
llm_config = obj_llm_config.groq_llm_config()
|
| 21 |
return llm_config
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
|
| 47 |
|
|
|
|
| 1 |
from LLMS.groqllm import GroqLLM
|
| 2 |
+
from LLMS.oaillm import OAILLM
|
| 3 |
|
| 4 |
|
| 5 |
class LLMHandler:
|
|
|
|
| 20 |
obj_llm_config = GroqLLM(user_controls_input=self.user_control)
|
| 21 |
llm_config = obj_llm_config.groq_llm_config()
|
| 22 |
return llm_config
|
| 23 |
+
|
| 24 |
+
def common_handler(self):
|
| 25 |
+
obj_llm_config = OAILLM(user_controls_input=self.user_control)
|
| 26 |
+
obj_llm_config.oai_llm_config()
|
| 27 |
+
|
| 28 |
+
def google_handler(self):
|
| 29 |
+
self.common_handler()
|
| 30 |
+
|
| 31 |
+
def mistral_handler(self):
|
| 32 |
+
self.common_handler()
|
| 33 |
+
|
| 34 |
+
def anthropic_handler(self):
|
| 35 |
+
self.common_handler()
|
| 36 |
+
|
| 37 |
+
def bedrock_handler(self):
|
| 38 |
+
self.common_handler()
|
| 39 |
+
|
| 40 |
+
def ollama_handler(self):
|
| 41 |
+
self.common_handler()
|
| 42 |
+
def together_handler(self):
|
| 43 |
+
self.common_handler()
|
| 44 |
+
|
| 45 |
+
def openai_handler(self):
|
| 46 |
+
self.common_handler()
|
| 47 |
|
| 48 |
|
LLMS/oaillm.py
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import autogen
|
| 2 |
+
import os
|
| 3 |
+
|
| 4 |
+
import streamlit as st
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
class OAILLM:
|
| 8 |
+
def __init__(self, user_controls_input):
|
| 9 |
+
self.user_controls_input = user_controls_input
|
| 10 |
+
|
| 11 |
+
def oai_llm_config(self):
|
| 12 |
+
config_list = [
|
| 13 |
+
{
|
| 14 |
+
"api_type": self.user_controls_input['api_type'],
|
| 15 |
+
"model": self.user_controls_input['selected_model_name'],
|
| 16 |
+
"api_key": st.session_state["api_key"],
|
| 17 |
+
"cache_seed": None
|
| 18 |
+
}
|
| 19 |
+
]
|
| 20 |
+
|
| 21 |
+
llm_config = {"config_list": config_list}
|
| 22 |
+
st.session_state['llm_config'] = llm_config
|
| 23 |
+
return llm_config
|
README.md
CHANGED
|
@@ -14,3 +14,7 @@ short_description: Autogen with various llm support
|
|
| 14 |
|
| 15 |
# AutogenLLM
|
| 16 |
Autogen with different LLM
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
|
| 15 |
# AutogenLLM
|
| 16 |
Autogen with different LLM
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
## Together AI
|
| 20 |
+

|
images/togetherai.png
ADDED
|
streamlitui/loadui.py
CHANGED
|
@@ -26,6 +26,7 @@ class Streamlit_UI() :
|
|
| 26 |
ollama_file = "./LLMCONFIG/OLLAMA_LLM_CONFIG_LIST.json"
|
| 27 |
groq_file = "./LLMCONFIG/GROQ_CONFIG_LIST.json"
|
| 28 |
bedrock_file = "./LLMCONFIG/BEDROCK_CONFIG_LIST.json"
|
|
|
|
| 29 |
|
| 30 |
# Load model configurations
|
| 31 |
anthropic_models = self.load_json(anthropic_file)
|
|
@@ -34,20 +35,22 @@ class Streamlit_UI() :
|
|
| 34 |
ollama_models = self.load_json(ollama_file)
|
| 35 |
groq_models = self.load_json(groq_file)
|
| 36 |
bedrock_models = self.load_json(bedrock_file)
|
|
|
|
| 37 |
|
| 38 |
# Combine all API types into a single dictionary
|
| 39 |
api_data = {
|
| 40 |
-
"anthropic": anthropic_models,
|
| 41 |
-
"bedrock": bedrock_models,
|
| 42 |
-
"google": google_models,
|
| 43 |
"groq": groq_models,
|
|
|
|
|
|
|
| 44 |
"mistral": mistral_models,
|
| 45 |
"ollama": ollama_models,
|
| 46 |
-
"
|
| 47 |
-
|
|
|
|
| 48 |
}
|
| 49 |
user_inputs = {}
|
| 50 |
-
|
|
|
|
| 51 |
with st.sidebar:
|
| 52 |
|
| 53 |
# Streamlit UI
|
|
@@ -67,25 +70,29 @@ class Streamlit_UI() :
|
|
| 67 |
|
| 68 |
# Dropdown to select model
|
| 69 |
model_names = [model["model"] for model in selected_models]
|
| 70 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 71 |
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 78 |
|
| 79 |
-
|
| 80 |
-
if key not in ["api_type", "model"]:
|
| 81 |
-
# Use a password field for API keys, otherwise a text input
|
| 82 |
-
input_label = f"Enter {key}"
|
| 83 |
-
if "key" in key.lower():
|
| 84 |
-
st.session_state['api_key'] = user_inputs[key] = st.text_input(input_label, value="", type="password")
|
| 85 |
-
elif isinstance(value, bool):
|
| 86 |
-
user_inputs[key] = st.checkbox(input_label, value=value)
|
| 87 |
-
else:
|
| 88 |
-
user_inputs[key] = st.text_input(input_label, value=str(value))
|
| 89 |
|
| 90 |
user_inputs['selected_model_name']= selected_model_name
|
| 91 |
|
|
|
|
| 26 |
ollama_file = "./LLMCONFIG/OLLAMA_LLM_CONFIG_LIST.json"
|
| 27 |
groq_file = "./LLMCONFIG/GROQ_CONFIG_LIST.json"
|
| 28 |
bedrock_file = "./LLMCONFIG/BEDROCK_CONFIG_LIST.json"
|
| 29 |
+
togetherai_file = "./LLMCONFIG/TOGETHERAI_CONFIG_LIST.json"
|
| 30 |
|
| 31 |
# Load model configurations
|
| 32 |
anthropic_models = self.load_json(anthropic_file)
|
|
|
|
| 35 |
ollama_models = self.load_json(ollama_file)
|
| 36 |
groq_models = self.load_json(groq_file)
|
| 37 |
bedrock_models = self.load_json(bedrock_file)
|
| 38 |
+
togetherai_models = self.load_json(togetherai_file)
|
| 39 |
|
| 40 |
# Combine all API types into a single dictionary
|
| 41 |
api_data = {
|
|
|
|
|
|
|
|
|
|
| 42 |
"groq": groq_models,
|
| 43 |
+
"together":togetherai_models,
|
| 44 |
+
"openai": [],
|
| 45 |
"mistral": mistral_models,
|
| 46 |
"ollama": ollama_models,
|
| 47 |
+
"anthropic": anthropic_models,
|
| 48 |
+
"bedrock": bedrock_models,
|
| 49 |
+
"google": google_models
|
| 50 |
}
|
| 51 |
user_inputs = {}
|
| 52 |
+
st.set_page_config(page_title= "AUTOGEN ~ 0.2", layout="wide",page_icon='🤖')
|
| 53 |
+
st.header("🤖 " + "AUTOGEN ~ 0.2")
|
| 54 |
with st.sidebar:
|
| 55 |
|
| 56 |
# Streamlit UI
|
|
|
|
| 70 |
|
| 71 |
# Dropdown to select model
|
| 72 |
model_names = [model["model"] for model in selected_models]
|
| 73 |
+
if st.checkbox("Select Model from list : ",True):
|
| 74 |
+
selected_model_name = st.selectbox("Select Model", options=model_names)
|
| 75 |
+
# Find the selected model configuration
|
| 76 |
+
selected_model_config = next(
|
| 77 |
+
(model for model in selected_models if model["model"] == selected_model_name), {}
|
| 78 |
+
)
|
| 79 |
+
# Input fields for the selected model configuration
|
| 80 |
|
| 81 |
+
for key, value in selected_model_config.items():
|
| 82 |
+
if key not in ["api_type", "model"]:
|
| 83 |
+
# Use a password field for API keys, otherwise a text input
|
| 84 |
+
input_label = f"Enter {key}"
|
| 85 |
+
if "key" in key.lower():
|
| 86 |
+
st.session_state['api_key'] = user_inputs[key] = st.text_input(input_label, value="", type="password")
|
| 87 |
+
elif isinstance(value, bool):
|
| 88 |
+
user_inputs[key] = st.checkbox(input_label, value=value)
|
| 89 |
+
else:
|
| 90 |
+
user_inputs[key] = st.text_input(input_label, value=str(value))
|
| 91 |
+
else :
|
| 92 |
+
selected_model_name = st.text_input("Enter Model Name", value="")
|
| 93 |
+
st.session_state['api_key'] = st.text_input("Enter api_key", value="", type="password",key='input_modelname')
|
| 94 |
|
| 95 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 96 |
|
| 97 |
user_inputs['selected_model_name']= selected_model_name
|
| 98 |
|