Antoine101 commited on
Commit
b30f209
·
verified ·
1 Parent(s): cdda2a3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -3
app.py CHANGED
@@ -13,8 +13,10 @@ from langgraph.prebuilt import ToolNode, tools_condition
13
  from langchain_core.messages import AnyMessage, SystemMessage, HumanMessage
14
  from langchain_groq import ChatGroq
15
  from langchain_huggingface import HuggingFaceEndpoint, ChatHuggingFace
 
16
  from langchain_ollama import ChatOllama
17
 
 
18
  # (Keep Constants as is)
19
  # --- Constants ---
20
  DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
@@ -45,11 +47,11 @@ model = AutoModelForCausalLM.from_pretrained(checkpoint, token=HF_TOKEN)
45
  #outputs = model.generate(inputs, max_new_tokens=50, temperature=0.2, top_p=0.9, do_sample=True)
46
  #print(tokenizer.decode(outputs[0]))
47
 
48
- pipe = pipeline('text-generation', model=model, tokenizer=tokenizer, max_length=2048)
49
- hf = HuggingFacePipeline(pipeline=pipe)
50
 
51
  #chat = ChatHuggingFace(llm=llm, verbose=True)
52
- chat = ChatOllama(llm=llm)
53
 
54
  tools = []
55
  chat_with_tools = chat.bind_tools(tools)
 
13
  from langchain_core.messages import AnyMessage, SystemMessage, HumanMessage
14
  from langchain_groq import ChatGroq
15
  from langchain_huggingface import HuggingFaceEndpoint, ChatHuggingFace
16
+ from langchain_huggingface.llms import HuggingFacePipeline
17
  from langchain_ollama import ChatOllama
18
 
19
+
20
  # (Keep Constants as is)
21
  # --- Constants ---
22
  DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
 
47
  #outputs = model.generate(inputs, max_new_tokens=50, temperature=0.2, top_p=0.9, do_sample=True)
48
  #print(tokenizer.decode(outputs[0]))
49
 
50
+ pipe = pipeline('text-generation', model=model, tokenizer=tokenizer, max_new_tokens=1000)
51
+ hf_pipe = HuggingFacePipeline(pipeline=pipe)
52
 
53
  #chat = ChatHuggingFace(llm=llm, verbose=True)
54
+ chat = ChatOllama(llm=hf).bind(skip_prompt=True)
55
 
56
  tools = []
57
  chat_with_tools = chat.bind_tools(tools)