Dhanushlevi commited on
Commit
8328420
·
verified ·
1 Parent(s): 98f291b

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -0
app.py ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from langchain_huggingface import HuggingFaceEndpoint
3
+ from secrets import HUGGING_FACE_TOKEN # Importing the token from a separate file
4
+
5
+ # Define your HuggingFace endpoint details
6
+ repo_id_1 = "mistralai/Mistral-7B-Instruct-v0.2"
7
+ repo_id_2 = "mistralai/Mistral-7B-Instruct-v0.3"
8
+
9
+ # Initialize the HuggingFace endpoints
10
+ llm_1 = HuggingFaceEndpoint(repo_id=repo_id_1, max_length=128, temperature=0.7, token=HUGGING_FACE_TOKEN)
11
+ llm_2 = HuggingFaceEndpoint(repo_id=repo_id_2, max_length=128, temperature=0.7, token=HUGGING_FACE_TOKEN)
12
+
13
+ # Define a function to get responses from both models
14
+ def get_combined_response(prompt):
15
+ response_1 = llm_1.invoke(prompt)
16
+ response_2 = llm_2.invoke(prompt)
17
+ combined_response = f"Model 1 Response: {response_1}\n\nModel 2 Response: {response_2}"
18
+ return combined_response
19
+
20
+ # Create a Gradio interface for the combined function
21
+ iface_combined = gr.Interface(fn=get_combined_response, inputs="text", outputs="text", title="Combined Machine Learning Chatbots")
22
+
23
+ # Launch the Gradio app
24
+ iface_combined.launch()