deepakaitcs commited on
Commit
ac04983
·
1 Parent(s): 09c5196
Files changed (3) hide show
  1. README.md +1 -0
  2. app.py +31 -15
  3. requirements.txt +2 -1
README.md CHANGED
@@ -10,3 +10,4 @@ pinned: false
10
  ---
11
 
12
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
10
  ---
11
 
12
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
13
+ https://huggingface.co/spaces/deepakaitcs/learnai
app.py CHANGED
@@ -1,26 +1,42 @@
1
  ## Difference between Open AI and hugging face
2
 
 
 
 
3
  from dotenv import load_dotenv
4
  load_dotenv()
5
  from langchain_openai import OpenAI
6
  llm = OpenAI()
7
- result= llm.invoke("What is capital of India")
8
- print(result)
9
 
10
- ## Use Huggingface to load google Model using langchain
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
 
12
- from langchain import HuggingFaceHub
13
- llm2 = HuggingFaceHub(
14
- repo_id="google/flan-t5-large",
15
- model_kwargs={"temperature":0, "max_length":180}
16
- )
17
 
18
- results2= llm2("what is the capital of Sri lanka")
19
- print(results2)
20
 
21
- ## Use Google GenAI chat models using langChain
 
 
22
 
23
- from langchain_google_genai import ChatGoogleGenerativeAI
24
- chat = ChatGoogleGenerativeAI(model="gemini-pro")
25
- results3 = chat.invoke("What is the capital of Pakistan")
26
- print(results3.content)
 
1
  ## Difference between Open AI and hugging face
2
 
3
+ import streamlit as st
4
+
5
+
6
  from dotenv import load_dotenv
7
  load_dotenv()
8
  from langchain_openai import OpenAI
9
  llm = OpenAI()
 
 
10
 
11
+ def load_Answer(inputtext):
12
+ result= llm(inputtext)
13
+ return result
14
+
15
+ st.set_page_config(
16
+ page_title="My Chat GPT",
17
+ page_icon="🧊",
18
+ layout="wide",
19
+ initial_sidebar_state="expanded",
20
+ menu_items={
21
+ 'Get Help': 'https://www.extremelycoolapp.com/help',
22
+ 'Report a bug': "https://www.extremelycoolapp.com/bug",
23
+ 'About': "# This is a header. This is an *extremely* cool app!"
24
+ }
25
+ )
26
+
27
+ st.header('This is a header')
28
+
29
+ def get_text():
30
+ i= st.text_input("You: ", key="input")
31
+ return i
32
+
33
+ user_input = get_text()
34
 
35
+ response = load_Answer(user_input)
 
 
 
 
36
 
37
+ submit = st.button("Submit")
 
38
 
39
+ if submit:
40
+ st.subheader("Answer:")
41
+ st.write(response)
42
 
 
 
 
 
requirements.txt CHANGED
@@ -1,4 +1,5 @@
1
  langchain
2
  openai
3
  langchain_openai
4
- langchain_google_genai
 
 
1
  langchain
2
  openai
3
  langchain_openai
4
+ langchain_google_genai
5
+ streamlit