Spaces:
Sleeping
Sleeping
vismaya2939
commited on
Commit
•
8a30ac6
1
Parent(s):
c3037a8
Update app.py
Browse files
app.py
CHANGED
@@ -1,25 +1,12 @@
|
|
1 |
-
#Hello! It seems like you want to import the Streamlit library in Python. Streamlit is a powerful open-source framework used for building web applications with interactive data visualizations and machine learning models. To import Streamlit, you'll need to ensure that you have it installed in your Python environment.
|
2 |
-
#Once you have Streamlit installed, you can import it into your Python script using the import statement,
|
3 |
-
|
4 |
import streamlit as st
|
5 |
|
6 |
-
from langchain_openai import OpenAI
|
7 |
-
from langchain_huggingface import HuggingFaceEndpoint
|
8 |
-
|
9 |
-
#When deployed on huggingface spaces, this values has to be passed using Variables & Secrets setting, as shown in the video :)
|
10 |
-
#import os
|
11 |
-
#os.environ["OPENAI_API_KEY"] = "sk-PLfFwPq6y24234234234FJ1Uc234234L8hVowXdt"
|
12 |
|
13 |
-
import
|
14 |
-
os.environ["HUGGINGFACEHUB_API_TOKEN"] = "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"
|
15 |
|
16 |
#Function to return the response
|
17 |
def load_answer(question):
|
18 |
-
|
19 |
-
llm
|
20 |
-
repo_id="mistralai/Mistral-7B-Instruct-v0.3") # Model link : https://huggingface.co/mistralai/Mistral-7B-Instruct-v0.3
|
21 |
-
|
22 |
-
answer=llm.invoke(question)
|
23 |
return answer
|
24 |
|
25 |
|
@@ -34,8 +21,7 @@ def get_text():
|
|
34 |
|
35 |
|
36 |
user_input=get_text()
|
37 |
-
|
38 |
-
response = load_answer(user_input)
|
39 |
|
40 |
submit = st.button('Generate')
|
41 |
|
@@ -44,5 +30,4 @@ if submit:
|
|
44 |
|
45 |
st.subheader("Answer:")
|
46 |
|
47 |
-
st.write(response)
|
48 |
-
|
|
|
|
|
|
|
|
|
1 |
import streamlit as st
|
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
|
4 |
+
from langchain.llms import openai
|
|
|
5 |
|
6 |
#Function to return the response
|
7 |
def load_answer(question):
|
8 |
+
llm = OpenAI(model_name="gpt-3.5-turbo-instruct",temperature=0)
|
9 |
+
answer=llm(question)
|
|
|
|
|
|
|
10 |
return answer
|
11 |
|
12 |
|
|
|
21 |
|
22 |
|
23 |
user_input=get_text()
|
24 |
+
response = load_answer(user_input)
|
|
|
25 |
|
26 |
submit = st.button('Generate')
|
27 |
|
|
|
30 |
|
31 |
st.subheader("Answer:")
|
32 |
|
33 |
+
st.write(response)
|
|