Delete.app.py

#10
by Waseem7711 - opened
Files changed (1) hide show
  1. app.py +0 -41
app.py DELETED
@@ -1,41 +0,0 @@
1
- from langchain_openai import ChatOpenAI
2
- from langchain_core.prompts import ChatPromptTemplate
3
- from langchain_core.output_parsers import StrOutputParser
4
- from langchain_community.llms import Ollama
5
- import streamlit as st
6
- import os
7
- from dotenv import load_dotenv
8
-
9
- # Load environment variables
10
- load_dotenv()
11
-
12
- # Set environment variables
13
- os.environ["LANGCHAIN_TRACING_V2"] = "true"
14
- os.environ["LANGCHAIN_API_KEY"] = os.getenv("LANGCHAIN_API_KEY")
15
-
16
- # Prompt Template
17
- prompt = ChatPromptTemplate.from_messages(
18
- [
19
- ("system", "You are a helpful assistant. Please respond to the user queries"),
20
- ("user", "Question: {question}")
21
- ]
22
- )
23
-
24
- # Streamlit app setup
25
- st.title('Langchain Demo With LLAMA2 API')
26
-
27
- # User input
28
- input_text = st.text_input("Search the topic you want")
29
-
30
- # Ollama LLM (ensure the model is available, or access it through Hugging Face API)
31
- llm = Ollama(model="llama2")
32
- output_parser = StrOutputParser()
33
- chain = prompt | llm | output_parser
34
-
35
- # Display result when user inputs text
36
- if input_text:
37
- try:
38
- response = chain.invoke({"question": input_text})
39
- st.write(response)
40
- except Exception as e:
41
- st.error(f"Error: {e}")