Download main.py from kartavya17/LLAMA3: direct link, hf CLI and curl.
- Browser
- Download file 1.07 kB
-
https://huggingface.co/kartavya17/LLAMA3/resolve/main/main.py
- Command line
-
hf download hf://kartavya17/LLAMA3/main.py
-
curl -L -o main.py https://huggingface.co/kartavya17/LLAMA3/resolve/main/main.py
1.07 kB
| from langchain_openai import ChatOpenAI | |
| from langchain_core.prompts import ChatPromptTemplate | |
| from langchain_core.output_parsers import StrOutputParser | |
| from langchain_community.llms import Ollama | |
| import os | |
| import streamlit as st | |
| from dotenv import load_dotenv | |
| load_dotenv() | |
| os.environ["OPENAI_API_KEY"]=os.getenv("OPENAI_API_KEY", "not found") | |
| #langmith Tracking | |
| os.environ["LANGCHAIN_TRACING_V2"]="true" | |
| os.environ["LANGCHAIN_API_KEY"]=os.getenv("LANGCHAIN_API_KEY", "not found") | |
| #Prompt Template | |
| prompt = ChatPromptTemplate.from_messages( | |
| [ | |
| ("system", "You are a world class helpful assistant.Please respond to the user."), | |
| ("user","Question:{question}") | |
| ] | |
| ) | |
| #streamlit framework | |
| st.title('LLAMA3 using Langchain :sunglasses:') | |
| st.subheader("I am developed by :blue[Kartavya.] How can i assist you:question :") | |
| input_text = st.text_input("") | |
| #OLLAMA LLAma3 | |
| llm = Ollama(model="llama3") | |
| output_parser = StrOutputParser() | |
| chain = prompt|llm|output_parser | |
| if st.button("Enter"): | |
| st.write(chain.invoke({"question":input_text})) | |