67Ayush87 commited on
Commit
15a2774
·
verified ·
1 Parent(s): 6559c38

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +42 -12
app.py CHANGED
@@ -1,16 +1,46 @@
1
- import os
2
- import langchain
3
- import langchain_huggingface
4
- from langchain_huggingface import HuggingFaceEndpoint,HuggingFacePipeline, ChatHuggingFace
5
- from langchain_google_genai import GoogleGenerativeAI, ChatGoogleGenerativeAI
6
- from langchain_core.messages import HumanMessage, SystemMessage, AIMessage
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
 
 
 
8
  os.environ["HF_TOKEN"]=os.getenv('Ayush')
9
  os.environ["HUGGINGFACEHUB_API_KEY"]=os.getenv('Ayush')
10
 
11
- llama_model = HuggingFaceEndpoint(repo_id= "meta-llama/Llama-3.2-3B-Instruct",provider= "nebius",temperature=0.6, max_new_tokens=70,task="conversational")
12
- model_d=ChatHuggingFace(llm =llama_model,repo_id= "meta-llama/Llama-3.2-3B-Instruct",provider= "nebius",temperature=0.6, max_new_tokens=70,task="conversational")
13
- message = [SystemMessage(content = "Answer like you are a hardcore pc gamer"),
14
- HumanMessage(content = "Give me name of top 10 pc games of all time with description")]
15
- result = model_d.invoke(message)
16
- print(result.content)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # import os
2
+ # import langchain
3
+ # import langchain_huggingface
4
+ # from langchain_huggingface import HuggingFaceEndpoint,HuggingFacePipeline, ChatHuggingFace
5
+ # from langchain_core.messages import HumanMessage, SystemMessage, AIMessage
6
+
7
+ # os.environ["HF_TOKEN"]=os.getenv('Ayush')
8
+ # os.environ["HUGGINGFACEHUB_API_KEY"]=os.getenv('Ayush')
9
+
10
+ # llama_model = HuggingFaceEndpoint(repo_id= "meta-llama/Llama-3.2-3B-Instruct",provider= "nebius",temperature=0.6, max_new_tokens=70,task="conversational")
11
+ # model_d=ChatHuggingFace(llm =llama_model,repo_id= "meta-llama/Llama-3.2-3B-Instruct",provider= "nebius",temperature=0.6, max_new_tokens=70,task="conversational")
12
+ # message = [SystemMessage(content = "Answer like you are a hardcore pc gamer"),
13
+ # HumanMessage(content = "Give me name of top 10 pc games of all time with description")]
14
+ # result = model_d.invoke(message)
15
+ # print(result.content)
16
+
17
+ import streamlit as st
18
+ from langchain_community.chat_models import ChatHuggingFace
19
+ from langchain_community.llms import HuggingFaceHub
20
+ from langchain_core.messages import HumanMessage, SystemMessage
21
 
22
+ # Setup API key (replace with your key or use st.secrets)
23
+ import os
24
  os.environ["HF_TOKEN"]=os.getenv('Ayush')
25
  os.environ["HUGGINGFACEHUB_API_KEY"]=os.getenv('Ayush')
26
 
27
+ # Load model
28
+ llm = HuggingFaceHub(
29
+ repo_id="meta-llama/Llama-3.2-3B-Instruct",
30
+ model_kwargs={"temperature": 0.6, "max_new_tokens": 100}
31
+ )
32
+ chat_model = ChatHuggingFace(llm=llm)
33
+
34
+ # Streamlit UI
35
+ st.title("🧪 Simple LLaMA Chat Test")
36
+
37
+ question = st.text_input("Ask a gaming-related question:", "Give me name of top 10 PC games of all time with description")
38
+
39
+ if st.button("Ask"):
40
+ messages = [
41
+ SystemMessage(content="Answer like you are a hardcore PC gamer"),
42
+ HumanMessage(content=question)
43
+ ]
44
+ response = chat_model.invoke(messages)
45
+ st.write("### Response:")
46
+ st.write(response.content)