samim2024 commited on
Commit
3d94688
·
verified ·
1 Parent(s): 22261d7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -5
app.py CHANGED
@@ -8,7 +8,8 @@ import streamlit as st
8
  #from langchain.llms import OpenAI
9
 
10
  #New import from langchain, which replaces the above
11
- from langchain_openai import OpenAI
 
12
 
13
  #When deployed on huggingface spaces, this values has to be passed using Variables & Secrets setting, as shown in the video :)
14
  #import os
@@ -17,16 +18,16 @@ from langchain_openai import OpenAI
17
  #Function to return the response
18
  def load_answer(question):
19
  # "text-davinci-003" model is depreciated, so using the latest one https://platform.openai.com/docs/deprecations
20
- llm = OpenAI(model_name="gpt-3.5-turbo-instruct",temperature=0)
21
-
22
  #Last week langchain has recommended to use invoke function for the below please :)
23
  answer=llm.invoke(question)
24
  return answer
25
 
26
 
27
  #App UI starts here
28
- st.set_page_config(page_title="LangChain Demo", page_icon=":robot:")
29
- st.header("LangChain Demo")
30
 
31
  #Gets the user input
32
  def get_text():
 
8
  #from langchain.llms import OpenAI
9
 
10
  #New import from langchain, which replaces the above
11
+ #from langchain_openai import OpenAI
12
+ from langchain.llms import HuggingFaceEndpoint
13
 
14
  #When deployed on huggingface spaces, this values has to be passed using Variables & Secrets setting, as shown in the video :)
15
  #import os
 
18
  #Function to return the response
19
  def load_answer(question):
20
  # "text-davinci-003" model is depreciated, so using the latest one https://platform.openai.com/docs/deprecations
21
+ #llm = OpenAI(model_name="gpt-3.5-turbo-instruct",temperature=0)
22
+ llm = HuggingFaceEndpoint(repo_id="mistralai/Mistral-7B-Instruct-v0.2",temperature=0)
23
  #Last week langchain has recommended to use invoke function for the below please :)
24
  answer=llm.invoke(question)
25
  return answer
26
 
27
 
28
  #App UI starts here
29
+ st.set_page_config(page_title="Samim LangChain Demo", page_icon=":robot:")
30
+ st.header("Samim LangChain Demo")
31
 
32
  #Gets the user input
33
  def get_text():