Spaces:
Sleeping
Sleeping
Upload app.py
Browse files
app.py
ADDED
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from langchain.chat_models import ChatOpenAI
|
2 |
+
from langchain.schema import HumanMessage
|
3 |
+
from dotenv import load_dotenv
|
4 |
+
import streamlit as st
|
5 |
+
import os
|
6 |
+
|
7 |
+
load_dotenv()
|
8 |
+
|
9 |
+
|
10 |
+
#function to load openAI model and get response
|
11 |
+
|
12 |
+
def get_model_response(question):
|
13 |
+
llm=ChatOpenAI(
|
14 |
+
base_url = "https://openrouter.ai/api/v1",
|
15 |
+
openai_api_key = os.getenv("OPENROUTE_API_KEY"),
|
16 |
+
model= "deepseek/deepseek-r1-zero:free",
|
17 |
+
temperature=0.4
|
18 |
+
)
|
19 |
+
response = llm.invoke([HumanMessage(content=question)])
|
20 |
+
return response
|
21 |
+
|
22 |
+
st.set_page_config(page_title="Chat With your love ❤️")
|
23 |
+
|
24 |
+
st.header("Langchain Application")
|
25 |
+
|
26 |
+
input = st.text_input("Input: ", key=input)
|
27 |
+
response = get_model_response(input)
|
28 |
+
submit = st.button("Ask")
|
29 |
+
|
30 |
+
if submit:
|
31 |
+
st.subheader("the Response is: ")
|
32 |
+
st.write(response.content)
|