jdesiree commited on
Commit
27e4b47
·
verified ·
1 Parent(s): 9842e19

Model Change and Task Declaration

Browse files
Files changed (1) hide show
  1. app.py +6 -8
app.py CHANGED
@@ -18,14 +18,12 @@ if "HUGGINGFACEHUB_API_TOKEN" not in os.environ:
18
 
19
  # --- LLM and Template Configuration ---
20
  llm = HuggingFaceEndpoint(
21
- repo_id="EleutherAI/gpt-j-6B",
22
  temperature=0.7,
23
- top_p=0.9,
24
- repetition_penalty=1.1,
25
- max_new_tokens=1024,
26
- huggingfacehub_api_token=os.getenv("HUGGINGFACEHUB_API_TOKEN")
27
  )
28
-
29
  math_template = ChatPromptTemplate.from_messages([
30
  ("system", """{system_message}
31
  You are an expert math tutor. For every math problem:
@@ -133,7 +131,7 @@ def respond_with_enhanced_streaming(message, history):
133
 
134
  logger.info(f"Processing {mode} query: {message[:50]}...")
135
 
136
- # Use the chain with proper message history
137
  chain = template | llm
138
  response = chain.invoke({
139
  "question": message,
@@ -160,7 +158,7 @@ def respond_with_enhanced_streaming(message, history):
160
 
161
  except Exception as e:
162
  logger.exception("Error in LangChain response generation")
163
- yield f"Sorry, I encountered an error: {str(e)[:150]}"
164
 
165
  # --- Fixed Gradio UI and CSS ---
166
  custom_css = """
 
18
 
19
  # --- LLM and Template Configuration ---
20
  llm = HuggingFaceEndpoint(
21
+ repo_id="google/flan-t5-base",
22
  temperature=0.7,
23
+ max_new_tokens=512,
24
+ huggingfacehub_api_token=os.getenv("HUGGINGFACEHUB_API_TOKEN"),
25
+ task="text2text-generation"
 
26
  )
 
27
  math_template = ChatPromptTemplate.from_messages([
28
  ("system", """{system_message}
29
  You are an expert math tutor. For every math problem:
 
131
 
132
  logger.info(f"Processing {mode} query: {message[:50]}...")
133
 
134
+ # Use the chain with proper message history (YOUR ORIGINAL APPROACH)
135
  chain = template | llm
136
  response = chain.invoke({
137
  "question": message,
 
158
 
159
  except Exception as e:
160
  logger.exception("Error in LangChain response generation")
161
+ yield f"Sorry, I encountered an error: {str(e)}"
162
 
163
  # --- Fixed Gradio UI and CSS ---
164
  custom_css = """